Skip to content

Commit 4944ab0

Browse files
committed
Adjust for removal of "positive violations".
1 parent f0e438f commit 4944ab0

File tree

4 files changed

+18
-37
lines changed

4 files changed

+18
-37
lines changed

lib/WebworkWebservice/ProblemActions.pm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,8 +187,8 @@ sub runPGCritic {
187187
return {
188188
ra_out => {
189189
html => $self->c->render_to_string(
190-
template => 'ContentGenerator/Instructor/PGProblemEditor/pg_critic',
191-
results => [ critiquePGCode($params->{pgCode}) ]
190+
template => 'ContentGenerator/Instructor/PGProblemEditor/pg_critic',
191+
violations => [ critiquePGCode($params->{pgCode}) ]
192192
)
193193
},
194194
text => 'The script pg-critic has been run successfully.'

templates/ContentGenerator/Instructor/PGProblemEditor/code_maintenance_form.html.ep

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@
3434
<%= radio_button 'action.code_maintenance' => 'runPGCritic',
3535
id => 'action_code_maintenance_run_pgcritic', class => 'form-check-input'=%>
3636
<%= label_for 'action_code_maintenance_run_pgcritic', class => 'form-check-label', begin =%>
37-
<%== maketext('Run the PG Critic Analyzer') =%>
37+
<%== maketext('Analyze code with PG Critic') =%>
3838
<% end =%>
39-
<a class="help-popup" data-bs-content="<%== maketext('This option runs the PG Critic '
40-
. 'code analyzer which gives suggestions on using modern PG constructs and '
41-
. 'ensures that you include important features.') =%>"
39+
<a class="help-popup" data-bs-content="<%== maketext('This option analyzes the code with PG Critic '
40+
. 'which gives suggestions on using modern PG constructs and ensures that the code conforms '
41+
. 'to current best-practices.') =%>"
4242
data-bs-placement="top" data-bs-toggle="popover" role="button">
4343
<i aria-hidden="true" class="fas fa-question-circle"></i>
4444
<span class="visually-hidden"><%= maketext('PG Critic Help') %></span>

templates/ContentGenerator/Instructor/PGProblemEditor/pg_critic.html.ep

Lines changed: 9 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,12 @@
11
% Perl::Critic::Violation::set_format('%m at line %l, column %c.');
22
%
33
<div class="m-3 overflow-auto">
4-
<h2><%= maketext('PG Critic Results') %></h2>
5-
% my @goodResults = grep { ref($_->explanation) eq 'HASH' && ($_->explanation->{score} // 0) > 0 } @$results;
6-
% if (@goodResults) {
7-
<h3 class="mt-2"><%= maketext('The following are good aspects of this problem:') %></h3>
4+
<h2><%= maketext('PG Critic Violations') %></h2>
5+
% my @pgCriticViolations = grep { $_->policy =~ /^Perl::Critic::Policy::PG::/ } @$violations;
6+
% if (@pgCriticViolations) {
7+
<h3 class="mt-2"><%= maketext('The following PG issues should be fixed:') %></h3>
88
<ul class="list-group">
9-
% for (@goodResults) {
10-
<li class="list-group-item">
11-
<div><%= $_->to_string %></div>
12-
<div>
13-
<%= $_->explanation->{explanation} %>
14-
See <%= link_to(
15-
($_->policy =~ s/^Perl::Critic::Policy:://r)
16-
=> pod_viewer => { filePath => 'lib/' . ($_->policy =~ s/::/\//gr) . '.pm' },
17-
target => '_blank'
18-
) %>.
19-
</div>
20-
</li>
21-
% }
22-
</ul>
23-
%}
24-
% my @badResults = grep { ref($_->explanation) eq 'HASH' && ($_->explanation->{score} // 0) < 0 } @$results;
25-
% if (@badResults) {
26-
<h3 class="mt-2"><%= maketext('The following are things that can be improved:') %></h3>
27-
<ul class="list-group">
28-
% for (@badResults) {
9+
% for (@pgCriticViolations) {
2910
<li class="list-group-item">
3011
<div><%= $_->to_string %></div>
3112
<div>
@@ -55,11 +36,11 @@
5536
% }
5637
</ul>
5738
%}
58-
% my @badPerlResults = grep { !ref($_->explanation) } @$results;
59-
% if (@badPerlResults) {
60-
<h3 class="mt-2"><%= maketext('The following are general Perl issues that can be improved:') %></h3>
39+
% my @perlCriticViolations = grep { $_->policy !~ /^Perl::Critic::Policy::PG::/ } @$violations;
40+
% if (@perlCriticViolations) {
41+
<h3 class="mt-2"><%= maketext('The following general Perl issues should be fixed:') %></h3>
6142
<ul class="list-group">
62-
% for (@badPerlResults) {
43+
% for (@perlCriticViolations) {
6344
<li class="list-group-item">
6445
<div><%= $_->to_string %></div>
6546
<div>

templates/HelpFiles/InstructorPGProblemEditor.html.ep

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,9 +184,9 @@
184184
. 'Second the code can be converted to PGML. This changes the code in text blocks to use PGML features. '
185185
. 'Generally the conversion of much of the formatting and LaTeX is performed correctly. However, answer '
186186
. 'blanks need attention. In any case, make sure to inspect the formatted code, and edit further or revert '
187-
. 'if needed. Third, the code can be analyzed by the "PG Critic Analyzer." This checks that the code uses '
188-
. 'modern features of PG, that it does not use old or deprecated features of PG, and offers advice on how '
189-
. 'to fix issues that are found.') =%>
187+
. 'if needed. Third, the code can be analyzed by the "PG Critic." This checks that the code does not use '
188+
. 'old or deprecated features of PG and conforms to current best-practices in problem authoring, and offers '
189+
. 'suggestions on how to fix issues that are found.') =%>
190190
</dd>
191191

192192
<dt><%= maketext('Save') %></dt>

0 commit comments

Comments
 (0)