-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path.pre-commit-config.yaml
More file actions
303 lines (276 loc) · 9.85 KB
/
Copy path.pre-commit-config.yaml
File metadata and controls
303 lines (276 loc) · 9.85 KB
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
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
minimum_pre_commit_version: '3.5.0'
default_stages: [pre-commit]
default_language_version:
python: python3.12
node: system
fail_fast: false
repos:
# ============================================================================
# README AUTO-GENERATION
# ============================================================================
- repo: local
hooks:
- id: update-readme-usage
name: Auto-generate README usage section
language: python
entry: python scripts/update_readme_usage.py
pass_filenames: false
always_run: true
# ============================================================================
# BASIC FILE QUALITY CHECKS (baseline hygiene)
# ============================================================================
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v6.0.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-added-large-files
args: ["--maxkb=1000"]
- id: check-merge-conflict
- id: check-toml
- id: check-json
- id: mixed-line-ending
args: ["--fix=lf"]
- id: check-case-conflict
- id: check-docstring-first
- id: check-ast
- id: debug-statements
- id: name-tests-test
args: ["--pytest-test-first"]
exclude: ^(tests/(utils|conftest|framework/.*|garbage_data|scoring)\.py|diffctx/tests/fixtures/garbage/.*\.py)$
- id: fix-byte-order-marker
- id: detect-private-key
- repo: https://github.com/abravalheri/validate-pyproject
rev: "v0.25"
hooks:
- id: validate-pyproject
name: validate-pyproject (PEP 621 schema)
# ============================================================================
# PYPROJECT.TOML FORMATTING
# ============================================================================
- repo: https://github.com/tox-dev/pyproject-fmt
rev: "v2.18.1"
hooks:
- id: pyproject-fmt
name: pyproject-fmt (normalize pyproject.toml)
# ============================================================================
# GITHUB ACTIONS VALIDATION
# ============================================================================
- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.35.0
hooks:
- id: check-github-workflows
name: Validate GitHub workflows
args: ['--verbose']
- id: check-dependabot
name: Validate Dependabot config
- repo: https://github.com/rhysd/actionlint
rev: v1.7.8
hooks:
- id: actionlint
name: Lint GitHub Actions
# ============================================================================
# CODE FORMATTING
# ============================================================================
- repo: https://github.com/psf/black
rev: 26.1.0
hooks:
- id: black
language_version: python3
- repo: https://github.com/asottile/pyupgrade
rev: v3.21.1
hooks:
- id: pyupgrade
name: pyupgrade (auto-upgrade Python syntax)
args: ['--py310-plus']
files: ^src/.*\.py$
# ============================================================================
# STATIC TYPING
# ============================================================================
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.18.2
hooks:
- id: mypy
name: mypy (strict mode)
additional_dependencies:
- types-PyYAML
- PyYAML
- pathspec
files: ^src/
# ============================================================================
# LINTING (Ruff for speed + correctness)
# ============================================================================
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.14.0
hooks:
- id: ruff
name: ruff (correctness-focused checks)
args: ["--fix", "--unsafe-fixes"]
# ============================================================================
# SECURITY & VULNERABILITY DETECTION
# ============================================================================
- repo: https://github.com/Yelp/detect-secrets
rev: v1.5.0
hooks:
- id: detect-secrets
args: ["--baseline", ".secrets.baseline"]
- repo: https://github.com/gitleaks/gitleaks
rev: v8.29.0
hooks:
- id: gitleaks
name: Scan for secrets (gitleaks)
- repo: https://github.com/semgrep/pre-commit
rev: v1.149.0
hooks:
- id: semgrep
name: semgrep (AST-based security & policy)
args:
[
"--config=p/security-audit",
"--config=p/python",
"--error",
"--skip-unknown-extensions",
"--metrics=off",
]
files: ^src/
# ============================================================================
# COMPLEXITY ANALYSIS
# ============================================================================
- repo: https://github.com/yunojuno/pre-commit-xenon
rev: cc59b0431a5d072786b59430e9b342b2881064f6
hooks:
- id: xenon
name: xenon (cyclomatic complexity)
args:
- "--max-absolute=C"
- "--max-modules=B"
- "--max-average=A"
- "src/"
pass_filenames: false
# ============================================================================
# DEAD CODE DETECTION
# ============================================================================
- repo: https://github.com/jendrikseipp/vulture
rev: v2.14
hooks:
- id: vulture
name: vulture (dead code)
args: ["--min-confidence=80", "src/"]
files: ^src/
pass_filenames: false
# ============================================================================
# ARCHITECTURE ENFORCEMENT
# ============================================================================
- repo: local
hooks:
- id: lint-imports
name: import-linter (architecture contracts)
entry: lint-imports
language: system
pass_filenames: false
types: [python]
# ============================================================================
# CODE DUPLICATION DETECTION
# ============================================================================
- repo: https://github.com/PyCQA/pylint
rev: v4.0.1
hooks:
- id: pylint
name: pylint (duplicate code detection)
args:
[
"--disable=all",
"--enable=duplicate-code",
"--min-similarity-lines=6",
"--ignore-comments=yes",
"--ignore-docstrings=yes",
"--ignore-imports=yes",
]
files: ^src/
# ============================================================================
# YAML LINTING
# ============================================================================
- repo: https://github.com/adrienverge/yamllint
rev: v1.37.1
hooks:
- id: yamllint
args:
- "-d"
- >-
{extends: default, rules:
{line-length: {max: 120}, document-start: disable,
indentation: disable, comments: disable}}
exclude: ^tests/cases/diff/
# ============================================================================
# SHELL LINTING
# ============================================================================
- repo: https://github.com/scop/pre-commit-shfmt
rev: v3.12.0-2
hooks:
- id: shfmt
name: shfmt (shell script formatting)
args: [-w, -i, '2']
- repo: https://github.com/shellcheck-py/shellcheck-py
rev: v0.11.0.1
hooks:
- id: shellcheck
name: shellcheck (shell script linting)
args: [-x]
# ============================================================================
# MARKDOWN LINTING
# ============================================================================
- repo: https://github.com/igorshubovych/markdownlint-cli
rev: v0.45.0
hooks:
- id: markdownlint
name: Lint Markdown files
args: ['--fix']
files: \.(md|markdown)$
# ============================================================================
# RUST QUALITY (fmt, clippy, test, audit)
# ============================================================================
- repo: local
hooks:
- id: cargo-fmt
name: cargo fmt (Rust formatting)
language: system
entry: bash -c 'cd diffctx && cargo fmt -- --check'
pass_filenames: false
files: ^diffctx/.*\.rs$
types: [file]
- id: cargo-clippy
name: cargo clippy (Rust linting)
language: system
entry: bash -c 'cd diffctx && cargo clippy --release --lib 2>&1 | tail -5'
pass_filenames: false
files: ^diffctx/
types: [file]
- id: cargo-test
name: cargo test (Rust unit tests)
language: system
# Two-step: lib unit tests in dev profile (panic=unwind harness),
# yaml_cases integration test in release (harness=false, abort-safe).
entry: |
bash -c '
cd diffctx &&
cargo test --lib &&
DIFFCTX_YAML_CASES_LIMIT=20 cargo test --release --test yaml_cases'
pass_filenames: false
files: ^diffctx/.*\.rs$
types: [file]
- id: cargo-audit
name: cargo audit (dependency vulnerabilities)
language: system
entry: bash -c 'command -v cargo-audit >/dev/null 2>&1 && cd diffctx && cargo audit || true'
pass_filenames: false
files: ^diffctx/Cargo\.(toml|lock)$
types: [file]
# ============================================================================
# COMMIT MESSAGE QUALITY
# ============================================================================
- repo: https://github.com/commitizen-tools/commitizen
rev: v4.9.1
hooks:
- id: commitizen
stages: [commit-msg]