Skip to content

Update readme about how to improve performance #65

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
rev: v5.0.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
Expand All @@ -10,11 +10,11 @@ repos:
- id: check-toml
- id: requirements-txt-fixer
- repo: https://github.com/asottile/pyupgrade
rev: v3.15.0
rev: v3.20.0
hooks:
- id: pyupgrade
- repo: https://github.com/pycqa/flake8
rev: '7.0.0'
rev: '7.2.0'
hooks:
- id: flake8
args: [--max-line-length=120]
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,30 @@ repos:
args: [--checks=.clang-tidy, --version=16] # Specifies version
```

> [!IMPORTANT]
> 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:


```yaml
- repo: https://github.com/cpp-linter/cpp-linter-hooks
rev: v0.6.1
hooks:
- id: clang-format
args: [--style=file, --version=16]
files: ^(src|include)/.*\.(cpp|cc|cxx|h|hpp)$ # limit the scope
- id: clang-tidy
args: [--checks=.clang-tidy, --version=16]
files: ^(src|include)/.*\.(cpp|cc|cxx|h|hpp)$
```

Alternatively, if you want to run the hooks manually on only the changed files, you can use the following command:

```bash
pre-commit run --files $(git diff --name-only)
```

This approach ensures that only modified files are checked, further speeding up the linting process during development.

## Output

### clang-format Example
Expand Down
Loading