From 71420b1b0e4d84ff86bedbb39b3dd28b09b685a0 Mon Sep 17 00:00:00 2001 From: Phong Nguyen Date: Sat, 15 Nov 2025 21:08:10 +0700 Subject: [PATCH 1/2] cppcheck - activate inline suspressions --- .github/workflows/cpp-build-test-coverage.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/cpp-build-test-coverage.yml b/.github/workflows/cpp-build-test-coverage.yml index f8ac5bb..4f168bb 100644 --- a/.github/workflows/cpp-build-test-coverage.yml +++ b/.github/workflows/cpp-build-test-coverage.yml @@ -46,6 +46,7 @@ jobs: # Step 2: Run Cppcheck (Static Analysis) # - Scans for common C++ issues (style, memory, logic) # - You can adjust `--enable=` options as needed + # - https://cppcheck.sourceforge.io/manual.pdf # ------------------------------------------------------- - name: Run static analysis with Cppcheck run: | @@ -53,6 +54,7 @@ jobs: cppcheck --enable=warning,style,performance,portability \ --inconclusive \ --quiet \ + --inline-suppr \ --error-exitcode=1 \ ./src ./include From 6e838000f7c43bb4f26ca8367f365a45b4cef885 Mon Sep 17 00:00:00 2001 From: Phong Nguyen Date: Sat, 15 Nov 2025 21:12:34 +0700 Subject: [PATCH 2/2] Add // cppcheck-suppress-file to ignore warnings for this problem example --- src/core/datatypes/class/RoleOfThreeFiveZero.cpp | 2 ++ src/core/datatypes/class/SallowDeepCopying.cpp | 8 ++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/core/datatypes/class/RoleOfThreeFiveZero.cpp b/src/core/datatypes/class/RoleOfThreeFiveZero.cpp index 8fd7cd4..ac2e173 100644 --- a/src/core/datatypes/class/RoleOfThreeFiveZero.cpp +++ b/src/core/datatypes/class/RoleOfThreeFiveZero.cpp @@ -1,3 +1,5 @@ +// cppcheck-suppress-file [noCopyConstructor, noOperatorEq, accessMoved] + #include #include #include diff --git a/src/core/datatypes/class/SallowDeepCopying.cpp b/src/core/datatypes/class/SallowDeepCopying.cpp index b5bacef..08c391d 100644 --- a/src/core/datatypes/class/SallowDeepCopying.cpp +++ b/src/core/datatypes/class/SallowDeepCopying.cpp @@ -1,3 +1,5 @@ +// cppcheck-suppress-file [noCopyConstructor, noOperatorEq, unsafeClassCanLeak] + #include namespace @@ -35,12 +37,13 @@ namespace } } - int getPtr() + int getPtr() const { if (ptr != nullptr) { return *ptr; } + return 0; } // Implicit copy constructor: Model a{b}; @@ -149,12 +152,13 @@ namespace } } - int getPtr() + int getPtr() const { if (ptr != nullptr) { return *ptr; } + return 0; } };