Skip to content

Commit b41aca1

Browse files
committed
chore(tools): rename run-static-checks to run-linter-checks, add run-tox-tests
- Rename `tools/run-static-checks` -> `tools/run-linter-checks` so the tools/run-* naming is consistent with run-unit-tests and run-container-tests, and the name describes what the tool does (linting + security + dead-code) rather than the generic "static analysis". - Drop pylint from the default run. Its metric-based checks (R0801 duplicate lines, R09xx complexity) produce thousands of false positives on a repo of look-alike check plugins, and silencing them with a disable list would go against the house rule of running pylint without `--disable`. Pylint stays available for targeted single-file audits. - Print a clear `<analyzer>: all checks passed` / `issues found` summary line after each analyzer so bandit and vulture no longer exit silently on a clean run. - Add `tools/run-tox-tests` as a thin wrapper around `tox`. Same naming convention as the other run-* tools, and forwards all arguments to tox. Use `tools/run-unit-tests` for the currently activated venv, `tools/run-tox-tests` for the multi-Python matrix (py39 ... py314).
1 parent d60210d commit b41aca1

File tree

2 files changed

+76
-8
lines changed

2 files changed

+76
-8
lines changed
Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,27 @@
66
# https://www.linuxfabrik.ch/
77
# License: The Unlicense, see LICENSE file.
88

9-
"""Run static analysis (ruff, pylint, bandit, vulture) over the whole repo.
9+
"""Run lint and security checks (ruff, bandit, vulture) over the whole repo.
1010
1111
Pre-commit hooks only run on staged files. This script sweeps every plugin
1212
script, every tool, and every file under lib/ so that long-standing issues
1313
cannot hide simply because nobody has touched the file in a while.
1414
15+
pylint is intentionally NOT invoked here. Its metric-based checks
16+
(R0801 duplicate lines, R09xx complexity, etc.) produce thousands of
17+
false positives across a collection of check plugins that all share
18+
the same boilerplate, and suppressing the noise with a disable list
19+
would go against the house rule of running pylint without `--disable`.
20+
Run pylint by hand when you want to audit a single plugin.
21+
1522
Plugin scripts use a shebang instead of a `.py` extension, so the script
1623
discovers them by `#!/usr/bin/env python` header and passes them explicitly
1724
to each analyzer.
1825
1926
Usage:
20-
tools/run-static-checks # run all analyzers
21-
tools/run-static-checks --only=ruff # run only ruff
22-
tools/run-static-checks --only=ruff,bandit
27+
tools/run-linter-checks # run all analyzers
28+
tools/run-linter-checks --only=ruff # run only ruff
29+
tools/run-linter-checks --only=ruff,bandit
2330
"""
2431

2532
import argparse
@@ -66,14 +73,24 @@ def run(analyzer, argv):
6673
except FileNotFoundError:
6774
print(f'{analyzer}: not installed, skipping')
6875
return 0
76+
# Normalize the end-of-run signal so every analyzer prints a clear
77+
# pass/fail summary line. ruff prints "All checks passed!" itself,
78+
# bandit and vulture stay silent on a clean run - which is confusing.
79+
if result.returncode == 0:
80+
print(f'{analyzer}: all checks passed', flush=True)
81+
else:
82+
print(
83+
f'{analyzer}: issues found (exit {result.returncode})',
84+
flush=True,
85+
)
6986
return result.returncode
7087

7188

7289
def main():
7390
parser = argparse.ArgumentParser(description=__doc__)
7491
parser.add_argument(
7592
'--only',
76-
help='Comma-separated list of analyzers to run (ruff, pylint, bandit, vulture)',
93+
help='Comma-separated list of analyzers to run (ruff, bandit, vulture)',
7794
default='',
7895
)
7996
args = parser.parse_args()
@@ -91,9 +108,6 @@ def main():
91108
if selected is None or 'ruff' in selected:
92109
exit_code |= run('ruff', ['ruff', 'check', '--no-fix', *python_files])
93110

94-
if selected is None or 'pylint' in selected:
95-
exit_code |= run('pylint', ['pylint', *python_files])
96-
97111
if selected is None or 'bandit' in selected:
98112
exit_code |= run(
99113
'bandit',

tools/run-tox-tests

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#!/usr/bin/env python3
2+
# -*- coding: utf-8; py-indent-offset: 4 -*-
3+
#
4+
# Author: Linuxfabrik GmbH, Zurich, Switzerland
5+
# Contact: info (at) linuxfabrik (dot) ch
6+
# https://www.linuxfabrik.ch/
7+
# License: The Unlicense, see LICENSE file.
8+
9+
"""Run unit tests across every supported Python version via tox.
10+
11+
This is a thin wrapper around `tox` that lives in `tools/` so the
12+
same `tools/run-*` naming convention used for unit, container and
13+
linter checks applies to the cross-Python-version test run as well.
14+
15+
The actual Python matrix (py39 ... py314) and the list of plugins
16+
each env depends on live in the repo's `tox.ini`. Any command-line
17+
arguments to this script are passed straight through to tox. A few
18+
common invocations:
19+
20+
tools/run-tox-tests # run the full matrix
21+
tools/run-tox-tests -e py39 # only python 3.9
22+
tools/run-tox-tests -e py312 -- procs scanrootkit
23+
# only python 3.12, only
24+
# two plugins (forwarded
25+
# to tools/run-unit-tests
26+
# via {posargs})
27+
28+
Use `tools/run-unit-tests` directly for the single-interpreter case
29+
against the currently activated venv; use this wrapper when you
30+
want the multi-Python sweep that catches interpreter-specific bugs.
31+
"""
32+
33+
import os
34+
import subprocess
35+
import sys
36+
37+
REPO_ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
38+
39+
40+
def main():
41+
try:
42+
result = subprocess.run(['tox', *sys.argv[1:]], cwd=REPO_ROOT, check=False)
43+
except FileNotFoundError:
44+
print(
45+
'tox is not installed. Install it with `pip install tox` '
46+
'(or your distribution package).',
47+
file=sys.stderr,
48+
)
49+
return 1
50+
return result.returncode
51+
52+
53+
if __name__ == '__main__':
54+
sys.exit(main())

0 commit comments

Comments
 (0)