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
cpp-linter-hooks is a [pre-commit](https://pre-commit.com/) hook that uses `clang-format` and `clang-tidy` to format C/C++ code.
9
+
A powerful [pre-commit](https://pre-commit.com/) hook that automatically formats and lints your C/C++ code using `clang-format` and `clang-tidy`.
11
10
12
-
> [!NOTE]
13
-
> This hook automatically downloads specific versions of `clang-format` or `clang-tidy`[static-binaries](https://github.com/cpp-linter/clang-tools-static-binaries) and installs them on your system.
To use custom configurations like `.clang-format` and `.clang-tidy`:
35
42
@@ -44,6 +51,8 @@ repos:
44
51
args: [--checks=.clang-tidy] # Loads checks from .clang-tidy file
45
52
```
46
53
54
+
### Custom Clang Tool Version
55
+
47
56
To use specific versions of [clang-tools](https://github.com/cpp-linter/clang-tools-pip?tab=readme-ov-file#supported-versions):
48
57
49
58
```yaml
@@ -57,6 +66,8 @@ repos:
57
66
args: [--checks=.clang-tidy, --version=18] # Specifies version
58
67
```
59
68
69
+
### Troubleshooting
70
+
60
71
> [!IMPORTANT]
61
72
> If your `pre-commit` runs longer than expected, it is highly recommended to add `files` in `.pre-commit-config.yaml` to limit the scope of the hook. This helps improve performance by reducing the number of files being checked and avoids unnecessary processing. Here's an example configuration:
62
73
@@ -81,9 +92,22 @@ pre-commit run --files $(git diff --name-only)
81
92
82
93
This approach ensures that only modified files are checked, further speeding up the linting process during development.
83
94
95
+
### Debugging `clang-format` hook
96
+
97
+
If you encounter issues with the clang-format hook (such as exit code 247 or other errors), you can enable verbose output to show the list of processed files by passing the `-v` or `--verbose` argument in the `args` section.
@@ -151,25 +175,10 @@ Use -header-filter=.* to display errors from all non-system headers. Use -system
151
175
152
176
```
153
177
154
-
## Troubleshooting
155
-
156
-
### Debugging `clang-format` hook
157
-
158
-
If you encounter issues with the clang-format hook (such as exit code 247 or other errors), you can enable verbose output to show the list of processed files by passing the `-v` or `--verbose` argument in the `args` section.
0 commit comments