forked from mavlink/qgroundcontrol
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.pre-commit-config.yaml
More file actions
264 lines (235 loc) · 8.67 KB
/
Copy path.pre-commit-config.yaml
File metadata and controls
264 lines (235 loc) · 8.67 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
# QGroundControl Pre-Commit Configuration
# Install: pre-commit install
# Run: pre-commit run --all-files
# Update: pre-commit autoupdate
repos:
# Basic file checks
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v6.0.0
hooks:
- id: check-yaml
args: [--allow-multiple-documents, --unsafe]
- id: check-json
- id: check-toml
- id: pretty-format-json
args: ['--indent=2', '--no-ensure-ascii', '--no-sort-keys']
files: ^(\.github/|tools/).*\.json$
- id: check-xml
exclude: ^test/
- id: check-merge-conflict
- id: check-added-large-files
args: ['--maxkb=2000']
exclude: ^(resources/icons/|resources/audio/)
- id: check-case-conflict
- id: check-shebang-scripts-are-executable
- id: check-executables-have-shebangs
- id: trailing-whitespace
args: ['--markdown-linebreak-ext=md']
exclude: ^translations/
- id: end-of-file-fixer
exclude: ^(translations/.*\.ts|.*\.(png|jpg|jpeg|gif|svg|ico|bin|dat))$
- id: mixed-line-ending
args: ['--fix=lf']
exclude: \.(bat|ps1)$
# Secret detection
- repo: https://github.com/trufflesecurity/trufflehog
rev: v3.95.7
hooks:
- id: trufflehog
args: ['--only-verified', '--exclude-paths=tools/configs/trufflehog-exclude.txt']
# C++ formatting (check-only, use 'clang-format -i' to fix)
# Note: Install matching clang-format version locally to avoid formatting differences
- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v22.1.5
hooks:
- id: clang-format
args: ['--dry-run', '--Werror']
types_or: [c++, c]
exclude: ^(build/|libs/)
# Python formatting (report-only)
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.15.20
hooks:
- id: ruff
- id: ruff-format
args: [--check]
# Python type checking
- repo: https://github.com/RobertCraigie/pyright-python
rev: v1.1.411
hooks:
- id: pyright
files: ^(tools|test|\.github/scripts)/.*\.py$
- repo: local
hooks:
- id: import-linter
name: import-linter (tools layering)
entry: bash -c 'cd tools && PYTHONPATH=. lint-imports --config pyproject.toml'
language: python
additional_dependencies: ['import-linter>=2.0']
files: ^tools/.*\.py$
pass_filenames: false
# uv lockfile sync (keeps tools/uv.lock current with tools/pyproject.toml)
- repo: https://github.com/astral-sh/uv-pre-commit
rev: 0.11.26
hooks:
- id: uv-lock
files: ^tools/(pyproject\.toml|uv\.lock)$
args: ['--project', 'tools']
# Shell scripts
- repo: https://github.com/shellcheck-py/shellcheck-py
rev: v0.11.0.1
hooks:
- id: shellcheck
args: ['-e', 'SC1091'] # Don't warn about not following sourced files
# Dockerfile linting
- repo: https://github.com/AleksaC/hadolint-py
rev: v2.14.0
hooks:
- id: hadolint
files: ^deploy/docker/Dockerfile-.*$
types: [file]
# GitHub Actions linting
- repo: https://github.com/rhysd/actionlint
rev: v1.7.12
hooks:
- id: actionlint
# GitHub Actions security scanning
- repo: local
hooks:
- id: zizmor
name: zizmor (GitHub Actions security)
entry: zizmor
language: python
additional_dependencies: ['zizmor>=1.25.2']
files: ^\.github/(workflows|actions)/.*\.ya?ml$
types: [yaml]
# YAML validation
- repo: https://github.com/adrienverge/yamllint
rev: v1.38.0
hooks:
- id: yamllint
# JSON Schema validation for build-config.json
- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.37.4
hooks:
- id: check-jsonschema
name: Validate .github/build-config.json
files: ^\.github/build-config\.json$
args: ['--schemafile', '.github/build-config.schema.json']
# Renovate config validation (schema-checks the active renovate.json)
- repo: https://github.com/renovatebot/pre-commit-hooks
rev: 43.249.6
hooks:
- id: renovate-config-validator
files: ^\.github/renovate\.json$
# Markdown linting (report-only, doesn't auto-fix)
- repo: https://github.com/igorshubovych/markdownlint-cli
rev: v0.49.0
hooks:
- id: markdownlint
exclude: ^(translations/|tools/skills/|docs/(zh|ko|tr|ru|ja|de|es|fa|fr|he|uk)/|CHANGELOG\.md)
# Prose linting (documentation quality)
# vale-sync downloads the Packages declared in .vale.ini into the gitignored
# .github/styles/ before vale runs; without it vale has no styles and no-ops.
- repo: local
hooks:
- id: vale-sync
name: vale sync (download styles)
language: golang
additional_dependencies:
- 'github.com/errata-ai/vale/v3@v3.14.2'
entry: vale sync
files: ^(docs/|\.vale\.ini$)
pass_filenames: false
- repo: https://github.com/errata-ai/vale
rev: v3.15.1
hooks:
- id: vale
files: ^docs/
args: ['--no-exit'] # Don't fail on warnings, just report
# Spell checking (report-only, doesn't auto-fix)
- repo: https://github.com/crate-ci/typos
rev: v1.48.0
hooks:
- id: typos
args: [] # Empty args disables auto-fix mode
files: \.(md|markdown|txt|rst)$|^docs/
- repo: local
hooks:
- id: qmllint
name: Lint QML files
entry: python3 ./tools/analyze.py --tool qmllint
language: system
files: \.qml$
exclude: ^build/
pass_filenames: false
- id: clang-tidy
name: Clang-Tidy static analysis
entry: python3 ./tools/analyze.py --tool clang-tidy
language: system
types_or: [c++, c]
exclude: ^(build/|libs/|test/)
pass_filenames: false
- id: cmake-format
name: cmake-format (check)
entry: cmake-format --check
language: python
additional_dependencies: ['cmakelang==0.6.13']
files: (CMakeLists\.txt|\.cmake)$
exclude: ^(build/|libs/)
- id: cmake-lint
name: cmake-lint
entry: cmake-lint
language: python
additional_dependencies: ['cmakelang==0.6.13']
files: (CMakeLists\.txt|\.cmake)$
exclude: ^(build/|libs/)
- id: clazy
name: Qt static analysis (clazy)
entry: python3 ./tools/analyze.py --tool clazy
language: system
types: [c++]
exclude: ^(build/|libs/|test/)
pass_filenames: false
- id: check-no-qassert
name: Check for Q_ASSERT in production code
entry: bash -c 'if grep -nH "Q_ASSERT" "$@" 2>/dev/null; then echo "::error::Q_ASSERT found in production code. Use defensive checks with early returns instead." >&2; exit 1; fi' --
language: system
types: [c++]
exclude: ^test/
pass_filenames: true
- id: check-categorized-logging
name: Check for category function passed to uncategorized logging macro
entry: bash -c 'if grep -EnH "(^|[^A-Za-z0-9_])q(Debug|Info|Warning|Critical)\([[:space:]]*[A-Za-z_]+Log[[:space:]]*\)" "$@" 2>/dev/null; then echo "::error::Category function passed to qDebug/qInfo/qWarning/qCritical. Use the qCDebug/qCInfo/qCWarning/qCCritical macros instead." >&2; exit 1; fi' --
language: system
types: [c++]
pass_filenames: true
- id: check-no-qtest-ignore-message
name: Check for QTest::ignoreMessage in test code
entry: bash -c 'if grep -nH "QTest::ignoreMessage" "$@" 2>/dev/null; then echo "::error::QTest::ignoreMessage found. Use expectLogMessage+verifyExpectedLogMessage or ignoreLogMessage instead." >&2; exit 1; fi' --
language: system
types: [c++]
files: ^test/
pass_filenames: true
- id: check-no-fixed-qwait
name: Check for fixed-delay QTest::qWait in test code
entry: bash -c 'if grep -EnH "qWait\([1-9][0-9]*\)" "$@" 2>/dev/null; then echo "::error::QTest::qWait(<non-zero>) found. Use QTRY_VERIFY_WITH_TIMEOUT, QTRY_COMPARE_WITH_TIMEOUT, or QSignalSpy::wait with a TestTimeout::* constant instead." >&2; exit 1; fi' --
language: system
types: [c++]
files: ^test/
pass_filenames: true
- id: vehicle-null-check
name: Check vehicle null safety
entry: python3 tools/analyzers/vehicle_null_check.py
language: system
types: [c++]
exclude: ^(build/|libs/|test/)
pass_filenames: true
- id: qt-translate-noop-check
name: Check QT_TRANSLATE_NOOP misuse
entry: python3 tools/analyzers/qt_translate_noop_check.py
language: system
types: [c++]
exclude: ^(build/|libs/|test/)
pass_filenames: true
exclude: ^build/