This is a set of C/C++ hooks for pre-commit framework.
C/C++ hooks provided are:
If you use Docker, don't need to install anything and skip this section.
clang-format executable. Use
brew (on macOS) or apt-get (on Ubuntu) to install it. For Windows, please read
http://releases.llvm.org/download.html.cppcheck executable. Use brew
(on macOS) or apt-get (on Ubuntu) to install it. For Windows, please read
http://cppcheck.sourceforge.net/#download.To use C/C++ hooks, add the following code block to your .pre-commit-config.yaml:
- repo: https://gitlab.com/daverona/pre-commit/cpp
rev: 0.8.0 # use the most recent version
hooks:
# Hooks using native
- id: clang-format # formatter for C/C++ code based on a style guide
- id: cpplint # linter (or style-error checker) for Google C++ Style Guide
- id: cppcheck # static analyzer for C/C++ code
# Hooks using Docker
- id: docker-clang-format # clang-format in Docker container
- id: docker-cpplint # cpplint in Docker container
- id: docker-cppcheck # cppcheck in Docker container
You don't need to use non-docker version hook and its corresponding docker version at the same time. For instance, if you use
docker-clang-formathook,clang-formathook is not required (andclang-formatexecutable is not required to be installed).
clang-format hook uses Google style (as described in
Google C++ Style Guide)
by default. If you like to use a different style, say
LLVM Coding Standards,
please add args to the hook to override the default style:
- repo: https://gitlab.com/daverona/pre-commit/cpp
rev: 0.8.0 # use the most recent version
hooks:
- id: clang-format
args: ["-style=LLVM"] # use LLVM Coding Standards
Available styles are LLVM, Google, Chromium, Mozilla, and WebKit.
Content type
Image
Digest
Size
71.9 MB
Last updated
about 6 years ago
docker pull daverona/pre-commit-cpp