To prevent endless issues when running the linters locally (say, on specific versions of bash, or system tools having certain names, or a certain implementation of sed
, etc) , as well as for maintainability/reviewability, it’s preferred for linter scripts to be written in Python.
Here is a list of scripts, feel free to pick up any that haven’t been ported:
-
test/lint/check-doc.py
(added in #7280, was always Python) -
test/lint/git-subtree-check.sh
(in progress in #25039) -
test/lint/lint-all.sh
(ported in #24982) -
test/lint/lint-assertions.sh
(ported in #24856) -
test/lint/lint-circular-dependencies.sh
(ported in #24915) -
test/lint/lint-cpp.sh
(removed in #24785) -
test/lint/lint-files.py
(added in #21740, was always Python) -
test/lint/lint-format-strings.sh
(ported in #24802) -
test/lint/lint-git-commit-check.sh
(ported in #24853) -
test/lint/lint-include-guards.sh
(ported in #24902) -
test/lint/lint-includes.sh
(ported in #24895) -
test/lint/lint-locale-dependence.sh
(ported in #24932) -
test/lint/lint-logs.sh
(ported in #24849) -
test/lint/lint-python-dead-code.py
(ported in #24778) -
test/lint/lint-python-mutable-default-parameters.sh
(ported in #24800) -
test/lint/lint-python.sh
(ported in #24794) -
test/lint/lint-python-utf8-encoding.sh
(ported in #24916) -
test/lint/lint-qt.sh
(removed in #24790) -
test/lint/lint-shell-locale.sh
(ported in #24929) -
test/lint/lint-shell.sh
(ported in #24840) -
test/lint/lint-spelling.py
(ported in #24766) -
test/lint/lint-submodule.sh
(ported in #24803) -
test/lint/lint-tests.sh
(ported in #24815) -
test/lint/lint-whitespace.sh
(ported in #24844) -
test/lint/run-lint-format-strings.py
(added in #13705, was always Python)
Although I try to keep this post up to date, before starting on a linter, please first do a github search in PRs to see if a PR for that already exists.
Guidelines
- Don’t forget to update
test/README.md
when the name of a script changes. - Avoid
shell=true
on subprocess calls. Remember that the point here is to avoid shell ambiguities. - If possible, avoid calling out to subprocesses at all and use what Python APIs provide (say,
grep
sed
awk
sha256sum
). An exception if this would introduce further dependencies that need to be installed. These are OK to use subprocess for:git
subcommands includinggit grep
โthe alternative would be to require an extra dependency on a Python git module, also,git
can be assumed to be the same implementation everywhere- Other scripts in the source tree.
- External linters (
vulture
,codespell
, etc) that provide only a command-based interface.
- Some further recommendations about Python usage here: #24766#pullrequestreview-932953476
Useful skills:
- Python
- Being able to read shell script
Want to work on this issue?
For guidance on contributing, please read CONTRIBUTING.md before opening your pull request.