Skip to content

update linters.yaml to use new versions of softwares; add linter_rrfs_code_norms.py#1434

Merged
MatthewPyle-NOAA merged 12 commits intoNOAA-EMC:rrfs-mpas-jedifrom
guoqing-noaa:rrfs_code_norm
Apr 10, 2026
Merged

update linters.yaml to use new versions of softwares; add linter_rrfs_code_norms.py#1434
MatthewPyle-NOAA merged 12 commits intoNOAA-EMC:rrfs-mpas-jedifrom
guoqing-noaa:rrfs_code_norm

Conversation

@guoqing-noaa
Copy link
Copy Markdown
Contributor

@guoqing-noaa guoqing-noaa commented Apr 10, 2026

  1. update actions/checkout and actions/setup-python in linter.yaml to newer versions (older versions will be deprecated soon).

  2. add linter_rrfs_code_norms.py to automatically check whether the BASH scripts follow the best practices outlined in the Google Company Shell Style Guide. This linter also checks compliance to selected NCO implementation standards (such as using ${NDATE}, PDY, etc).
    Currently, 18 rules are enforced (see the next post). These checks were previously performed manually during PR reviews; this linter makes the process faster, more consistent and more complete.

  3. Updated jobs/, scripts/ and ush/ scripts to pass the RRFS Code Norm Linting. Although it involves lots of files, but all changes are cosmetic and address the Linting comments.

@github-advanced-security
Copy link
Copy Markdown

You are seeing this message because GitHub Code Scanning has recently been set up for this repository, or this pull request contains the workflow file for the Code Scanning tool.

What Enabling Code Scanning Means:

  • The 'Security' tab will display more code scanning analysis results (e.g., for the default branch).
  • Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results.
  • You will be able to see the analysis results for the pull request's branch on this overview once the scans have completed and the checks have passed.

For more information about GitHub Code Scanning, check out the documentation.

@guoqing-noaa
Copy link
Copy Markdown
Contributor Author

guoqing-noaa commented Apr 10, 2026

Rules

ID Severity Description
RRFS001 warning Use source instead of . for sourcing files
RRFS002 error Use [[ instead of [
RRFS003 error Use == instead of = for string comparison in [[ ]]
RRFS004 warning Use -s instead of -f to check if a file exists and is not size zero
RRFS005 warning Use ${NDATE} for date arithmetic, not date -d (formatting existing dates with date -d is allowed)
RRFS006 error Use 2 spaces for indentation; no TABs
RRFS007 error Exported variables must start with uppercase (exception: err, pgm, pid, cyc, jobid, pgmout)
RRFS008 error Use :- (not : alone) for default values in ${VAR:-default}
RRFS009 warning Use ${var} instead of $var (except shell specials $?, $!, $@, etc.)
RRFS010 warning Use (( )) instead of [[ ]] for arithmetic operations
RRFS011 error Double-quote variables in -z/-n tests: -z "${var}"
RRFS012 error Job files (jobs/) must start with the required header (comments between shebang and header lines are allowed)
RRFS013 error Script files (scripts/) must start with the required header (comments between shebang and header lines are allowed)
RRFS014 error Use $(command) instead of backticks
RRFS015 warning Use true/false without quotes in assignments (only flags ="true" and ="false", not comparisons)
RRFS016 warning Use ${var^^} to uppercase before comparing to TRUE/FALSE/YES/NO
RRFS017 warning Use standard names: PDY not YYYYMMDD, cyc not HH, subcyc not MM, CDATE not YYYYMMDDHH
RRFS018 error Call Python scripts directly with a shebang instead of python script.py

@guoqing-noaa
Copy link
Copy Markdown
Contributor Author

User can check the "RRFS Code Norm Linting" results by clicking the three dot next to the failed test, click view details. In the new page, expand the Run RRFS Code Norm Linting section and then we can see the linting results, i.e, the violation lines, columns, the associated RRFS rules and the modification suggestions:

image

User don't have to check the results on the Github pages. This linter can also run locally as:

workflow/tools/linter_rrfs_code_norms.py  scripts/  jobs/  ush/  > rrfs_linting.txt

@guoqing-noaa
Copy link
Copy Markdown
Contributor Author

The latest commit demonstrated that once we fixed all those "RRFS Code Norm Linting" comments, "all checks have passed".

I will remove the temporary demo file bad_example.sh in the next commit.

@guoqing-noaa
Copy link
Copy Markdown
Contributor Author

completed 10 retro cycles and worked as expected as the changes are only cosmetic.

Copy link
Copy Markdown
Contributor

@MatthewPyle-NOAA MatthewPyle-NOAA left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice cleanup and adding of standards

@MatthewPyle-NOAA MatthewPyle-NOAA merged commit db52c79 into NOAA-EMC:rrfs-mpas-jedi Apr 10, 2026
6 checks passed
@guoqing-noaa guoqing-noaa deleted the rrfs_code_norm branch April 10, 2026 17:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants