Skip to content

Extend lint_source.py to catch stop/error stop, integer(wp), and signed d-exponent literals #1485

Description

@sbryngelson

toolchain/mfc/lint_source.py is the CI source linter. Current checks include: check_raw_directives (raw !$acc/!$omp), check_double_precision (dsqrt/…, real(8)/real(4)/double precision, and [0-9]d0 literals), check_junk_code, check_false_integers (bare 2_wp), check_junk_comments, check_fypp_list_duplicates, check_duplicate_lines, check_hardcoded_byte_size.

Gaps that let convention violations recur:

  1. No stop/error stop check. Nothing flags Fortran stop/error stop. Proposed check_stop_statements: flag stop/error stop in src/ .fpp/.f90, on non-comment/non-#: lines (so Fypp #:stop is exempt), excluding syscheck/ and the #ifndef MFC_MPI fallback in m_mpi_common.fpp (allowlist that file/routine).

  2. No integer(wp) check. Add a regex \binteger\s*\(\s*wp\s*\) → suggest plain integer.

  3. The d-literal regex is too narrow. check_double_precision uses [0-9]d0, which only matches a d0 exponent. Signed/multi-digit exponents like 5.0d-11, 2.5d+3, 1.0d12 are not caught. Broaden to [0-9]\.?[0-9]*[dD][-+]?[0-9]+ (case-insensitive, on the code portion only). This single fix would have caught m_bubbles_EL.fpp:1345.

Why it matters: these conventions are otherwise enforced only by review; real violations exist today that review missed. Closing the linter gaps makes them CI-gated.

Scope note: catching bare-real-literal-missing-_wp in general is much harder (huge false-positive surface — array indices, loop bounds, (/1,0,0/) are all integers-by-design). Recommend scoping this issue to (1)–(3) only, which are unambiguous.

This pairs with the stops_mpi_abort and forbidden-literal cleanup issues.


Filed from a repo-wide code-cleanliness review; verified against master @ 40dde5e.

Code references

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions