|
| 1 | +# To use: |
| 2 | +# |
| 3 | +# pre-commit run -a |
| 4 | +# |
| 5 | +# Or: |
| 6 | +# |
| 7 | +# pre-commit install # (runs every time you commit in git) |
| 8 | +# |
| 9 | +# To update this file: |
| 10 | +# |
| 11 | +# pre-commit autoupdate |
| 12 | +# |
| 13 | +# See https://github.com/pre-commit/pre-commit |
| 14 | + |
| 15 | +repos: |
| 16 | + # Standard hooks |
| 17 | + - repo: https://github.com/pre-commit/pre-commit-hooks |
| 18 | + rev: v4.1.0 |
| 19 | + hooks: |
| 20 | + - id: check-added-large-files |
| 21 | + - id: check-ast |
| 22 | + - id: check-case-conflict |
| 23 | + - id: check-docstring-first |
| 24 | + - id: check-merge-conflict |
| 25 | + - id: check-symlinks |
| 26 | + - id: check-xml |
| 27 | + - id: check-yaml |
| 28 | + - id: debug-statements |
| 29 | + - id: end-of-file-fixer |
| 30 | + - id: mixed-line-ending |
| 31 | + - id: trailing-whitespace |
| 32 | + exclude_types: [rst] |
| 33 | + - id: fix-byte-order-marker |
| 34 | + |
| 35 | + |
| 36 | + # Python hooks |
| 37 | + - repo: https://github.com/asottile/pyupgrade |
| 38 | + rev: v2.31.1 |
| 39 | + hooks: |
| 40 | + - id: pyupgrade |
| 41 | + args: [--py36-plus] |
| 42 | + |
| 43 | + # # PEP 257 |
| 44 | + - repo: local |
| 45 | + hooks: |
| 46 | + - id: ament_pep257 |
| 47 | + name: ament_pep257 |
| 48 | + description: Format files with pep257. |
| 49 | + entry: ament_pep257 |
| 50 | + language: system |
| 51 | + args: ["--ignore=D100,D101,D102,D103,D104,D105,D106,D107,D203,D212,D404"] |
| 52 | + |
| 53 | + - repo: https://github.com/pycqa/flake8 |
| 54 | + rev: 4.0.1 |
| 55 | + hooks: |
| 56 | + - id: flake8 |
| 57 | + args: ["--extend-ignore=E501"] |
| 58 | + |
| 59 | + # CPP hooks |
| 60 | + - repo: local |
| 61 | + hooks: |
| 62 | + - id: ament_uncrustify |
| 63 | + name: ament_uncrustify |
| 64 | + description: Format files with uncrustify. |
| 65 | + entry: ament_uncrustify |
| 66 | + language: system |
| 67 | + files: \.(c|cc|cxx|cpp|frag|glsl|h|hpp|hxx|ih|ispc|ipp|java|js|m|proto|vert)$ |
| 68 | + args: ["--reformat"] |
| 69 | + |
| 70 | + - repo: local |
| 71 | + hooks: |
| 72 | + - id: ament_cppcheck |
| 73 | + name: ament_cppcheck |
| 74 | + description: Static code analysis of C/C++ files. |
| 75 | + stages: [commit] |
| 76 | + entry: ament_cppcheck |
| 77 | + language: system |
| 78 | + files: \.(h\+\+|h|hh|hxx|hpp|cuh|c|cc|cpp|cu|c\+\+|cxx|tpp|txx)$ |
| 79 | + |
| 80 | + # Maybe use https://github.com/cpplint/cpplint instead |
| 81 | + - repo: local |
| 82 | + hooks: |
| 83 | + - id: ament_cpplint |
| 84 | + name: ament_cpplint |
| 85 | + description: Static code analysis of C/C++ files. |
| 86 | + stages: [commit] |
| 87 | + entry: ament_cpplint |
| 88 | + language: system |
| 89 | + files: \.(h\+\+|h|hh|hxx|hpp|cuh|c|cc|cpp|cu|c\+\+|cxx|tpp|txx)$ |
| 90 | + args: ["--linelength=100", "--filter=-whitespace/newline"] |
| 91 | + |
| 92 | + # Cmake hooks |
| 93 | + - repo: local |
| 94 | + hooks: |
| 95 | + - id: ament_lint_cmake |
| 96 | + name: ament_lint_cmake |
| 97 | + description: Check format of CMakeLists.txt files. |
| 98 | + stages: [commit] |
| 99 | + entry: ament_lint_cmake |
| 100 | + language: system |
| 101 | + files: CMakeLists\.txt$ |
| 102 | + |
| 103 | + # Copyright |
| 104 | + - repo: local |
| 105 | + hooks: |
| 106 | + - id: ament_copyright |
| 107 | + name: ament_copyright |
| 108 | + description: Check if copyright notice is available in all files. |
| 109 | + stages: [commit] |
| 110 | + entry: ament_copyright |
| 111 | + language: system |
| 112 | + |
| 113 | + # Docs - RestructuredText hooks |
| 114 | + - repo: https://github.com/PyCQA/doc8 |
| 115 | + rev: 0.10.1 |
| 116 | + hooks: |
| 117 | + - id: doc8 |
| 118 | + args: ['--max-line-length=100', '--ignore=D001'] |
| 119 | + exclude: CHANGELOG\.rst$ |
| 120 | + |
| 121 | + - repo: https://github.com/pre-commit/pygrep-hooks |
| 122 | + rev: v1.9.0 |
| 123 | + hooks: |
| 124 | + - id: rst-backticks |
| 125 | + exclude: CHANGELOG\.rst$ |
| 126 | + - id: rst-directive-colons |
| 127 | + - id: rst-inline-touching-normal |
| 128 | + |
| 129 | + # Spellcheck in comments and docs |
| 130 | + # skipping of *.svg files is not working... |
| 131 | + - repo: https://github.com/codespell-project/codespell |
| 132 | + rev: v2.1.0 |
| 133 | + hooks: |
| 134 | + - id: codespell |
| 135 | + args: ['--write-changes'] |
| 136 | + exclude: CHANGELOG\.rst|\.(svg|pyc)$ |
0 commit comments