Conversation
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.
r-sharp
left a comment
There was a problem hiding this comment.
Not a 'requested change', more just a comment/observation.
I can't help but feel "main" is doing too much 'heavy lifting'. For example, lines 135 to 152 /might/ be a nice compact function taking inputs and ignore_list and returning files_to_check.
I'm also less than convinced by the methodology, which requires each value in 'inputs' to be checked to see if it's a direcory (to then walk), or a file. Wouldn't 'globbing' each input to return a list of files be simpler as that would accept both a directory to descend and a file.
The small block to actually check them is less obvious to make a function, but it would allow unit testing...
Then the bottom 40+ lines are purely to generate the report/output, which while nicely set up to get plurals and grammer correct, does seem a touch overcomplicated...
| if not templates: | ||
| raise SystemExit("[ERROR] no templates found") | ||
|
|
There was a problem hiding this comment.
Perhaps a tad picky, but should this check perhaps be at line 124, immediately after the last time templates is updated ?
There was a problem hiding this comment.
I appear to have missed a bit of logic: the check should be at L127 and should report an error if both templates and regex_templates_raw are empty.
| default=template_path, | ||
| help="path to the templates (default: %(default)s)", | ||
| ) | ||
| excl_group.add_argument( |
There was a problem hiding this comment.
This appears to be the only argument in the exclusive arguments group, which I can't help but feel makes it somewhat difficult for there to be two clashing args....
There was a problem hiding this comment.
It's my fault: the templates argument splits the two exclusive arguments --full_trunk and files in an non-obvious way. I'll move things around to make it more obvious.
There was a problem hiding this comment.
I swear I 'hunted' for another excl_group.add_argument and couldn't spot it...
r-sharp
left a comment
There was a problem hiding this comment.
Thanks for those tweaks- Passing on for CR.
PR Summary
Sci/Tech Reviewer: @r-sharp
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
Testing
Template Location Changes
Tests of changes to the template location code using the copyright checker bin directory and running script on itself:
Ignore and Empty Changes
Test changes to messages where all files are ignored or where no valid files can be found:
New Output Format
Examples of the new format of the output using the UM source:
Security Considerations
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
(Please alert the code reviewer via a tag when you have approved the SR)
Code Review