Skip to content

Reduce output from copyright checker#198

Open
t00sa wants to merge 2 commits intoMetOffice:mainfrom
t00sa:copyright-messages
Open

Reduce output from copyright checker#198
t00sa wants to merge 2 commits intoMetOffice:mainfrom
t00sa:copyright-messages

Conversation

@t00sa
Copy link
Contributor

@t00sa t00sa commented Feb 26, 2026

PR Summary

Sci/Tech Reviewer:
Code Reviewer: @cameronbateman-mo

Remove a lot of the duplicate output from the copyright checker to make it obvious which files have a problem. Also report cases where no files are found or all files are ignored as non-fatal warnings.

Improve usability by making it possible to specify the location of the template directory on the command line. Previously, the script either used the contents of CYLC_TASK_WORK_PATH or the current directory.

Catch the case where no templates have been found and Exit with an error. Previous behaviour was to continue and to flag up all files as having invalid copyrights.

Code Quality Checklist

  • I have performed a self-review of my own code
  • My code follows the project's style guidelines
  • Comments have been included that aid understanding and enhance the readability of the code
  • My changes generate no new warnings
  • All automated checks in the CI pipeline have completed successfully

Testing

  • This change has been tested appropriately (please describe)

Template Location Changes

Tests of changes to the template location code using the copyright checker bin directory and running script on itself:

vdi> env CYLC_TASK_WORK_PATH=.. ./copyright_checker.py 
[SUCCESS] 1 file has a valid copyright
vdi> ./copyright_checker.py  --template=../file/
[SUCCESS] 1 file has a valid copyright
vdi> ./copyright_checker.py  --template=/var/tmp/empty
[ERROR] no templates found
vdi> ./copyright_checker.py
[ERROR] no templates found
vdi>

Ignore and Empty Changes

Test changes to messages where all files are ignored or where no valid files can be found:

vdi> ./copyright_checker.py  --template=../file/ --ignore .py
[WARNING] only possible file ignored
vdi> touch foo.py
vdi> ./copyright_checker.py  --template=../file/ --ignore .py
[WARNING] all 2 possible files ignored
vdi> ./copyright_checker.py  --template=../file/ /var/tmp/empty
[WARNING] no files found
vdi> mkdir /var/tmp/almost-empty
vdi> touch /var/tmp/almost-empty/foo.pl
vdi> ./copyright_checker.py  --template=../file/ /var/tmp/almost-empty
[WARNING] no files found
vdi>

New Output Format

Examples of the new format of the output using the UM source:

vdi> ./copyright_checker.py --templates ../file/ /var/tmp/um/src

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Checked 2515, ignored 0, with 10 failures                                    %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
/var/tmp/um/src/atmosphere/atmosphere_service/include/qsat_mod_qsat_mix.h
/var/tmp/um/src/atmosphere/convection/conv_type_defs.F90
/var/tmp/um/src/atmosphere/convection/tcs_cmt_params_cg.F90
/var/tmp/um/src/atmosphere/convection/tcs_cmt_params_dp.F90
/var/tmp/um/src/atmosphere/convection/tcs_cmt_params_sh.F90
/var/tmp/um/src/atmosphere/convection/comorph/unit_tests/build_test_calc_cond_properties.sh
/var/tmp/um/src/atmosphere/convection/comorph/unit_tests/build_test_check_bad_values.sh
/var/tmp/um/src/atmosphere/convection/comorph/unit_tests/build_test_comorph.sh
/var/tmp/um/src/atmosphere/convection/comorph/unit_tests/build_test_moist_proc.sh
/var/tmp/um/src/atmosphere/convection/comorph/unit_tests/build_test_solve_detrainment.sh

[ERROR] 10 files have missing copyright notices
vdi> ./copyright_checker.py --templates ../file/ --ignore comorph/unit_tests /var/tmp/um/src

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Checked 2504, ignored 11, with 5 failures                                    %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
/var/tmp/um/src/atmosphere/atmosphere_service/include/qsat_mod_qsat_mix.h
/var/tmp/um/src/atmosphere/convection/conv_type_defs.F90
/var/tmp/um/src/atmosphere/convection/tcs_cmt_params_cg.F90
/var/tmp/um/src/atmosphere/convection/tcs_cmt_params_dp.F90
/var/tmp/um/src/atmosphere/convection/tcs_cmt_params_sh.F90

[ERROR] 5 files have missing copyright notices
vdi> ./copyright_checker.py --templates ../file/ /var/tmp/um/src/control
[SUCCESS] 623 files have valid copyrights
vdi>

Security Considerations

  • I have reviewed my changes for potential security issues
  • Sensitive data is properly handled (if applicable)
  • Authentication and authorisation are properly implemented (if applicable)

AI Assistance and Attribution

  • Some of the content of this change has been produced with the assistance of Generative AI tool name (e.g., Met Office Github Copilot Enterprise, Github Copilot Personal, ChatGPT GPT-4, etc) and I have followed the Simulation Systems AI policy (including attribution labels)

Sci/Tech Review

  • I understand this area of code and the changes being added
  • The proposed changes correspond to the pull request description
  • Documentation is sufficient (do documentation papers need updating)
  • Sufficient testing has been completed

(Please alert the code reviewer via a tag when you have approved the SR)

Code Review

  • All dependencies have been resolved
  • Related Issues have been properly linked and addressed
  • Code quality standards have been met
  • Tests are adequate and have passed
  • Security considerations have been addressed
  • Performance impact is acceptable

Remove a lot of the duplicate output from the copyright checker to
make it obvious which files have a problem.  Also report cases where
no files are found or all files are ignored as non-fatal warnings.

Improve usability by making it possible to specify the location of the
template directory on the command line.  Previously, the script either
used the contents of CYLC_TASK_WORK_PATH or the current directory.

Catch the case where no templates have been found and Exit with an
error.  Previous behaviour was to continue and to flag up all files as
having invalid copyrights.
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.

1 participant