enh(ci): add Clang-Tidy to the CI
Description
A lot of time is spent during review to spot mistakes that could be detected automatically by a static analysis tool. Clang-Tidy proposes a lot of checks. On my computer, it takes one hour to scan the whole Sight repository, but on the CI it will only scan modified files, so it should be faster in practice. I tested on my MR on GUI tests with ~50 modified C++ files, it takes around 15 minutes in the CI to complete, which I believe is acceptable. Unfortunately, Clang-Tidy can't generate report on its own. I use aha
to convert the output of the command to an HTML file named clang-tidy.html
.
GitLab supports "codequality" reports, which allow to supply the list of warnings as a JSON file, so that GitLab can display them in the web interface.
It is displayed in the MR interface:
As well as in the pipeline interface:
How to test it?
The CI runs, the HTML report is created and the warnings are relevant.
Additional tests/tasks to run
-
Install aha
in the image -
Audit which checks are relevant and which warnings must be suppressed -
Fix the warnings, so as to cause an error if a warning is encountered (might be progressive)
Related to sight-git#47 (closed)