Skip to content

Commit 2842fbf

Browse files
committed
update README.md
1 parent fcbf65a commit 2842fbf

File tree

1 file changed

+45
-43
lines changed

1 file changed

+45
-43
lines changed

README.md

Lines changed: 45 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,14 @@ A powerful [pre-commit](https://pre-commit.com/) hook that automatically formats
1111
## Table of Contents
1212

1313
- [Quick Start](#quick-start)
14-
- [Custom Configuration Files](#custom-configuration-files)
15-
- [Custom Clang Tool Version](#custom-clang-tool-version)
16-
- [Troubleshooting](#troubleshooting)
17-
- [Debugging `clang-format` hook](#debugging-clang-format-hook)
14+
- [Custom Configuration Files](#custom-configuration-files)
15+
- [Custom Clang Tool Version](#custom-clang-tool-version)
1816
- [Output](#output)
1917
- [clang-format Output](#clang-format-output)
2018
- [clang-tidy Output](#clang-tidy-output)
19+
- [Troubleshooting](#troubleshooting)
20+
- [Performance Optimization](#performance-optimization)
21+
- [Verbose Output](#verbose-output)
2122
- [Contributing](#contributing)
2223
- [License](#license)
2324

@@ -66,45 +67,6 @@ repos:
6667
args: [--checks=.clang-tidy, --version=18] # Specifies version
6768
```
6869

69-
### Troubleshooting
70-
71-
> [!IMPORTANT]
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:
73-
74-
75-
```yaml
76-
- repo: https://github.com/cpp-linter/cpp-linter-hooks
77-
rev: v0.8.1
78-
hooks:
79-
- id: clang-format
80-
args: [--style=file, --version=18]
81-
files: ^(src|include)/.*\.(cpp|cc|cxx|h|hpp)$ # Limits to specific dirs and file types
82-
- id: clang-tidy
83-
args: [--checks=.clang-tidy, --version=18]
84-
files: ^(src|include)/.*\.(cpp|cc|cxx|h|hpp)$
85-
```
86-
87-
Alternatively, if you want to run the hooks manually on only the changed files, you can use the following command:
88-
89-
```bash
90-
pre-commit run --files $(git diff --name-only)
91-
```
92-
93-
This approach ensures that only modified files are checked, further speeding up the linting process during development.
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.
98-
99-
```yaml
100-
repos:
101-
- repo: https://github.com/cpp-linter/cpp-linter-hooks
102-
rev: v0.8.1
103-
hooks:
104-
- id: clang-format
105-
args: [--style=file, --version=18, --verbose] # Add -v or --verbose for detailed output
106-
```
107-
10870
## Output
10971

11072
### clang-format Output
@@ -175,6 +137,46 @@ Use -header-filter=.* to display errors from all non-system headers. Use -system
175137
176138
```
177139

140+
## Troubleshooting
141+
142+
### Performance Optimization
143+
144+
> [!WARNING]
145+
> 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:
146+
147+
```yaml
148+
- repo: https://github.com/cpp-linter/cpp-linter-hooks
149+
rev: v0.8.1
150+
hooks:
151+
- id: clang-format
152+
args: [--style=file, --version=18]
153+
files: ^(src|include)/.*\.(cpp|cc|cxx|h|hpp)$ # Limits to specific dirs and file types
154+
- id: clang-tidy
155+
args: [--checks=.clang-tidy, --version=18]
156+
files: ^(src|include)/.*\.(cpp|cc|cxx|h|hpp)$
157+
```
158+
159+
Alternatively, if you want to run the hooks manually on only the changed files, you can use the following command:
160+
161+
```bash
162+
pre-commit run --files $(git diff --name-only)
163+
```
164+
165+
This approach ensures that only modified files are checked, further speeding up the linting process during development.
166+
167+
### Verbose Output
168+
169+
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.
170+
171+
```yaml
172+
repos:
173+
- repo: https://github.com/cpp-linter/cpp-linter-hooks
174+
rev: v0.8.1
175+
hooks:
176+
- id: clang-format
177+
args: [--style=file, --version=18, --verbose] # Add -v or --verbose for detailed output
178+
```
179+
178180
## Contributing
179181

180182
We welcome contributions! Whether it's fixing issues, suggesting improvements, or submitting pull requests, your support is greatly appreciated.

0 commit comments

Comments
 (0)