A Fortran linter, written in Rust :crab: and installable with Python :snake:.
Fortitude can be installed directly into your Python environment:
pip install fortitude-lint
It can also be installed as a pure Rust project:
git clone https://github.com/PlasmaFAIR/fortitude
cargo install --path fortitude
Fortitude can lint your whole project under the working directory
using the check
command:
fortitude check
You 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 src --file-extensions=f90,fpp
You can select or ignore individual rules or whole groups with
--select
and --ignore
:
# Just check for missing `implicit none`
fortitude check --select=T001
# Also check for missing `implicit none` in interfaces
fortitude check --select=T001,T002
# Ignore all styling rules
fortitude check --ignore=S
# Only check for typing rules, but ignore superfluous implicit none
fortitude check --select=T --ignore=T003
# Rules and categories can also be referred to by name
fortitude check --select=typing --ignore=superfluous-implicit-none
Use --output-format=concise
to get shorter output:
$ fortitude check --concise
test.f90:2:1: M001 function not contained within (sub)module or program
test.f90:5:1: S061 end statement should read 'end function double'
test.f90:7:1: M001 subroutine not contained within (sub)module or program
test.f90:8:3: P021 real has implicit kind
The 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 T001,T011
# Print information on all style rules
fortitude explain S
# Rules and categories can also be referred to by name
fortitude explain style,superfluous-implicit-none
To see further commands and optional arguments, try using --help
:
fortitude --help
fortitude check --help
Fortitude will look for either a fortitude.toml
or fpm.toml
file in the
current directory, or one of its parents. If using fortitude.toml
, settings
should be under the command name:
[check]
select = ["S", "T"]
ignore = ["S001", "S051"]
line-length = 132
For fpm.toml
files, this has to be additionally nested under the
extra.fortitude
table:
[extra.fortitude.check]
select = ["S", "T"]
ignore = ["S001", "S051"]
line-length = 132
You can use --extend-select
from the command line to select additional
rules on top of those in the configuration file.
# Selects S, T, and M categories
fortitude check --extend-select=M
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.