NAME

WeBWorK::PG::Critic - Critique PG problem source code for best-practices.

DESCRIPTION

Analyze a pg file for use of old and current methods.

FUNCTIONS

critiquePGCode

my @violations = critiquePGCode($code, $force = 0);

Parses and critiques the given PG problem source provided in $code. An array of violations that are found is returned. Note that the elements of this return array are Perl::Critic::Violation objects. The explanation method can be called for each element, and that will either return a string or a reference to a hash. The string return type will occur for a violation of a default Perl::Critic::Policy policy. The last return type will occur with a Perl::Critic::Policy::PG policy, and the hash will contain a score key and an explanation key containing the actual explanation. Note that the greater the score, the worse the violation is. In some cases the explanation return hash will also contain the key sampleProblems which will be a reference to an array each of whose entries will be a reference to a two element array whose first element is the title of a sample problem and whose second element is the path for that sample problem where the sample problem demonstrates a way to fix the policy violation.

Note that ## no critic annotations can be used in the code to disable a violation for a line or the entire file. See "BENDING THE RULES". However, if $force is true, then ## no critic annotations are ignored, and all policies are enforced regardless.

critiquePGFile

my @violations = critiquePGFile($file, $force);

This just executes critiquePGCode on the contents of $file and returns the violations found.