(ci): add static analysis
Description
We spend way too much time in review to detect mistakes that could be detected by a good static analysis tool. Sheldon has a hook to launch cppcheck
but we never enabled it on the ci, apparently because it was very slow.
Proposal
- Reevaluate
cppcheck
run on the ci - Evaluate clang-tidy
- Evaluate gcc11 static analysis tool
Evaluation
Clang-tidy
-
Works with a program database: requires building sight
-
CMake provides a variable to enable checks:
set(CMAKE_CXX_CLANG_TIDY ${CLANG_TIDY};--header-filter=.*;--checks=*,-llvm-header-guard,-llvmlibc-*,-fuchsia-*,-altera-struct-pack-align,-bugprone-macro-parentheses;--use-color)
--checks=* -> enable all checks --checks=
-
<...> -> disable checks -
Provides an "auto-fix" mode, but is rather unusable since too much "fixes" break the code. Since CMake variable is global, there is no way to disable it easily for a part of sight...
Edited by Didier WECKMANN