Sign inSign up

daverona/pre-commit-cpp

By daverona

•Updated about 6 years ago

Image
0

10K+

daverona/pre-commit-cpp repository overview

⁠daverona/pre-commit/cpp

pipeline status

This is a set of C/C++ hooks for pre-commit framework⁠.

⁠Overview

C/C++ hooks provided are:

  • clang-format⁠: formatter of C/C++ code based on a style guide
  • cpplint⁠: linter (or style-error detector) for Google C++ Style Guide⁠
  • cppcheck⁠: static analyzer of C/C++ code
  • docker-clang-format: docker-version clang-format hook
  • docker-cpplint: docker-version cpplint hook
  • docker-clang-format: docker-version clang-format hook

⁠Hook Prerequisites

If you use Docker, don't need to install anything and skip this section.

⁠Hook Installation

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-format hook, clang-format hook is not required (and clang-format executable is not required to be installed).

⁠Hook Configuration

⁠clang-format

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.

⁠References

Tag summary

Content type

Image

Digest

Size

71.9 MB

Last updated

about 6 years ago

docker pull daverona/pre-commit-cpp