Nexus: Add workflow to run linter checks
- Dominant language
- C++
- Stars
- 403
- Forks
- 154
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 82
Description
# Current
The current entirety of Nexus's testing is covered by the workflows in [ci-github-actions-nexus.yaml](https://github.com/QMCPACK/qmcpack/blob/develop/.github/workflows/ci-github-actions-nexus.yaml). It captures all code that is tested for both Python 3.10 and 3.14, however that is only ~64% of the code based on our current reports.
# Proposed
I propose that we add a workflow that runs the `ruff` linter on Nexus with a set of rules that we can select. The benefits of a linter are numerous, but perhaps the most important is that it can easily catch obvious errors in untested code. For example, just running `ruff check --select "F821"` ([F821 description](https://docs.astral.sh/ruff/rules/undefined-name/)) catches all of the errors relating to undefined named, of which there are 69 instances in Nexus as of the time of writing. The reason these errors have remained uncaught is because they are in code that is not tested.
Linters are useful for a number of reasons, but the primary one being that they perform static code analysis, no execution required. This means that they catch errors of many kinds (not all errors, but many), and also can display warnings about poor code practice that occurs in Nexus (e.g. discouraging bare `except` statements, which catch all errors/exceptions, or putting code on one line with a semicolon).
We can add a workflow that runs `ruff` on Nexus and reports passes/fails based on the linter output. To start it doesn't need to be required, but I strongly encourage that in the future it becomes required. There are some rules that likely should be disabled, which can be configured in Nexus's `pyproject.toml` file.
Ruff's guide on how to do this is given [here](https://docs.astral.sh/ruff/integrations/#github-actions).
Contributor guide
Assessment
This issue has not been assessed yet.