Skip to content

Commit a6536a1

Browse files
committed
Remove "positive violations" and invert score.
Now all violations are really violations. There is no need for the "positive violations". The score is now purely a badness score. The higher the score, the more work is needed to fix the problem. A score of 0 means the problem has no issues. The "positive violations" were really going to be a problem if the intent of the score is to obtain a measure of how much work is needed to fix a problem and make it conform to current best-practices in problem authoring. For example, a problem could do quite a bit wrong but have a custom checker. The custom checker score was really high, and so that would offset the things done wrong and it might end up with a score that is the same as for a problem that only does a few things wrong, but doesn't have a custom checker. So that first problem with the custom checker really needs a lot of work, but the second problem without the checker only needs trivial fixes. By only having a badness score you get a much clearer measure of how much is needed to update a problem to conform with current best-practices.
1 parent 85415e3 commit a6536a1

20 files changed

+46
-384
lines changed

bin/pg-critic.pl

Lines changed: 17 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,18 @@ =head1 SYNOPSIS
1616
JavaScript Object Notation.
1717
-o|--output-file Filename to write output to. If not provided output will
1818
be printed to STDOUT.
19-
-n|--no-details Only show the filename and score and do not include the
20-
details in the output for each file.
19+
-n|--no-details Only show the filename and badness score and do not
20+
include the details in the output for each file.
2121
-s|--strict Disable "## no critic" annotations and force all
2222
policies to be enforced.
2323
-h|--help Show the help message.
2424
2525
=head1 DESCRIPTION
2626
2727
C<pg-critic.pl> is a PG problem source code analyzer. It is the executable
28-
front-end to the L<WeBWorK::PG::Critic> module, which attempts to identify
29-
usage of old or deprecated PG features, as well as usage of newer features and
30-
current best practices in coding a problem.
28+
front-end to the L<WeBWorK::PG::Critic> module, which attempts to identify usage
29+
of old or deprecated PG features and code that does not conform to current
30+
best-practices.
3131
3232
=cut
3333

@@ -70,9 +70,9 @@ (@violations)
7070
if ($_->policy =~ /^Perl::Critic::Policy::PG::/) {
7171
$score += $_->explanation->{score} // 0;
7272
} else {
73-
# Deduct 5 points for any of the default Perl::Critic::Policy violations.
73+
# Add 5 points for any of the default Perl::Critic::Policy violations.
7474
# These will not have a score in the explanation.
75-
$score -= 5;
75+
$score += 5;
7676
}
7777
}
7878
return $score;
@@ -83,13 +83,10 @@ (@violations)
8383
for (@ARGV) {
8484
my @violations = critiquePGFile($_, $force);
8585

86-
my (@positivePGResults, @negativePGResults, @perlCriticResults);
86+
my (@pgCriticViolations, @perlCriticViolations);
8787
if (!$noDetails) {
88-
@positivePGResults =
89-
grep { $_->policy =~ /^Perl::Critic::Policy::PG::/ && $_->explanation->{score} > 0 } @violations;
90-
@negativePGResults =
91-
grep { $_->policy =~ /^Perl::Critic::Policy::PG::/ && $_->explanation->{score} < 0 } @violations;
92-
@perlCriticResults = grep { $_->policy !~ /^Perl::Critic::Policy::PG::/ } @violations;
88+
@pgCriticViolations = grep { $_->policy =~ /^Perl::Critic::Policy::PG::/ } @violations;
89+
@perlCriticViolations = grep { $_->policy !~ /^Perl::Critic::Policy::PG::/ } @violations;
9390
}
9491

9592
push(
@@ -99,11 +96,7 @@ (@violations)
9996
score => scoreProblem(@violations),
10097
$noDetails
10198
? ()
102-
: (
103-
positivePGResults => \@positivePGResults,
104-
negativePGResults => \@negativePGResults,
105-
perlCriticResults => \@perlCriticResults
106-
)
99+
: (pgCriticViolations => \@pgCriticViolations, perlCriticViolations => \@perlCriticViolations)
107100
}
108101
);
109102
}
@@ -116,16 +109,13 @@ (@violations)
116109
return join(
117110
"\n",
118111
map { (
119-
"filename: $_->{file}",
120-
"score: $_->{score}",
121-
@{ $_->{positivePGResults} // [] }
122-
? ('positive pg critic results:', map { "\t" . $_->to_string } @{ $_->{positivePGResults} })
112+
"Filename: $_->{file}",
113+
"Score: $_->{score}",
114+
@{ $_->{pgCriticViolations} // [] }
115+
? ('PG critic violations:', map { "\t" . $_->to_string } @{ $_->{pgCriticViolations} })
123116
: (),
124-
@{ $_->{negativePGResults} // [] }
125-
? ('negative pg critic results:', map { "\t" . $_->to_string } @{ $_->{negativePGResults} })
126-
: (),
127-
@{ $_->{perlCriticResults} // [] }
128-
? ('perl critic results:', map { "\t" . $_->to_string } @{ $_->{perlCriticResults} })
117+
@{ $_->{perlCriticViolations} // [] }
118+
? ('Perl critic violations:', map { "\t" . $_->to_string } @{ $_->{perlCriticViolations} })
129119
: ()
130120
) } @$results
131121
);

lib/Perl/Critic/Policy/PG/EncourageCustomCheckers.pm

Lines changed: 0 additions & 43 deletions
This file was deleted.

lib/Perl/Critic/Policy/PG/EncourageModernContextUsage.pm

Lines changed: 0 additions & 65 deletions
This file was deleted.

lib/Perl/Critic/Policy/PG/EncouragePGMLUsage.pm

Lines changed: 0 additions & 57 deletions
This file was deleted.

lib/Perl/Critic/Policy/PG/EncourageQualityMacroUsage.pm

Lines changed: 0 additions & 100 deletions
This file was deleted.

0 commit comments

Comments
 (0)