You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/tools/README.md
+67-11Lines changed: 67 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -53,28 +53,23 @@ Next time you execute `git commit`, the hooks will run automatically.
53
53
`clang-tidy` is a clang-based C++ linter tool for diagnosing and fixing typical programming errors, like style violations or bugs.
54
54
(See the [list of checks](https://clang.llvm.org/extra/clang-tidy/checks/list.html).)
55
55
56
-
### Prerequisites for using clang-tidy
56
+
To use `clang-tidy`, you need to have O2Physics compiled and a valid symbolic link `compile_commands.json` in the O2Physics directory pointing to the `alice/sw/BUILD/.../O2Physics` directory.
57
57
58
-
- You need to have O2Physics successfully compiled.
59
-
- Verify that there is a valid symbolic link `compile_commands.json` in the O2Physics directory pointing to the `alice/sw/BUILD/.../O2Physics` directory.
60
-
61
-
### Tips
62
-
63
-
#### Naming conventions
58
+
### Checking naming conventions
64
59
65
60
The [`readability-identifier-naming`](https://clang.llvm.org/extra/clang-tidy/checks/readability/identifier-naming.html) check can fix deviations from the [naming conventions](https://rawgit.com/AliceO2Group/CodingGuidelines/master/naming_formatting.html).
66
61
67
-
####Cleaning `#include`s
62
+
### Cleaning `#include`s
68
63
69
64
The [`misc-include-cleaner`](https://clang.llvm.org/extra/clang-tidy/checks/misc/include-cleaner.html) check can fix missing and unused `#include`s.
70
65
This helps to apply the [Include What You Use](https://github.com/AliceO2Group/O2Physics/issues/8357) principle which allows to maintain header dependencies clean.
71
66
72
-
####Testing (and fixing) many files at once
67
+
### Testing (and fixing) many files at once
73
68
74
-
Here is an example of how to run the `misc-include-cleaner` check in parallel on all `.h` and `.cxx` files in the current directory.
69
+
Here is an example of how to run the `misc-include-cleaner` check in parallel on all `.h`, `.cxx`, `.C` files in the current directory.
The [`parallel`](https://www.gnu.org/software/parallel/) command is used to parallelise the execution of the `clang-tidy` command for all files.
@@ -83,6 +78,67 @@ For each file, `clang-tidy` will first try to compile it and then run the enable
83
78
The messages are redirected into `clang-tidy.log`.
84
79
The file name and the exit code are printed below the output of `clang-tidy` so that you can get the list of files for which `clang-tidy` failed with `grep " 1$" "clang-tidy.log"`.
85
80
81
+
## [cppcheck](https://cppcheck.sourceforge.io/)
82
+
83
+
`cppcheck` is a static analysis tool for C/C++ code that detects bugs, undefined behaviour, and dangerous coding constructs that compilers typically miss.
84
+
85
+
`cppcheck` can analyse individual files (file mode) or entire projects (project mode).
86
+
The two modes give slightly different results so one can consider using both for maximum coverage.
87
+
88
+
### Using cppcheck in file mode
89
+
90
+
The file mode is used in the MegaLinter check on GitHub.
91
+
92
+
To use this mode, provide paths of files you want to analyse in the following way:
Note: It is possible to parallelise the execution with the `-j` option instead but it usually produces less results than analysing files independently.
107
+
108
+
### Using cppcheck in project mode
109
+
110
+
To use this mode, you need to have O2Physics compiled and a valid symbolic link `compile_commands.json` in the O2Physics directory pointing to the `alice/sw/BUILD/.../O2Physics` directory.
111
+
112
+
Instead of providing file paths, provide the path to the project compilation database and use the `-j` option for parallelisation:
0 commit comments