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.
54
-
(See the [list of checks](https://clang.llvm.org/extra/clang-tidy/checks/list.html).)
54
+
(See the [list of checks](https://releases.llvm.org/20.1.0/tools/clang/tools/extra/docs/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
+
By default, Clang-Tidy uses the configuration in [`.clang-tidy`](https://github.com/AliceO2Group/O2Physics/blob/master/.clang-tidy).
57
+
58
+
False positives can be suppressed per line with `// NOLINT(check-name,...)`. (See the [documentation](https://releases.llvm.org/20.1.0/tools/clang/tools/extra/docs/clang-tidy/index.html#suppressing-undesired-diagnostics) for details.)
59
+
60
+
### Running directly
61
+
62
+
To run Clang-Tidy directly locally, 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.
63
+
64
+
Without further options, you can run Clang-Tidy with
65
+
66
+
```bash
67
+
clang-tidy file1 file2 ...
68
+
```
69
+
70
+
### Running with O2Physics-code-check
71
+
72
+
Clang-Tidy runs on O2Physics PRs as the O2Physics-code-check tool under the `build/O2Physics/code-check` CI check, using the repository configuration.
73
+
You can run the check locally to test C++ files modified since `<base-commit>` until `<head-commit>` with
where `<base-commit>` is typically `upstream/master` and `<head-commit>` is `HEAD` by default if `ALIBUILD_HEAD_HASH` is omitted.
80
+
If `ALIBUILD_BASE_HASH` is omitted, all tracked C++ files are analysed.
81
+
82
+
Enabled checks can be modified with the `O2PHYSICS_CHECKER_CHECKS=...` option.
83
+
84
+
Fixes can be enabled with the `O2PHYSICS_CHECKER_FIX=1` option.
57
85
58
86
### Checking naming conventions
59
87
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) using the configuration in [`.clang-tidy`](https://github.com/AliceO2Group/O2Physics/blob/master/.clang-tidy).
88
+
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).
61
89
62
90
```tip
63
91
Learn how to form a [correct camelCase name](https://google.github.io/styleguide/javaguide.html#s5.3-camel-case).
@@ -113,6 +141,8 @@ The include format is corrected automatically in O2Physics PRs as part of the au
113
141
114
142
Cppcheck is a static analysis tool for C/C++ code that detects bugs, undefined behaviour, and dangerous coding constructs that compilers typically miss.
115
143
144
+
False positives can be suppressed per line with `// cppcheck-suppress check-name`. (See the [documentation](https://github.com/cppcheck-opensource/cppcheck/blob/main/man/manual.md#inline-suppressions) for details.)
145
+
116
146
Cppcheck can analyse individual files (file mode) or entire projects (project mode).
117
147
The two modes give slightly different results so one can consider using both for maximum coverage.
118
148
@@ -123,15 +153,15 @@ The file mode is used in the MegaLinter check on GitHub.
123
153
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.
@@ -143,7 +173,7 @@ To use this mode, you need to have O2Physics compiled and a valid symbolic link
143
173
Instead of providing file paths, provide the path to the project compilation database and use the `-j` option for parallelisation:
0 commit comments