Skip to content

Commit a20ab67

Browse files
committed
Add a "--pg-only" ("-p" for short) option to the bin/pg-critic.pl script.
If this option is set, only PG critic policy violations (those in the `Perl::Critic::Policy::PG` namespace) are shown and scored, and general Perl critic policies are ignored.
1 parent 5aefac9 commit a20ab67

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

bin/pg-critic.pl

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ =head1 SYNOPSIS
2020
include the details in the output for each file.
2121
-s|--strict Disable "## no critic" annotations and force all
2222
policies to be enforced.
23+
-p|--pg-only Only include PG critic policy violations and ignore
24+
general Perl critic policy violations (both for the
25+
score and display).
2326
-h|--help Show the help message.
2427
2528
=head1 DESCRIPTION
@@ -47,6 +50,7 @@ =head1 DESCRIPTION
4750
'o|output-file=s' => \my $filename,
4851
'n|no-details' => \my $noDetails,
4952
's|strict' => \my $force,
53+
'p|pg-only' => \my $pgOnly,
5054
'h|help' => \my $show_help
5155
);
5256
pod2usage(2) if $show_help;
@@ -82,6 +86,7 @@ (@violations)
8286

8387
for (@ARGV) {
8488
my @violations = critiquePGFile($_, $force);
89+
@violations = grep { $_->policy =~ /^Perl::Critic::Policy::PG::/ } @violations if $pgOnly;
8590

8691
my (@pgCriticViolations, @perlCriticViolations);
8792
if (!$noDetails) {
@@ -96,7 +101,10 @@ (@violations)
96101
score => scoreProblem(@violations),
97102
$noDetails
98103
? ()
99-
: (pgCriticViolations => \@pgCriticViolations, perlCriticViolations => \@perlCriticViolations)
104+
: (
105+
@pgCriticViolations ? (pgCriticViolations => \@pgCriticViolations) : (),
106+
@perlCriticViolations ? (perlCriticViolations => \@perlCriticViolations) : ()
107+
)
100108
}
101109
);
102110
}

0 commit comments

Comments
 (0)