pre-commit-cpp is a pre-commit component which provides cpplint and cppcheck hooks.
pre-commit-cpp requires the following to run:
- create .pre-commit-config.yaml in you git project with the following included:
--- repos: - repo: https://github.com/danielhoherd/pre-commit-cpp rev: master hooks: - id: cppcheck - id: cpplint
pre-commit install
pre-commit run --all-files
To contribute to pre-commit-cpp, fork, implement and submit a PR.
pre-commit-cpp is licensed under the MIT license.
It was only after making these hooks that I realized they could just as easily be local hooks. I am leaving this repo up, but in case you want to not require an online hook, you can use the following .pre-commit-config.yaml
file to get basically the same behavior provided by this repo:
---
repos:
- repo: local
hooks:
- id: cpplint
name: cpplint
language: system
entry: cpplint --count=detailed
files: '\.(h|cpp)$'
- id: cppcheck
name: cppcheck
language: system
entry: cppcheck --error-exitcode=1
files: '\.(h|cpp)$'