|
3 | 3 | - navigation |
4 | 4 | - toc |
5 | 5 | - feedback |
| 6 | +# The home page people see is built by docs/overrides/home.html, which does not |
| 7 | +# render the Markdown below. That Markdown is the page's copy for AI agents and |
| 8 | +# llms.txt (the llms_txt plugin publishes it as index.md). Keep the two in step. |
6 | 9 | template: home.html |
7 | 10 | title: C/C++ Linter with clang-format and clang-tidy |
8 | 11 | description: clang-format and clang-tidy for C and C++ pull requests, pre-commit hooks and CI, with the LLVM version you pin. |
9 | 12 | --- |
10 | 13 |
|
11 | | -<!-- The home page is built by docs/overrides/home.html. --> |
| 14 | +# cpp-linter |
| 15 | + |
| 16 | +cpp-linter runs clang-format and clang-tidy on the C and C++ files a pull request changes. It |
| 17 | +reports what it finds in the job log and as annotations on the pull request, and can post the |
| 18 | +fixes as review suggestions. It reads the repository's `.clang-format` and `.clang-tidy` files. |
| 19 | +Set the same LLVM version in each tool, and laptops and CI run the same major release. |
| 20 | + |
| 21 | +## Pick where the checks run |
| 22 | + |
| 23 | +| Where | Project | Docs | |
| 24 | +| --- | --- | --- | |
| 25 | +| On the pull request (GitHub Actions) | cpp-linter-action | <https://cpp-linter.github.io/cpp-linter-action/> | |
| 26 | +| Before each commit (pre-commit) | cpp-linter-hooks | <https://github.com/cpp-linter/cpp-linter-hooks> | |
| 27 | +| Locally or in other CI | cpp-linter, the Python command behind the action | <https://cpp-linter.github.io/cpp-linter/> | |
| 28 | +| Just the clang tools, by LLVM version | clang-tools (pip), npm, asdf, Docker, Homebrew | <https://cpp-linter.github.io/clang-tools-pip/> | |
| 29 | +| Static clang-format and clang-tidy binaries | clang-tools-static-binaries | <https://cpp-linter.github.io/clang-tools-static-binaries/> | |
| 30 | +| Version 2, a rewrite in Rust (release candidates) | cpp-linter-rs | <https://cpp-linter.github.io/cpp-linter-rs/> | |
| 31 | + |
| 32 | +The action and clang-tools cover LLVM 12 to 23. The clang-tidy pre-commit hook covers LLVM 13 to 23. |
| 33 | + |
| 34 | +## Start with one workflow file |
| 35 | + |
| 36 | +Save this as `.github/workflows/cpp-linter.yml` and open a pull request that changes C or C++ files: |
| 37 | + |
| 38 | +```yaml |
| 39 | +name: cpp-linter |
| 40 | +on: pull_request |
| 41 | + |
| 42 | +jobs: |
| 43 | + cpp-linter: |
| 44 | + runs-on: ubuntu-latest |
| 45 | + permissions: |
| 46 | + contents: read |
| 47 | + pull-requests: write |
| 48 | + steps: |
| 49 | + - uses: actions/checkout@v7 |
| 50 | + - uses: cpp-linter/cpp-linter-action@v2 |
| 51 | + env: |
| 52 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 53 | + with: |
| 54 | + style: file |
| 55 | + tidy-checks: '' |
| 56 | + format-review: true |
| 57 | +``` |
| 58 | +
|
| 59 | +On pull requests from forks the token is read-only, so findings show up as annotations only. |
| 60 | +
|
| 61 | +## More |
| 62 | +
|
| 63 | +- [Get started](getting-started.md): the action, the pre-commit hooks, the command and the clang tools. |
| 64 | +- [Other CI](other-ci.md): GitLab CI, Jenkins, Azure Pipelines and Bitbucket Pipelines. |
| 65 | +- [AI coding agents](ai-coding-agents.md): run the checks from Claude Code, Copilot coding agent and `AGENTS.md`. |
| 66 | +- [Why cpp-linter](why-cpp-linter.md): how it compares with other clang-format and clang-tidy actions and hooks. |
0 commit comments