-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy path.pre-commit-config.yaml
272 lines (247 loc) · 8.35 KB
/
.pre-commit-config.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
# This file configures https://pre-commit.com/
# Based on pre-commit hooks in
# https://github.com/pre-commit/pre-commit-hooks
# https://github.com/jumanjihouse/pre-commit-hooks
# to use specific hooks and options.
fail_fast: false
repos:
#
# Common
#
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: "v4.4.0"
hooks:
- id: check-case-conflict
- id: trailing-whitespace
exclude: \.output
- id: end-of-file-fixer
exclude: \.(cp?p?$|output)
- id: check-added-large-files
exclude: doc/html/static/background.mp4
- id: check-executables-have-shebangs
- id: check-shebang-scripts-are-executable
- id: check-yaml
- id: check-toml
#
# Git.
#
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: "v4.4.0"
hooks:
- id: check-merge-conflict
# - id: no-commit-to-branch
- repo: https://github.com/jorisroovers/gitlint
rev: "v0.19.1"
hooks:
- id: gitlint
#
# C++
#
- repo: https://github.com/pocc/pre-commit-hooks
rev: "v1.3.5"
hooks:
- id: clang-format
args: ["--style=file", "-i"]
additional_dependencies:
[clang-format==15.0.7]
# - id: oclint
# - id: uncrustify
# DO NOT RUN: see comment below (in the local hook description).
#- id: clang-tidy
# name: clang-tidy
# args: ["--config-file=knp/.clang-tidy", "-extra-arg-before=-xc++", "-extra-arg=-std=c++17", "-p=build"]
- id: cppcheck
args: ["-x", "c++", "--inline-suppr", "--template=gcc", "--suppress-xml=knp/.cppcheck-suppress.xml"] # --cppcheck-build-dir=build]
# - id: clang-tidy
# args: ["--config-file=knp/.clang-tidy", "-extra-arg-before=-xc++", "-extra-arg=-std=c++17", "-p=build"]
# additional_dependencies:
# [clang-tidy==18.1.1]
- id: cpplint
args: ["--exclude=tools/python-bindings-gen/py-gen", "--root", "knp"]
additional_dependencies:
[cpplint==1.6.1]
# - id: include-what-you-use
- repo: local
hooks:
# Tidy is not integrated in CMake calls.
# - Bug: cstddef:50:10: error: 'stddef.h' file not found [clang-diagnostic-error].
# - Don't necessary to run tidy on the every build.
# - With a cache tidy is faster.
# - I don't know where is the real build directory.
# - Hook implementation with a cache is buggy now.
# - id: clang-tidy
# name: clang-tidy
# args: ["--config-file=knp/.clang-tidy", "-extra-arg-before=-xc++", "-extra-arg=-std=c++17", "-p=build"]
# entry: tools/hooks/clang_tidy.py
# description: Find warnings/errors in C, C++, and Objective-C code
# additional_dependencies:
# [clang-tidy==18.1.1]
# types_or: [c, c++, g#, objective-c, cuda]
# language: python
# - id: oclint
# name: oclint
# entry: tools/hooks/oclint.py
# description: Find warnings/errors in C, C++, and Objective-C code
# types_or: [c, c++, c#, objective-c]
# language: python
# - id: uncrustify
# name: uncrustify
# entry: tools/hooks/uncrustify.py
# description: Formats C, C++, Objective-C, Java, D, and Vala code
# # D, vala currently aren't valid file types. See https://github.com/pre-commit/identify/issues/258
# types_or: [c, c++, c#, objective-c, java]
# language: python
- id: cloc
name: cloc
entry: tools/hooks/cloc.py
description: Code lines counter
types_or: [c, c++, c#, objective-c, cuda, python, bash]
language: python
- id: cccc
name: cccc
entry: tools/hooks/cccc.py
args: ["--outdir=build/cccc", "--limits_file=knp/.cccc.json"]
description: Code counter for C and C++
types_or: [c, c++, c#, objective-c, cuda]
language: python
#
# CMake
#
- repo: https://github.com/cheshirekow/cmake-format-precommit
rev: "v0.6.13"
hooks:
- id: cmake-format
args: ["--config", "knp/.cmake-format.yaml"]
- id: cmake-lint
args: ["--config-files", "knp/.cmake-format.yaml"]
#
# Python
#
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: "v4.4.0"
hooks:
- id: debug-statements
- id: check-docstring-first
- id: requirements-txt-fixer
- repo: https://github.com/PyCQA/autoflake
rev: v2.2.0
hooks:
- id: autoflake
exclude: &fixtures tests(/\w*)*/functional/|tests/input|doc/data/messages|tests(/\w*)*data/
args:
- --in-place
- --remove-all-unused-imports
- --expand-star-imports
- --remove-duplicate-keys
- --remove-unused-variables
- repo: https://github.com/pycqa/pylint
rev: "v3.0.0a7" # pylint-2.14.5
hooks:
- id: pylint
args: ["-rn", "-sn", "--rcfile=knp/python-framework/packaging/common/.pylintrc", "--fail-on=I", "--load-plugins=pylint.extensions.docparams"]
exclude: tests(/\w*)*/functional/|tests/input|tests(/\w*)*data/|doc/
- id: pylint
alias: pylint-with-spelling
args: ["-rn", "-sn", "--rcfile=knp/python-framework/packaging/common/.pylintrc", "--fail-on=I", "--spelling-dict=en,ru"]
exclude: tests(/\w*)*/functional/|tests/input|tests(/\w*)*data/|doc/
stages: [manual]
- repo: https://github.com/PyCQA/flake8
rev: 6.1.0
hooks:
- id: flake8
args: ["--config", "knp/.flake8"]
additional_dependencies:
[flake8-bugbear==22.12.6, flake8-typing-imports==1.14.0]
exclude: ".*fixtures"
# Bad: removes blank string after shebang.
# - repo: https://github.com/asottile/reorder_python_imports
# rev: bc7b5b2f0fde191c9d0121588ef9bbb79f8e5e21
# hooks:
# - id: reorder-python-imports
# language_version: python3
- repo: https://github.com/pre-commit/pre-commit
rev: v3.6.2
hooks:
- id: validate_manifest
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.8.0
hooks:
- id: mypy
args: ["--config-file", "knp/.mypy.ini", "--install-types", "--explicit-package-bases", "--check-untyped-defs", "--scripts-are-modules", "--strict"]
additional_dependencies:
[
"isort>=5",
"platformdirs==2.2.0",
"py==1.11",
"tokenize-rt==3.2.0",
"tomlkit>=0.10.1",
"types-pkg_resources==0.1.3",
"types-all",
"types-attrs",
"types-requests",
"types-dataclasses>=0.1.3",
"types-PyYAML",
"types-typed-ast>=1.4.1"
]
exclude: tests(/\w*)*/functional/|tests/input|tests(/.*)+/conftest.py|doc/data/messages|tests(/\w*)*data|python/
- repo: https://github.com/asottile/pyupgrade
rev: v3.10.1
hooks:
- id: pyupgrade
- repo: https://github.com/ambv/black
rev: "23.7.0"
hooks:
- id: black
args: ["-l", "120", "--skip-string-normalization"]
- repo: https://github.com/DanielNoord/pydocstringformatter
rev: v0.7.3
hooks:
- id: pydocstringformatter
exclude: *fixtures
args: ["--max-summary-lines=2", "--linewrap-full-docstring"]
- repo: https://github.com/PyCQA/bandit
rev: 1.7.5
hooks:
- id: bandit
args: ["-r", "-lll"]
exclude: ".*fixtures"
# Conflicts with Black.
# - repo: https://github.com/pycqa/isort
# rev: 5.12.0
# hooks:
# - id: isort
# args: ["--line-length", "120"]
# - id: tests
# name: tests
# entry: bash -c "pip install . && pytest -v -xxx"
# description: Tests expected output of all scripts
# language: system
# types: [python]
# TODO: Enable this on the knp/pyframework
# - repo: https://github.com/regebro/pyroma
# rev: "4.1"
# hooks:
# - id: pyroma
# # Must be specified because of the default value in pyroma
# always_run: false
# args: ["knp"]
# files: |
# (?x)^(
# README.md|
# pyproject.toml|
# pylint/__init__.py|
# pylint/__pkginfo__.py|
# setup.cfg
# )$
#
# Markdown
#
# Written on Ruby, but we don't want to install gem.
# - repo: https://github.com/markdownlint/markdownlint
# rev: "v0.12.0"
# hooks:
# - id: markdownlint
- repo: https://github.com/executablebooks/mdformat
rev: "0.7.16"
hooks:
- id: mdformat