Skip to content

Fix lint_param_docs parser bugs and deduplicate CI source lint#1329

Merged
sbryngelson merged 1 commit intoMFlowCode:masterfrom
sbryngelson:docs-checks
Mar 19, 2026
Merged

Fix lint_param_docs parser bugs and deduplicate CI source lint#1329
sbryngelson merged 1 commit intoMFlowCode:masterfrom
sbryngelson:docs-checks

Conversation

@sbryngelson
Copy link
Copy Markdown
Member

Summary

Follow-up to #1327. Fixes bugs found by Claude CI review and deduplicates CI workflow.

Fixes

  • Docstring: Updated to reflect all 3 tiers are blocking (was incorrectly saying Tier 2 is "warnings")
  • Case-sensitivity bug: _parse_namelist_params used stripped.lower() for detection but stripped.split("/user_inputs/") for extraction — fails on uppercase Fortran. Now uses index-based slicing from the lowercase match.
  • Single-line namelist bug: Parser read one line past a single-line namelist declaration. Now checks for continuation & immediately.
  • Multiple namelist blocks: Uses += for accumulator so subsequent namelist /user_inputs/ blocks are captured.
  • CI DRY violation: Replaced 3 hardcoded grep steps in test.yml with single python3 toolchain/mfc/lint_source.py call. Added missing lint_param_docs.py step. CI now matches precheck exactly.

Test plan

  • python3 toolchain/mfc/lint_param_docs.py exits 0
  • ./mfc.sh precheck -j 8 passes all 6/6

🤖 Generated with Claude Code

@sbryngelson sbryngelson marked this pull request as draft March 19, 2026 16:03
@sbryngelson sbryngelson marked this pull request as ready for review March 19, 2026 16:06
@sbryngelson sbryngelson merged commit febffab into MFlowCode:master Mar 19, 2026
30 of 53 checks passed
@github-actions
Copy link
Copy Markdown

Claude Code Review

Head SHA: 1a5d523

Files changed:

  • 2
  • .github/workflows/test.yml
  • toolchain/mfc/lint_param_docs.py

Findings:

toolchain/mfc/lint_param_docs.py_parse_namelist_params: accum += drops parameters at statement boundaries when multiple namelist /user_inputs/ declarations appear in one file

The new code replaces accum = stripped.split("/user_inputs/", 1)[1] (reset per statement) with accum += " " + stripped[idx:] (accumulate across all statements). When a file contains two or more namelist /user_inputs/ statements (which is valid Fortran — repeated namelist groups merge at runtime), the boundary between them produces a single comma-less token like "beta gamma" which fails the re.match(r"^[a-zA-Z_]\w*$", name) guard and is silently dropped.

Minimal reproduction:

text = "  namelist /user_inputs/ alpha, beta\n  namelist /user_inputs/ gamma, delta\n"
# New code returns: {'alpha', 'delta'}   # 'beta' and 'gamma' are silently dropped
# Expected:         {'alpha', 'beta', 'gamma', 'delta'}

All three current m_start_up.fpp files each have exactly one namelist /user_inputs/ statement, so this does not affect CI today. However, if a developer splits a growing namelist into two statements (common as Fortran line-continuation limits are hit), parameters at the statement boundary will be silently excluded from Tier 2 checking, producing false negatives rather than errors.

The fix is to insert a comma separator rather than a space when appending a new namelist statement's content to accum (e.g. accum += ", " + stripped[idx:]), or to reset accum to "" at the start of each new statement and flush collected params into the output set before resetting.

toolchain/mfc/lint_param_docs.pyin_namelist continuation detection tests the full accumulated buffer rather than the current line

In the new code:

accum += " " + stripped[idx:]
in_namelist = accum.rstrip().endswith("&")

in_namelist should reflect whether the current namelist statement has an open continuation, but the endswith("&") test operates on the entire accum string (all previously accumulated content plus the current line). If earlier content in accum happens to end with & (e.g. from a prior continuation that was mid-flight when a second namelist /user_inputs/ line was encountered), in_namelist would be set True incorrectly. The correct test is stripped[idx:].rstrip().endswith("&"), checking only the portion of the current line that follows /user_inputs/.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 19, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 423aab7b-8ed8-4cd7-a4ca-f36aabddc045

📥 Commits

Reviewing files that changed from the base of the PR and between 2162f7a and 1a5d523.

📒 Files selected for processing (2)
  • .github/workflows/test.yml
  • toolchain/mfc/lint_param_docs.py

📝 Walkthrough

Walkthrough

The pull request consolidates three separate grep-based "Lint Source" checks in the CI/CD workflow into a single Python script (lint_source.py), which validates source code against disallowed raw directives, double-precision intrinsics, and junk code markers. Additionally, the lint_param_docs.py script is enhanced to improve detection of multi-line Fortran namelist parameter blocks in source files by using incremental content accumulation and checking for continuation markers. The Tier 2 validation rule for namelist parameter synchronization is updated to be blocking.

📝 Coding Plan
  • Generate coding plan for human review comments

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 19, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 45.01%. Comparing base (2ffec9a) to head (1a5d523).
⚠️ Report is 3 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1329   +/-   ##
=======================================
  Coverage   45.01%   45.01%           
=======================================
  Files          70       70           
  Lines       20562    20562           
  Branches     1962     1962           
=======================================
  Hits         9255     9255           
  Misses      10179    10179           
  Partials     1128     1128           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@sbryngelson sbryngelson deleted the docs-checks branch March 20, 2026 16:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant