I’m really excited to announce a new version of fortitude! Fortitude is a Fortran linter, heavily inspired by the Python linter ruff. We’ve added a bunch of new rules, but more excitingly, we’ve started adding auto-fixes – so far, mostly for style issues, but we’re continually adding new rules and fixes.
Why should you use fortitude?
- it’s fast – running
fortitude check --fix
on a large, popular scientific package fixed 23,376 issues across 473 files in 1.4s! Most - it catches bugs – rules like
assumed-size-character-intent
andimplicit-external-procedures
help catch real bugs in code - it helps you follow community best practices
- it’s opinionated but customisable – don’t like
double-precision
? Turn it off in yourfpm.toml
file - it integrates with your CI – use
--output-format=github
to get automatic annotations on your PRs - it’s continuously expanding – this release sees us increase to 34 rules, with another 30 or so in the pipeline!
Planned features include per-file and per-line ignores, an opinionated formatter, and editor integration – warnings as fast as you can type!
We’d love to hear your feedback, especially on the new rules in preview – contributors even more welcome!
New Features
- Adds
--preview
flag. Going forward, many new features will be hidden behind this prior to a stable release. - Adds autofixes.
- A subset of rules can now be fixed automatically by passing
--fix
or--unsafe-fix
(mostly style-based rules) - Fixable rules are highlighted in the output
- See the new rules page for an overview of which rules are now fixable
- A subset of rules can now be fixed automatically by passing
- Adds rules to the
modules
category for checking accessibility in modules (both in preview mode)missing-accessibility-statement
requires you to explicitly declare the default accessibility toprivate
orpublic
default-public-accessibility
requires you to set the default accessibility toprivate
- Adds rules to the
style
category:missing-double-colon
requires variable declarations to include::
, e.g.integer :: i
instead ofinteger i
.incorrect-space-before-comment
requires at least two spaces before an inline comment.
- Adds rules to the
typing
category:external-procedure
warns for the use of procedures within implicit interfaces using theexternal
declaration.implicit-external-procedures
warns when a bareimplicit none
is used instead ofimplicit none (type, external)
, which forbids implicit typing when calling external procedures.
- Adds the ‘obsolescent’ rule category for catching outdated Fortran features, with three new rules:
common-block
statement-function
entry-statement
- Adds an optional progress bar – useful when running on very large projects or on slower hardware.
- The
no-real-suffix
rule has been upgraded, and no longer complains in cases where no precision would be lost, e.g:
use, intrinsic :: iso_fortran_env, only: dp => real64
real(dp), parameter :: x = 3.141592653589 ! Error, RHS is single precision, precision lost in assignment
real(dp), parameter :: x = 3.141592653589_dp ! Okay
real(dp), parameter :: y = 1 ! Okay, no precision lost
- We have docs!
Bug-fixes
trailing-whitespace
andline-too-long
can handle multibyte UTF-8 characters in strings and comments- Correctly report number of files scanned on completion
Breaking changes
- The rule
external-function
has been renamedprocedure-not-in-module
to avoid confusion with the newexternal-procedure
rule.