]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#3930] Fix cppcheck after adoption of meson
authorAndrei Pavel <andrei@isc.org>
Thu, 19 Jun 2025 07:09:14 +0000 (10:09 +0300)
committerAndrei Pavel <andrei@isc.org>
Thu, 19 Jun 2025 07:09:14 +0000 (10:09 +0300)
- Was running on build dir which had little to no sources.
- Use the compile_commands.json file provided by meson which enables
  cppcheck to know about compiler flags used in compilation.
- Make the cppcheck target write to cppcheck-result.xml which is
  expected in the cppcheck-htmlreport target.
- Add library=googletest so it correctly decodes gtest macros.
- Remove suppression list. A lot of the suppressions were fixed with
  proper use of cppcheck or are no longer reported.

meson.build
src/cppcheck-suppress.lst

index 7e3440cea48ea860089374ced580b9c186b33634..228a6fff1c0e11d2846a8a724dd13cf38d414dae 100644 (file)
@@ -921,17 +921,18 @@ if cppcheck.found()
         'cppcheck',
         command: [
             cppcheck,
-            '-I.',
-            '-I./src/lib',
-            '-I./src/bin',
+            '--check-level=exhaustive',
+            '--enable=all',
             '--inline-suppr',
+            '--library=googletest',
+            '--output-file=cppcheck-result.xml',
+            '--project=compile_commands.json',
             '--quiet',
-            '--max-configs=256',
+            '--report-progress',
             f'--suppressions-list=@TOP_SOURCE_DIR@/src/cppcheck-suppress.lst',
             '--template={file}:{line}: check_fail: {message} ({severity},{id})',
             '--xml',
             '--xml-version=2',
-            '.',
         ],
     )
 endif
@@ -945,6 +946,8 @@ if cppcheck_htmlreport.found()
             './cppcheck-result.xml',
             '--report-dir',
             './report',
+            '--source-dir',
+            TOP_SOURCE_DIR,
             '--title',
             '"cppcheck report"',
         ],
index 9dc8d996198766de0f5bf94aff50f0620dbc7b37..7c2557233f12a06e96c69d9c558e032dbb0a0b53 100644 (file)
@@ -1,28 +1,6 @@
-// On some systems cppcheck produces false alarms about 'missing includes'.
-// the following two will suppress, depending on the cppcheck version
-debug
-missingInclude
+// Supress errors that are often false positives.
+missingIncludeSystem
 
-// Please don't add any suppressions here. We now use inline
-// suppressions (in the .cc files) so that we don't have to
-// maintain line numbers in this file.
-//
-// See the cppcheck manual for syntax. It is something like:
-//
-//    // cppcheck-suppress duplicateExpression
-//    EXPECT_FALSE(small_name < small_name);
-
-// With cppcheck 1.56, there are a number of false positives, which
-// All of these should be checked and hopefully removed after upgrading
-// cppcheck past 1.56
-
-// eraseDereference: This is a known false positive, which has been
-// fixed in the current development version of cppcheck
-eraseDereference
-
-// Unused functions: there suddenly are a lot of unused function errors
-// We could address those by adding for instance early declarations or
-// (unnecessary) header files, but they were all somewhat false positives
-// When we upgrade past 1.56, we should re-check this, and perhaps enable
-// unused-functions again.
-unusedFunction
+// Supress errors from external sources.
+*:/usr/include/*
+*:/usr/src/googletest/*