Repository navigation
Make code meet perlcritic severity level 4. - #3126
Merged
Merged
Conversation
drgrice1
force-pushed
the
perlcritic-workflow
branch
2 times, most recently
from
August 10, 2026 22:10
69e3983 to
8b30a4b
Compare
This adds a GitHub workflow that checks that Perl files in the `lib` directory satisfy perlcritic with the `.perlcriticrc` file included in this pull request. I have been working toward this for years now (since December of 2022 according to the date on this commit). Originally there were are large number of changes to files. At this point, there are not so many, so I think it is time for this to go in. Note there are some things that can't be helped (particularly with safe mode code). So those are disabled with `## no critic` annotations. Almost every method in the `lib/WeBWorK/DB.pm` file breaks the `Subroutines::RequireArgUnpacking` rule, and so that is disabled for the entire file. Note that if `no critic` annotations are added to the code, they should be specific and disable only the rule or rules that are to be ignored, and those rules should usually be enabled again later in the file after the rule breaking code. Other than the annotations already added in this pull request, this is generally something that should be avoided.
drgrice1
force-pushed
the
perlcritic-workflow
branch
from
August 10, 2026 22:10
8b30a4b to
92be955
Compare
somiaj
approved these changes
Aug 11, 2026
somiaj
left a comment
Contributor
There was a problem hiding this comment.
Looks good, all files pass perlcritic ./lib.
I notice the work flow isn't testing perl (.pm and .pl) files in ./bin and only files in ./lib. Should the perl files in ./bin be tested as well?
Member
Author
|
Yes, it is intentionally only testing files in |
Alex-Jordan
approved these changes
Aug 12, 2026
drgrice1
added a commit
to drgrice1/webwork2
that referenced
this pull request
Aug 13, 2026
…itGrade.pm`. This was missed in openwebwork#3126. The `WeBWorK::Debug` package no longer exports the `debug` method by default, and it must be explicitly imported where needed. This was also missing in the `lib/WeBWorK/File/SetDef.pm` file. I have checked all cases, and these are the only ones.
drgrice1
added a commit
to drgrice1/webwork2
that referenced
this pull request
Oct 14, 2026
I change the name of the method that writes the tags of a `WeBWorK::Utils::Tags` object to its problem file from `write` to `write_to_file` in openwebwork#3126. However, I didn't change the method name in place where this method was called in the `WeBWorK::Utils::ListingDB` package. As a result writing tags fails. Note that the method name `write` does not pass the `Subroutines::ProhibitBuiltinHomonyms` policy. However, it only fails the policy with the caveat explicitly stated in their documentation which states "It is reasonable to declare an object method with the same name as a Perl built-in function, since they are easily distinguished from each other. However, at this time, Perl::Critic cannot tell whether a subroutine is static or an object method." This is one of my annoyances with that rule. It is generally a good rule, but it can't be implemented well. So the fix implemented here is to rename the method back to `write`, since it is a perfectly good object method name, and add `## no critic (Subroutines::ProhibitBuiltinHomonyms)` to the line.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This adds a GitHub workflow that checks that Perl files in the
libdirectory satisfy perlcritic with the.perlcriticrcfile included in this pull request.I have been working toward this for years now (since December of 2022 according to the date on this commit). Originally there were are large number of changes to files. At this point, there are not so many, so I think it is time for this to go in.
Note there are some things that can't be helped (particularly with safe mode code). So those are disabled with
## no criticannotations. Almost every method in thelib/WeBWorK/DB.pmfile breaks theSubroutines::RequireArgUnpackingrule, and so that is disabled for the entire file.Note that if
no criticannotations are added to the code, they should be specific and disable only the rule or rules that are to be ignored, and those rules should usually be enabled again later in the file after the rule breaking code. Other than the annotations already added in this pull request, this is generally something that should be avoided.