Skip to content

Commit

Permalink
Update README.md (#40)
Browse files Browse the repository at this point in the history
* Update README.md

* Bump version to v0.3.1
  • Loading branch information
shenxianpeng authored Mar 7, 2024
1 parent 730bc99 commit 2f028bb
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 17 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2022 Peter Shen
Copyright (c) 2022 Xianpeng Shen

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
30 changes: 14 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,50 +8,50 @@
<!-- [![PyPI - Downloads](https://img.shields.io/pypi/dw/cpp-linter-hooks)](https://pypi.org/project/cpp-linter-hooks/) -->


Using `clang-format` and `clang-tidy` hooks with [pre-commit](https://pre-commit.com/) to lint your C/C++ code.
`cpp-linter-hooks` integrates `clang-format` and `clang-tidy` hooks with [pre-commit](https://pre-commit.com/) to lint your C/C++ code efficiently.

> [!NOTE]
> Automatically downloads a specific version of `clang-format` or `clang-tidy` [binaries](https://github.com/cpp-linter/clang-tools-static-binaries) and installs it on the system.
> This hook automatically downloads a specific version of `clang-format` or `clang-tidy` [binaries](https://github.com/cpp-linter/clang-tools-static-binaries) and installs it on the system.
## Usage

Add this to your `.pre-commit-config.yaml`
Add the following configuration to your `.pre-commit-config.yaml`:

```yaml
repos:
- repo: https://github.com/cpp-linter/cpp-linter-hooks
rev: v0.3.0 # Use the ref you want to point at
rev: v0.3.1 # Use the ref you want to point at
hooks:
- id: clang-format
args: [--style=Google] # Other coding style: LLVM, GNU, Chromium, Microsoft, Mozilla, WebKit.
- id: clang-tidy
args: [--checks='boost-*,bugprone-*,performance-*,readability-*,portability-*,modernize-*,clang-analyzer-*,cppcoreguidelines-*']
```
The example of using custom config: `.clang-format` and `.clang-tidy`
To use custom configurations like `.clang-format` and `.clang-tidy`:

```yaml
repos:
- repo: https://github.com/cpp-linter/cpp-linter-hooks
rev: v0.3.0
rev: v0.3.1
hooks:
- id: clang-format
args: [--style=file] # to load .clang-format
- id: clang-tidy
args: [--checks=.clang-tidy] # path/to/.clang-tidy
```

The example of using any version of [clang-tools](https://github.com/cpp-linter/clang-tools-pip?tab=readme-ov-file#supported-versions).
To use specific versions of [clang-tools](https://github.com/cpp-linter/clang-tools-pip?tab=readme-ov-file#supported-versions):

```yaml
repos:
- repo: https://github.com/cpp-linter/cpp-linter-hooks
rev: v0.3.0
rev: v0.3.1
hooks:
- id: clang-format
args: [--style=file, --version=16]
args: [--style=file, --version=16] # Specifies version
- id: clang-tidy
args: [--checks=.clang-tidy, --version=16]
args: [--checks=.clang-tidy, --version=16] # Specifies version
```

## Output
Expand All @@ -64,7 +64,7 @@ clang-format.............................................................Failed
- files were modified by this hook
```

Here is the diff between the modified file.
The diff between the modified file is as follows:

```diff
--- a/testing/main.c
Expand All @@ -80,9 +80,7 @@ Here is the diff between the modified file.
+}
```

Pass `--dry-run` to the `args` of `clang-format`(can also pass other arg which clang-format supports)

Then it will just print instead of changing the format. E.g:
Use `--dry-run` in `args` of `clang-format` to print instead of changing the format, e.g.:

```bash
clang-format.............................................................Failed
Expand Down Expand Up @@ -128,8 +126,8 @@ Use -header-filter=.* to display errors from all non-system headers. Use -system

## Contributing

Any contribution is very welcome, including submitting issues, PRs, etc.
Contributions are very welcome, including submitting issues, PRs, etc.

## License

This project is licensed under the terms of the MIT license.
[MIT](LICENSE)

0 comments on commit 2f028bb

Please sign in to comment.