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
`clang-tidy` is a clang-based C++ linter tool for diagnosing and fixing typical programming errors, like style violations or bugs.
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
-
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.
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
58
### Checking naming conventions
59
59
@@ -69,23 +69,37 @@ This helps to apply the [Include What You Use](https://github.com/AliceO2Group/O
69
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.
76
76
77
-
For each file, `clang-tidy` will first try to compile it and then run the enabled check(s) and fix found problems (the `--fix` option).
77
+
For each file, Clang-Tidy will first try to compile it and then run the enabled check(s) and fix found problems (the `--fix` option).
78
78
The messages are redirected into `clang-tidy.log`.
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"`.
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"`.
80
80
81
-
## [cppcheck](https://cppcheck.sourceforge.io/)
81
+
## Fixing include format
82
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.
83
+
Headers from the same project should be included using quotation marks (`#include "path/header.h"`), all other headers should be included using angle brackets (`#include <path/header.h>`).
84
+
Failing to do so can result in picking a wrong header.
85
+
See more details in the [C++ Core Guidelines](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#sf12-prefer-the-quoted-form-of-include-for-files-relative-to-the-including-file-and-the-angle-bracket-form-everywhere-else).
84
86
85
-
`cppcheck` can analyse individual files (file mode) or entire projects (project mode).
87
+
The [`format_includes.awk`](https://github.com/AliceO2Group/O2Physics/blob/master/Scripts/format_includes.awk) script allows to fix the include format in a provided O2Physics file.
88
+
89
+
To fix the include format in all `.h`, `.cxx` files in the current directory, execute:
Cppcheck is a static analysis tool for C/C++ code that detects bugs, undefined behaviour, and dangerous coding constructs that compilers typically miss.
98
+
99
+
Cppcheck can analyse individual files (file mode) or entire projects (project mode).
86
100
The two modes give slightly different results so one can consider using both for maximum coverage.
87
101
88
-
### Using cppcheck in file mode
102
+
### Using Cppcheck in file mode
89
103
90
104
The file mode is used in the MegaLinter check on GitHub.
91
105
@@ -100,12 +114,12 @@ The report will be stored in the `err.log` file.
100
114
To run a parallelised analysis of all `.h`, `.cxx`, `.C` files in the current directory, execute:
Note: It is possible to parallelise the execution with the `-j` option instead but it usually produces less results than analysing files independently.
107
121
108
-
### Using cppcheck in project mode
122
+
### Using Cppcheck in project mode
109
123
110
124
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.
0 commit comments