With clang-tidy static analyzer I can keep a file (.clang-tidy
) in the root of the project with the warnings I want to activate or deactivate.
clang-tidy
will look for this file (as far I know) and use the options defined there. This saves me from hard coding long command lines in CMake or Makefiles.
Is it possible to do the same with cppcheck
static analyzer?
Currently I have this very long command line hardcoded:
cppcheck --max-ctu-depth=3 --enable=all --inline-suppr --suppress=*:*thrust/complex* --suppress=missingInclude --suppress=syntaxError --suppress=unmatchedSuppression --suppress=preprocessorErrorDirective --language=c++ --std=c++14 --error-exitcode=666
This is an example of .clang-tidy
configuration file that I keep at the root of a project:
---
Checks: '
*,
-readability-magic-numbers,
-modernize-use-nodiscard,
-altera-struct-pack-align,
-cert-err58-cpp,
-cppcoreguidelines-avoid-non-const-global-variables,
-cppcoreguidelines-macro-usage,
-cppcoreguidelines-pro-bounds-array-to-pointer-decay,
-cppcoreguidelines-pro-type-vararg,
-cppcoreguidelines-avoid-magic-numbers,
-fuchsia-default-arguments-calls,
-fuchsia-trailing-return,
-fuchsia-statically-constructed-objects,
-fuchsia-overloaded-operator,
-hicpp-vararg,
-hicpp-no-array-decay,
-llvm-header-guard,
-llvmlibc-restrict-system-libc-headers,
-llvmlibc-implementation-in-namespace,
-llvmlibc-callee-namespace
'
WarningsAsErrors: '*'
HeaderFilterRegex: '.'
AnalyzeTemporaryDtors: false
FormatStyle: file
...
--suppressions-list
should have a default value. – Kuban