A Fortran linter, inspired by (and built upon) Ruff. Written in Rust π¦ and installable with Python π.
Linting 43 files from the GS2 repo.
- β‘ Blazingly fast, up to hundreds of times faster than other open-source Fortran linters.
- π§ Automatically fixes linter warnings.
- π 50+ rules, with many more planned.
- π Multiple output formats, including SARIF and GitHub/GitLab CI.
- π€ Follows community best practices.
- πͺ Built on a robust tree-sitter parser.
Fortitude is developed by PlasmaFAIR, improving the sustainability of plasma science research software.
For more detail, please see our documentation.
Fortitude is available as
fortitude-lint on PyPI:
# With uv:
uv tool install fortitude-lint@latest
# With pip:
pip install fortitude-lintStarting with version 0.7.0, Fortitude can be installed with our
standalone installers:
# On macOS and Linux:
curl -LsSf https://github.com/PlasmaFAIR/fortitude/releases/latest/download/fortitude-installer.sh | sh
# On Windows:
powershell -c "irm https://github.com/PlasmaFAIR/fortitude/releases/latest/download/fortitude-installer.psi | iex"It can also be installed as a pure Rust project:
git clone https://github.com/PlasmaFAIR/fortitude
cd fortitude
cargo install --path crates/fortitudeFortitude can also be installed via other package managers
Fortitude can lint your whole project under the working directory
using the check command:
fortitude checkYou can also call check on individual files, globs, and
directories. You can configure what extensions Fortitude searches
for in directories with --file-extensions:
fortitude check --file-extensions=f90,fppBe default, Fortitude will ignore files and directories in your .gitignore.
This can be disabled by setting --no-respect-gitignore. Additional excludes
can be set using --excludes:
# Don't check in the `benchmarks/` and `tests/` directories.
fortitude check --exclude=benchmarks,testsYou can select or ignore individual rules or whole groups with
--select and --ignore:
# Just check for missing `implicit none`
fortitude check --select=C001
# Also check for missing `implicit none` in interfaces
fortitude check --select=C001,C002
# Ignore all styling rules
fortitude check --ignore=S
# Only check for style rules, but ignore superfluous implicit none
fortitude check --select=S --ignore=S201
# Rules and categories can also be referred to by name
fortitude check --select=style --ignore=superfluous-implicit-noneUse --output-format=concise to get shorter output:
$ fortitude check --output-format=concise
test.f90:2:1: C111 function not contained within (sub)module or program
test.f90:5:1: S061 end statement should read 'end function double'
test.f90:7:1: C111 subroutine not contained within (sub)module or program
test.f90:8:3: C022 real has implicit kindThe explain command can be used to get extra information about any rules:
# Print extra information for all rules
fortitude explain
# Only get information for selected rules
fortitude explain C001 C011
# Print information on all style rules
fortitude explain S
# Rules and categories can also be referred to by name
fortitude explain obsolescent superfluous-implicit-noneTo see further commands and optional arguments, try using --help:
fortitude --help
fortitude check --helpNote
Added in v0.6.0
Fortitude can automatically fix some lint warnings, such as
unnecessary implicit none statements, missing double-colons in
variable declarations, and more. Just pass the --fix flag to
check:
$ fortitude check --fix
fortitude: 1 files scanned.
Number of errors: 2 (2 fixed, 0 remaining)Run fortitude explain to see which rules have fixes available.
Note
Added in v0.6.0
Some fortitude rules are only available through an opt-in preview
mode to give the community some time to evaluate them and provide
feedback. To enable preview rules, pass the --preview flag to
check,
$ fortitude check --previewor to enable more permanently, set it in your fpm.toml:
[extra.fortitude.check]
preview = trueor fortitude.toml:
[check]
preview = trueRun fortitude explain to see which rules are in preview mode.
Fortitude will look for either a fortitude.toml, .fortitude.toml or fpm.toml
file in the current directory, or one of its parents.
If using fortitude.toml or .fortitude.toml, settings
should be under the command name:
[check]
select = ["C", "E", "S"]
ignore = ["S001", "S082"]
line-length = 132For fpm.toml files, this has to be additionally nested under the
extra.fortitude table:
[extra.fortitude.check]
select = ["C", "E", "S"]
ignore = ["S001", "S082"]
line-length = 132You can use --extend-select from the command line to select additional
rules on top of those in the configuration file.
# Select correctness, error, style and obsolescent categories
fortitude check --extend-select=OBPre-commit hooks for Fortitude are available at fortitude-pre-commit.
See table of rules for a list of all rules.
Please feel free to add or suggest new rules or comment on the layout of the project
while it's still at this early stage of development. See
CONTRIBUTING.md for a guide on contributing to the project, and
README.dev.md for details on building the project from source,
running tests, and linting/formatting the code. Please consult our code of
conduct before contributing.
This work is distributed under the MIT License. See LICENSE for more
information.
Fortitude is inspired by, and uses parts from
ruff, used under the MIT licence. See
LICENSE for more information.