Login
Vanquised can_be_disabled() method.
[gknop/Perl-Critic.git] / lib / Perl / Critic.pm
CommitLineData
6036a254 1##############################################################################
aaa8512c
JRT
2# $URL$
3# $Date$
4# $Author$
5# $Revision$
6036a254 6##############################################################################
aaa8512c 7
59b05e08
JRT
8package Perl::Critic;
9
df6dee2b 10use 5.006001;
59b05e08
JRT
11use strict;
12use warnings;
712f83ea 13
c680a9c9 14use English qw(-no_match_vars);
c680a9c9
ES
15use Readonly;
16
f7f62580
JRT
17use base qw(Exporter);
18
59b05e08 19use File::Spec;
389109ec 20use Scalar::Util qw(blessed);
c680a9c9
ES
21
22use PPI::Document;
23use PPI::Document::File;
24
558488f7 25use Perl::Critic::Exception::Configuration::Generic;
94472d4a 26use Perl::Critic::Exception::Parse qw{ throw_parse };
59b05e08 27use Perl::Critic::Config;
dc93df4f 28use Perl::Critic::Violation;
5bf96118 29use Perl::Critic::Document;
2ce0b9ee 30use Perl::Critic::Statistics;
1771d650 31use Perl::Critic::Utils qw{ :characters hashify };
59b05e08 32
6036a254 33#-----------------------------------------------------------------------------
f7f62580 34
173667ce 35our $VERSION = '1.093_01';
c680a9c9 36
70f3f307 37Readonly::Array our @EXPORT_OK => qw(critique);
f7f62580 38
6036a254 39#-----------------------------------------------------------------------------
dff08b70 40
59b05e08 41sub new {
59b05e08 42 my ( $class, %args ) = @_;
e01de056 43 my $self = bless {}, $class;
1e7b8681 44 $self->{_config} = $args{-config} || Perl::Critic::Config->new( %args );
2ce0b9ee 45 $self->{_stats} = Perl::Critic::Statistics->new();
59b05e08
JRT
46 return $self;
47}
48
6036a254 49#-----------------------------------------------------------------------------
59b05e08 50
dff08b70
JRT
51sub config {
52 my $self = shift;
53 return $self->{_config};
54}
59b05e08 55
6036a254 56#-----------------------------------------------------------------------------
59b05e08 57
dff08b70
JRT
58sub add_policy {
59 my ( $self, @args ) = @_;
60 #Delegate to Perl::Critic::Config
61 return $self->config()->add_policy( @args );
62}
59b05e08 63
6036a254 64#-----------------------------------------------------------------------------
dff08b70
JRT
65
66sub policies {
67 my $self = shift;
46a3f49d 68
dff08b70
JRT
69 #Delegate to Perl::Critic::Config
70 return $self->config()->policies();
59b05e08
JRT
71}
72
6036a254 73#-----------------------------------------------------------------------------
dff08b70 74
2ce0b9ee
JRT
75sub statistics {
76 my $self = shift;
77 return $self->{_stats};
78}
79
80#-----------------------------------------------------------------------------
81
6e7d6c9f 82sub critique { ##no critic (ArgUnpacking)
7ed796a7 83
f7f62580
JRT
84 #-------------------------------------------------------------------
85 # This subroutine can be called as an object method or as a static
86 # function. In the latter case, the first argument can be a
87 # hashref of configuration parameters that shall be used to create
88 # an object behind the scenes. Note that this object does not
89 # persist. In other words, it is not a singleton. Here are some
90 # of the ways this subroutine might get called:
91 #
92 # #Object style...
93 # $critic->critique( $code );
94 #
95 # #Functional style...
96 # critique( $code );
97 # critique( {}, $code );
98 # critique( {-foo => bar}, $code );
99 #------------------------------------------------------------------
100
101 my ( $self, $source_code ) = @_ >= 2 ? @_ : ( {}, $_[0] );
102 $self = ref $self eq 'HASH' ? __PACKAGE__->new(%{ $self }) : $self;
de2dc641 103 return if not defined $source_code; # If no code, then nothing to do.
59b05e08 104
fb1d7f95 105 my $doc = $self->_create_perl_critic_document($source_code);
576f6411 106
558488f7
ES
107 if ( 0 == $self->policies() ) {
108 Perl::Critic::Exception::Configuration::Generic->throw(
109 message => 'There are no enabled policies.',
110 )
111 }
112
576f6411
ES
113 return $self->_gather_violations($doc);
114}
115
576f6411
ES
116#=============================================================================
117# PRIVATE functions
118
119sub _create_perl_critic_document {
fb1d7f95 120 my ($self, $source_code) = @_;
576f6411 121
4e771b0b
JRT
122 # $source_code can be a file name, or a reference to a
123 # PPI::Document, or a reference to a scalar containing source
124 # code. In the last case, PPI handles the translation for us.
f7f62580 125
e58ec45b
JRT
126 my $doc = _is_ppi_doc( $source_code ) ? $source_code
127 : ref $source_code ? PPI::Document->new($source_code)
128 : PPI::Document::File->new($source_code);
59b05e08
JRT
129
130 # Bail on error
dc93df4f 131 if ( not defined $doc ) {
0e91e2bf
JRT
132 my $errstr = PPI::Document::errstr();
133 my $file = ref $source_code ? undef : $source_code;
94472d4a
ES
134 throw_parse
135 message => qq<Can't parse code: $errstr>,
136 file_name => $file;
59b05e08
JRT
137 }
138
139 # Pre-index location of each node (for speed)
140 $doc->index_locations();
141
5bf96118 142 # Wrap the doc in a caching layer
576f6411
ES
143 return Perl::Critic::Document->new($doc);
144}
145
146#-----------------------------------------------------------------------------
147
148sub _gather_violations {
149 my ($self, $doc) = @_;
5bf96118 150
1bef6e21
JRT
151 # Disable the magic shebang fix
152 my %is_line_disabled = _unfix_shebang($doc);
59b05e08 153
7ed796a7 154 # Filter exempt code, if desired
dc93df4f 155 if ( not $self->config->force() ) {
410cf90b 156 my @site_policies = $self->config->site_policy_names();
1bef6e21
JRT
157 %is_line_disabled = ( %is_line_disabled,
158 _filter_code($doc, @site_policies) );
7ed796a7 159 }
1e7b8681 160
e58ec45b 161 # Evaluate each policy
46a3f49d
ES
162 my @policies = $self->config->policies();
163 my @violations =
164 map { _critique( $_, $doc, \%is_line_disabled) } @policies;
dc93df4f 165
2ce0b9ee
JRT
166 # Accumulate statistics
167 $self->statistics->accumulate( $doc, \@violations );
168
e58ec45b
JRT
169 # If requested, rank violations by their severity and return the top N.
170 if ( @violations && (my $top = $self->config->top()) ) {
171 my $limit = @violations < $top ? $#violations : $top-1;
172 @violations = Perl::Critic::Violation::sort_by_severity(@violations);
173 @violations = ( reverse @violations )[ 0 .. $limit ]; #Slicing...
174 }
dc93df4f 175
e58ec45b
JRT
176 # Always return violations sorted by location
177 return Perl::Critic::Violation->sort_by_location(@violations);
178}
1bef6e21 179
576f6411 180#-----------------------------------------------------------------------------
1bef6e21 181
e58ec45b
JRT
182sub _is_ppi_doc {
183 my ($ref) = @_;
184 return blessed($ref) && $ref->isa('PPI::Document');
185}
dc93df4f 186
e58ec45b 187#-----------------------------------------------------------------------------
c70a9ff6 188
e58ec45b 189sub _critique {
e58ec45b 190 my ($policy, $doc, $is_line_disabled) = @_;
bb5a5c57 191
78afb6d4 192 return if not $policy->prepare_to_scan_document($doc);
bb5a5c57 193
6b79d701 194 my $maximum_violations = $policy->get_maximum_violations_per_document();
1771d650 195 my %policies_that_cannot_be_disabled = hashify(_policies_that_cannot_be_disabled());
6b79d701
ES
196
197 if (defined $maximum_violations && $maximum_violations == 0) {
198 return;
199 }
c70a9ff6 200
bb5a5c57 201 my @violations = ();
f409e8e7
ES
202 my $policy_name = $policy->get_long_name();
203
e58ec45b
JRT
204 TYPE:
205 for my $type ( $policy->applies_to() ) {
e01de056 206
e58ec45b
JRT
207 ELEMENT:
208 for my $element ( @{ $doc->find($type) || [] } ) {
209
210 # Evaluate the policy on this $element. A policy may
211 # return zero or more violations. We only want the
212 # violations that occur on lines that have not been
213 # disabled.
214
215 VIOLATION:
216 for my $violation ( $policy->violates( $element, $doc ) ) {
e58ec45b 217 my $line = $violation->location()->[0];
1c6e69da 218 if (exists $is_line_disabled->{$line}) {
05e2d404 219 next VIOLATION if $is_line_disabled->{$line}->{$policy_name}
1771d650 220 && not exists $policies_that_cannot_be_disabled{$policy_name};
05e2d404 221 next VIOLATION if $is_line_disabled->{$line}->{ALL}
1771d650 222 && not exists $policies_that_cannot_be_disabled{$policy_name};
1c6e69da 223 }
6b79d701 224
e58ec45b 225 push @violations, $violation;
6b79d701
ES
226 if (
227 defined $maximum_violations
228 and @violations >= $maximum_violations
229 ) {
230 last TYPE;
231 }
e58ec45b
JRT
232 }
233 }
e01de056
JRT
234 }
235
e58ec45b 236 return @violations;
59b05e08
JRT
237}
238
e58ec45b 239#-----------------------------------------------------------------------------
59b05e08
JRT
240
241sub _filter_code {
242
f4938b54 243 my ($doc, @site_policies)= @_;
682ce894 244
59b05e08 245 my $nodes_ref = $doc->find('PPI::Token::Comment') || return;
7ed796a7
JRT
246 my %disabled_lines;
247
682ce894
CD
248 _filter_shebang_line($nodes_ref, \%disabled_lines, \@site_policies);
249 _filter_other_lines($nodes_ref, \%disabled_lines, \@site_policies);
250 return %disabled_lines;
251}
252
253sub _filter_shebang_line {
254 my ($nodes_ref, $disabled_lines, $site_policies) = @_;
255
f135623f 256 my $shebang_no_critic = qr{\A [#]! .*? [#][#] \s* no \s+ critic}xms;
682ce894 257
1c6e69da
CD
258 # Special case for the very beginning of the file: allow "##no critic" after the shebang
259 if (0 < @{$nodes_ref}) {
260 my $loc = $nodes_ref->[0]->location;
261 if (1 == $loc->[0] && 1 == $loc->[1] && $nodes_ref->[0] =~ $shebang_no_critic) {
262 my $pragma = shift @{$nodes_ref};
682ce894
CD
263 for my $policy (_parse_nocritic_import($pragma, $site_policies)) {
264 $disabled_lines->{ 1 }->{$policy} = 1;
1c6e69da
CD
265 }
266 }
267 }
682ce894
CD
268 return;
269}
270
271sub _filter_other_lines {
272 my ($nodes_ref, $disabled_lines, $site_policies) = @_;
273
f135623f
ES
274 my $no_critic = qr{\A \s* [#][#] \s* no \s+ critic}xms;
275 my $use_critic = qr{\A \s* [#][#] \s* use \s+ critic}xms;
1c6e69da 276
59b05e08
JRT
277 PRAGMA:
278 for my $pragma ( grep { $_ =~ $no_critic } @{$nodes_ref} ) {
279
c70a9ff6
JRT
280 # Parse out the list of Policy names after the
281 # 'no critic' pragma. I'm thinking of this just
282 # like a an C<import> argument for real pragmas.
682ce894 283 my @no_policies = _parse_nocritic_import($pragma, $site_policies);
c70a9ff6
JRT
284
285 # Grab surrounding nodes to determine the context.
286 # This determines whether the pragma applies to
287 # the current line or the block that follows.
209eb6db
JRT
288 my $parent = $pragma->parent();
289 my $grandparent = $parent ? $parent->parent() : undef;
290 my $sib = $pragma->sprevious_sibling();
291
c70a9ff6 292
209eb6db
JRT
293 # Handle single-line usage on simple statements
294 if ( $sib && $sib->location->[0] == $pragma->location->[0] ) {
c70a9ff6
JRT
295 my $line = $pragma->location->[0];
296 for my $policy ( @no_policies ) {
682ce894 297 $disabled_lines->{ $line }->{$policy} = 1;
c70a9ff6 298 }
209eb6db
JRT
299 next PRAGMA;
300 }
301
302
303 # Handle single-line usage on compound statements
304 if ( ref $parent eq 'PPI::Structure::Block' ) {
5c1bf20d
JRT
305 if ( ref $grandparent eq 'PPI::Statement::Compound'
306 || ref $grandparent eq 'PPI::Statement::Sub' ) {
209eb6db 307 if ( $parent->location->[0] == $pragma->location->[0] ) {
c70a9ff6
JRT
308 my $line = $grandparent->location->[0];
309 for my $policy ( @no_policies ) {
682ce894 310 $disabled_lines->{ $line }->{$policy} = 1;
c70a9ff6 311 }
209eb6db
JRT
312 next PRAGMA;
313 }
59b05e08
JRT
314 }
315 }
316
209eb6db
JRT
317
318 # Handle multi-line usage. This is either a "no critic" ..
319 # "use critic" region or a block where "no critic" persists
320 # until the end of the scope. The start is the always the "no
321 # critic" which we already found. So now we have to search
322 # for the end.
7ed796a7
JRT
323
324 my $start = $pragma;
325 my $end = $pragma;
326
59b05e08 327 SIB:
f491464e
CD
328 while ( my $esib = $end->next_sibling() ) {
329 $end = $esib; # keep track of last sibling encountered in this scope
7ed796a7 330 last SIB
f491464e 331 if $esib->isa('PPI::Token::Comment') && $esib =~ $use_critic;
7ed796a7
JRT
332 }
333
334 # We either found an end or hit the end of the scope.
335 # Flag all intervening lines
336 for my $line ( $start->location->[0] .. $end->location->[0] ) {
c70a9ff6 337 for my $policy ( @no_policies ) {
682ce894 338 $disabled_lines->{ $line }->{$policy} = 1;
c70a9ff6 339 }
59b05e08 340 }
59b05e08 341 }
dff08b70 342
682ce894 343 return;
59b05e08 344}
dff08b70 345
6036a254 346#-----------------------------------------------------------------------------
7ed796a7 347
c70a9ff6
JRT
348sub _parse_nocritic_import {
349
1c6e69da 350 my ($pragma, $site_policies) = @_;
c70a9ff6 351
f135623f
ES
352 my $module = qr{ [\w:]+ }xms;
353 my $delim = qr{ \s* [,\s] \s* }xms;
354 my $qw = qr{ (?: qw )? }xms;
355 my $qualifier = qr{ $qw [(]? \s* ( $module (?: $delim $module)* ) \s* [)]? }xms;
356 my $no_critic = qr{ \#\# \s* no \s+ critic \s* $qualifier }xms; ##no critic(EscapedMetacharacters)
1bef6e21 357
c48094aa 358 if ( my ($module_list) = $pragma =~ $no_critic ) {
c0137eab 359 my @modules = split $delim, $module_list;
369abea9
CD
360
361 # Compose the specified modules into a regex alternation. Wrap each
362 # in a no-capturing group to permit "|" in the modules specification
363 # (backward compatibility)
364 my $re = join q{|}, map {"(?:$_)"} @modules;
f135623f 365 return grep {m/$re/ixms} @{$site_policies};
c70a9ff6
JRT
366 }
367
a9c73f99 368 # Default to disabling ALL policies.
c70a9ff6
JRT
369 return qw(ALL);
370}
371
6036a254 372#-----------------------------------------------------------------------------
59b05e08
JRT
373sub _unfix_shebang {
374
0e91e2bf
JRT
375 # When you install a script using ExtUtils::MakeMaker or Module::Build, it
376 # inserts some magical code into the top of the file (just after the
377 # shebang). This code allows people to call your script using a shell,
378 # like `sh my_script`. Unfortunately, this code causes several Policy
379 # violations, so we just disable it as if a "## no critic" comment had
380 # been attached.
59b05e08 381
7ed796a7 382 my $doc = shift;
59b05e08
JRT
383 my $first_stmnt = $doc->schild(0) || return;
384
f135623f 385 # Different versions of MakeMaker and Build use slightly different shebang
0e91e2bf
JRT
386 # fixing strings. This matches most of the ones I've found in my own Perl
387 # distribution, but it may not be bullet-proof.
59b05e08 388
f135623f 389 my $fixin_rx = qr{^eval 'exec .* \$0 \${1\+"\$@"}'\s*[\r\n]\s*if.+;}ms; ## no critic (RequireExtendedFormatting)
7ed796a7 390 if ( $first_stmnt =~ $fixin_rx ) {
1bef6e21 391 my $line = $first_stmnt->location()->[0];
c70a9ff6 392 return ( $line => {ALL => 1}, $line + 1 => {ALL => 1} );
7ed796a7 393 }
dff08b70 394
1bef6e21 395 #No magic shebang was found!
7ed796a7 396 return;
59b05e08
JRT
397}
398
0e91e2bf 399#-----------------------------------------------------------------------------
0e91e2bf 400
1771d650
JRT
401sub _policies_that_cannot_be_disabled {
402 # This is a special list of policies that cannot
403 # be disabled by the "no critic" pseudo-pragma.
404
405 return qw(
406 Perl::Critic::Policy::Miscellanea::ProhibitUnrestrictedNoCritic
407 );
408}
59b05e08 409
6036a254 410#-----------------------------------------------------------------------------
59b05e08 411
1771d650
JRT
4121;
413
414
415
59b05e08
JRT
416__END__
417
418=pod
419
c296c678 420=for stopwords DGR INI-style API -params pbp refactored ActivePerl
369abea9 421ben Jore Dolan's
821d0eb5 422
59b05e08
JRT
423=head1 NAME
424
c728943a 425Perl::Critic - Critique Perl source code for best-practices.
59b05e08 426
df89052a 427
59b05e08
JRT
428=head1 SYNOPSIS
429
430 use Perl::Critic;
6bf9b465
JRT
431 my $file = shift;
432 my $critic = Perl::Critic->new();
433 my @violations = $critic->critique($file);
434 print @violations;
59b05e08 435
df89052a 436
59b05e08
JRT
437=head1 DESCRIPTION
438
11f53956
ES
439Perl::Critic is an extensible framework for creating and applying
440coding standards to Perl source code. Essentially, it is a static
441source code analysis engine. Perl::Critic is distributed with a
442number of L<Perl::Critic::Policy|Perl::Critic::Policy> modules that
443attempt to enforce various coding guidelines. Most Policy modules are
444based on Damian Conway's book B<Perl Best Practices>. However,
445Perl::Critic is B<not> limited to PBP and will even support Policies
446that contradict Conway. You can enable, disable, and customize those
447Polices through the Perl::Critic interface. You can also create new
448Policy modules that suit your own tastes.
449
450For a command-line interface to Perl::Critic, see the documentation
451for L<perlcritic|perlcritic>. If you want to integrate Perl::Critic
452with your build process, L<Test::Perl::Critic|Test::Perl::Critic>
453provides an interface that is suitable for test scripts. Also,
454L<Test::Perl::Critic::Progressive|Test::Perl::Critic::Progressive> is
455useful for gradually applying coding standards to legacy code. For
456the ultimate convenience (at the expense of some flexibility) see the
457L<criticism|criticism> pragma.
458
459Win32 and ActivePerl users can find PPM distributions of Perl::Critic
460at L<http://theoryx5.uwinnipeg.ca/ppms/>.
461
462If you'd like to try L<Perl::Critic|Perl::Critic> without installing
463anything, there is a web-service available at
464L<http://perlcritic.com>. The web-service does not yet support all
465the configuration features that are available in the native
466Perl::Critic API, but it should give you a good idea of what it does.
467You can also invoke the perlcritic web-service from the command-line
468by doing an HTTP-post, such as one of these:
e518ead4 469
7711a331
JRT
470 $> POST http://perlcritic.com/perl/critic.pl < MyModule.pm
471 $> lwp-request -m POST http://perlcritic.com/perl/critic.pl < MyModule.pm
472 $> wget -q -O - --post-file=MyModule.pm http://perlcritic.com/perl/critic.pl
e518ead4 473
11f53956
ES
474Please note that the perlcritic web-service is still alpha code. The
475URL and interface to the service are subject to change.
8d36cd6f 476
df89052a 477
59b05e08
JRT
478=head1 CONSTRUCTOR
479
df89052a 480=over
59b05e08 481
89b50090 482=item C<< new( [ -profile => $FILE, -severity => $N, -theme => $string, -include => \@PATTERNS, -exclude => \@PATTERNS, -top => $N, -only => $B, -profile-strictness => $PROFILE_STRICTNESS_{WARN|FATAL|QUIET}, -force => $B, -verbose => $N ], -color => $B, -pager => $string, -criticism-fatal => $B) >>
7b84ff16 483
7b84ff16 484=item C<< new() >>
59b05e08 485
11f53956
ES
486Returns a reference to a new Perl::Critic object. Most arguments are
487just passed directly into
488L<Perl::Critic::Config|Perl::Critic::Config>, but I have described
489them here as well. The default value for all arguments can be defined
490in your F<.perlcriticrc> file. See the L<"CONFIGURATION"> section for
491more information about that. All arguments are optional key-value
492pairs as follows:
493
494B<-profile> is a path to a configuration file. If C<$FILE> is not
495defined, Perl::Critic::Config attempts to find a F<.perlcriticrc>
496configuration file in the current directory, and then in your home
497directory. Alternatively, you can set the C<PERLCRITIC> environment
498variable to point to a file in another location. If a configuration
499file can't be found, or if C<$FILE> is an empty string, then all
500Policies will be loaded with their default configuration. See
501L<"CONFIGURATION"> for more information.
502
503B<-severity> is the minimum severity level. Only Policy modules that
504have a severity greater than C<$N> will be applied. Severity values
505are integers ranging from 1 (least severe) to 5 (most severe). The
506default is 5. For a given C<-profile>, decreasing the C<-severity>
507will usually reveal more Policy violations. You can set the default
508value for this option in your F<.perlcriticrc> file. Users can
509redefine the severity level for any Policy in their F<.perlcriticrc>
510file. See L<"CONFIGURATION"> for more information.
511
512If it is difficult for you to remember whether severity "5" is the
513most or least restrictive level, then you can use one of these named
514values:
097f3455 515
7711a331 516 SEVERITY NAME ...is equivalent to... SEVERITY NUMBER
097f3455
JRT
517 --------------------------------------------------------
518 -severity => 'gentle' -severity => 5
519 -severity => 'stern' -severity => 4
520 -severity => 'harsh' -severity => 3
521 -severity => 'cruel' -severity => 2
522 -severity => 'brutal' -severity => 1
523
11f53956
ES
524B<-theme> is special expression that determines which Policies to
525apply based on their respective themes. For example, the following
526would load only Policies that have a 'bugs' AND 'pbp' theme:
7b84ff16 527
1c5955e4
JRT
528 my $critic = Perl::Critic->new( -theme => 'bugs && pbp' );
529
11f53956
ES
530Unless the C<-severity> option is explicitly given, setting C<-theme>
531silently causes the C<-severity> to be set to 1. You can set the
532default value for this option in your F<.perlcriticrc> file. See the
533L<"POLICY THEMES"> section for more information about themes.
7b84ff16 534
7b84ff16 535
11f53956 536B<-include> is a reference to a list of string C<@PATTERNS>. Policy
f135623f 537modules that match at least one C<m/$PATTERN/ixms> will always be
11f53956 538loaded, irrespective of all other settings. For example:
6bf9b465
JRT
539
540 my $critic = Perl::Critic->new(-include => ['layout'] -severity => 4);
541
11f53956
ES
542This would cause Perl::Critic to apply all the C<CodeLayout::*> Policy
543modules even though they have a severity level that is less than 4.
544You can set the default value for this option in your F<.perlcriticrc>
545file. You can also use C<-include> in conjunction with the
546C<-exclude> option. Note that C<-exclude> takes precedence over
547C<-include> when a Policy matches both patterns.
6bf9b465 548
11f53956 549B<-exclude> is a reference to a list of string C<@PATTERNS>. Policy
f135623f 550modules that match at least one C<m/$PATTERN/ixms> will not be loaded,
11f53956 551irrespective of all other settings. For example:
6bf9b465
JRT
552
553 my $critic = Perl::Critic->new(-exclude => ['strict'] -severity => 1);
554
1edbd692 555This would cause Perl::Critic to not apply the C<RequireUseStrict> and
11f53956
ES
556C<ProhibitNoStrict> Policy modules even though they have a severity
557level that is greater than 1. You can set the default value for this
558option in your F<.perlcriticrc> file. You can also use C<-exclude> in
559conjunction with the C<-include> option. Note that C<-exclude> takes
560precedence over C<-include> when a Policy matches both patterns.
561
562B<-single-policy> is a string C<PATTERN>. Only one policy that
f135623f 563matches C<m/$PATTERN/ixms> will be used. Policies that do not match
11f53956
ES
564will be excluded. This option has precedence over the C<-severity>,
565C<-theme>, C<-include>, C<-exclude>, and C<-only> options. You can
566set the default value for this option in your F<.perlcriticrc> file.
567
568B<-top> is the maximum number of Violations to return when ranked by
569their severity levels. This must be a positive integer. Violations
570are still returned in the order that they occur within the file.
571Unless the C<-severity> option is explicitly given, setting C<-top>
572silently causes the C<-severity> to be set to 1. You can set the
573default value for this option in your F<.perlcriticrc> file.
574
575B<-only> is a boolean value. If set to a true value, Perl::Critic
576will only choose from Policies that are mentioned in the user's
577profile. If set to a false value (which is the default), then
578Perl::Critic chooses from all the Policies that it finds at your site.
579You can set the default value for this option in your F<.perlcriticrc>
580file.
e01de056 581
9f12283e
ES
582B<-profile-strictness> is an enumerated value, one of
583L<Perl::Critic::Utils::Constants/"$PROFILE_STRICTNESS_WARN"> (the
584default),
585L<Perl::Critic::Utils::Constants/"$PROFILE_STRICTNESS_FATAL">, and
586L<Perl::Critic::Utils::Constants/"$PROFILE_STRICTNESS_QUIET">. If set
587to L<Perl::Critic::Utils::Constants/"$PROFILE_STRICTNESS_FATAL">,
588Perl::Critic will make certain warnings about problems found in a
589F<.perlcriticrc> or file specified via the B<-profile> option fatal.
590For example, Perl::Critic normally only C<warn>s about profiles
591referring to non-existent Policies, but this value makes this
592situation fatal. Correspondingly,
593L<Perl::Critic::Utils::Constants/"$PROFILE_STRICTNESS_QUIET"> makes
594Perl::Critic shut up about these things.
66186ba3 595
11f53956
ES
596B<-force> is a boolean value that controls whether Perl::Critic
597observes the magical C<"## no critic"> pseudo-pragmas in your code.
598If set to a true value, Perl::Critic will analyze all code. If set to
599a false value (which is the default) Perl::Critic will ignore code
600that is tagged with these comments. See L<"BENDING THE RULES"> for
601more information. You can set the default value for this option in
602your F<.perlcriticrc> file.
59b05e08 603
11f53956
ES
604B<-verbose> can be a positive integer (from 1 to 11), or a literal
605format specification. See
606L<Perl::Critic::Violation|Perl::Critic::Violation> for an explanation
607of format specifications. You can set the default value for this
608option in your F<.perlcriticrc> file.
7b84ff16 609
89b50090 610B<-color> and B<-pager> are not used by Perl::Critic but is provided for the benefit
11f53956 611of L<perlcritic|perlcritic>.
25792f52 612
11f53956
ES
613B<-criticism-fatal> is not used by Perl::Critic but is provided for
614the benefit of L<criticism|criticism>.
badbf753 615
59b05e08
JRT
616=back
617
df89052a 618
59b05e08
JRT
619=head1 METHODS
620
df89052a 621=over
59b05e08 622
6d9feae6 623=item C<critique( $source_code )>
1e7b8681
JRT
624
625Runs the C<$source_code> through the Perl::Critic engine using all the
11f53956
ES
626Policies that have been loaded into this engine. If C<$source_code>
627is a scalar reference, then it is treated as a string of actual Perl
628code. If C<$source_code> is a reference to an instance of
629L<PPI::Document|PPI::Document>, then that instance is used directly.
630Otherwise, it is treated as a path to a local file containing Perl
631code. This method returns a list of
632L<Perl::Critic::Violation|Perl::Critic::Violation> objects for each
633violation of the loaded Policies. The list is sorted in the order
634that the Violations appear in the code. If there are no violations,
635this method returns an empty list.
1e7b8681 636
520f00c6 637=item C<< add_policy( -policy => $policy_name, -params => \%param_hash ) >>
59b05e08 638
11f53956
ES
639Creates a Policy object and loads it into this Critic. If the object
640cannot be instantiated, it will throw a fatal exception. Otherwise,
641it returns a reference to this Critic.
59b05e08 642
11f53956
ES
643B<-policy> is the name of a
644L<Perl::Critic::Policy|Perl::Critic::Policy> subclass module. The
645C<'Perl::Critic::Policy'> portion of the name can be omitted for
646brevity. This argument is required.
59b05e08 647
11f53956
ES
648B<-params> is an optional reference to a hash of Policy parameters.
649The contents of this hash reference will be passed into to the
650constructor of the Policy module. See the documentation in the
651relevant Policy module for a description of the arguments it supports.
59b05e08 652
dc93df4f 653=item C< policies() >
59b05e08 654
11f53956
ES
655Returns a list containing references to all the Policy objects that
656have been loaded into this engine. Objects will be in the order that
657they were loaded.
59b05e08 658
dc93df4f 659=item C< config() >
dff08b70 660
11f53956
ES
661Returns the L<Perl::Critic::Config|Perl::Critic::Config> object that
662was created for or given to this Critic.
dff08b70 663
2ce0b9ee
JRT
664=item C< statistics() >
665
11f53956
ES
666Returns the L<Perl::Critic::Statistics|Perl::Critic::Statistics>
667object that was created for this Critic. The Statistics object
668accumulates data for all files that are analyzed by this Critic.
2ce0b9ee 669
59b05e08
JRT
670=back
671
df89052a 672
f7f62580
JRT
673=head1 FUNCTIONAL INTERFACE
674
11f53956
ES
675For those folks who prefer to have a functional interface, The
676C<critique> method can be exported on request and called as a static
677function. If the first argument is a hashref, its contents are used
678to construct a new Perl::Critic object internally. The keys of that
679hash should be the same as those supported by the C<Perl::Critic::new>
680method. Here are some examples:
f7f62580
JRT
681
682 use Perl::Critic qw(critique);
683
684 # Use default parameters...
685 @violations = critique( $some_file );
686
687 # Use custom parameters...
688 @violations = critique( {-severity => 2}, $some_file );
689
d47377d5
JRT
690 # As a one-liner
691 %> perl -MPerl::Critic=critique -e 'print critique(shift)' some_file.pm
692
f7f62580
JRT
693None of the other object-methods are currently supported as static
694functions. Sorry.
695
df89052a 696
59b05e08
JRT
697=head1 CONFIGURATION
698
11f53956
ES
699Most of the settings for Perl::Critic and each of the Policy modules
700can be controlled by a configuration file. The default configuration
701file is called F<.perlcriticrc>. Perl::Critic will look for this file
702in the current directory first, and then in your home directory.
703Alternatively, you can set the C<PERLCRITIC> environment variable to
704explicitly point to a different file in another location. If none of
705these files exist, and the C<-profile> option is not given to the
706constructor, then all the modules that are found in the
7b84ff16
JRT
707Perl::Critic::Policy namespace will be loaded with their default
708configuration.
709
11f53956
ES
710The format of the configuration file is a series of INI-style blocks
711that contain key-value pairs separated by '='. Comments should start
712with '#' and can be placed on a separate line or after the name-value
713pairs if you desire.
7b84ff16 714
11f53956
ES
715Default settings for Perl::Critic itself can be set B<before the first
716named block.> For example, putting any or all of these at the top of
717your configuration file will set the default value for the
718corresponding constructor argument.
7b84ff16 719
097f3455 720 severity = 3 #Integer or named level
c3b1b521
JRT
721 only = 1 #Zero or One
722 force = 0 #Zero or One
723 verbose = 4 #Integer or format spec
724 top = 50 #A positive integer
1edbd692 725 theme = (pbp || security) && bugs #A theme expression
c3b1b521
JRT
726 include = NamingConventions ClassHierarchies #Space-delimited list
727 exclude = Variables Modules::RequirePackage #Space-delimited list
badbf753 728 criticism-fatal = 1 #Zero or One
51ae9d9b 729 color = 1 #Zero or One
89b50090 730 pager = less #pager to pipe output to
7b84ff16 731
11f53956
ES
732The remainder of the configuration file is a series of blocks like
733this:
59b05e08 734
7b84ff16
JRT
735 [Perl::Critic::Policy::Category::PolicyName]
736 severity = 1
4cd0567c 737 set_themes = foo bar
c94fb804 738 add_themes = baz
35ab5036 739 maximum_violations_per_document = 57
7b84ff16
JRT
740 arg1 = value1
741 arg2 = value2
59b05e08 742
11f53956
ES
743C<Perl::Critic::Policy::Category::PolicyName> is the full name of a
744module that implements the policy. The Policy modules distributed
745with Perl::Critic have been grouped into categories according to the
746table of contents in Damian Conway's book B<Perl Best Practices>. For
747brevity, you can omit the C<'Perl::Critic::Policy'> part of the module
748name.
749
750C<severity> is the level of importance you wish to assign to the
751Policy. All Policy modules are defined with a default severity value
752ranging from 1 (least severe) to 5 (most severe). However, you may
753disagree with the default severity and choose to give it a higher or
754lower severity, based on your own coding philosophy. You can set the
755C<severity> to an integer from 1 to 5, or use one of the equivalent
756names:
097f3455 757
7711a331 758 SEVERITY NAME ...is equivalent to... SEVERITY NUMBER
097f3455
JRT
759 ----------------------------------------------------
760 gentle 5
761 stern 4
762 harsh 3
763 cruel 2
764 brutal 1
765
11f53956
ES
766C<set_themes> sets the theme for the Policy and overrides its default
767theme. The argument is a string of one or more whitespace-delimited
768alphanumeric words. Themes are case-insensitive. See L<"POLICY
769THEMES"> for more information.
097f3455 770
11f53956
ES
771C<add_themes> appends to the default themes for this Policy. The
772argument is a string of one or more whitespace-delimited words.
773Themes are case-insensitive. See L<"POLICY THEMES"> for more
774information.
59b05e08 775
11f53956
ES
776C<maximum_violations_per_document> limits the number of Violations the
777Policy will return for a given document. Some Policies have a default
778limit; see the documentation for the individual Policies to see
779whether there is one. To force a Policy to not have a limit, specify
780"no_limit" or the empty string for the value of this parameter.
35ab5036 781
11f53956
ES
782The remaining key-value pairs are configuration parameters that will
783be passed into the constructor for that Policy. The constructors for
784most Policy objects do not support arguments, and those that do should
785have reasonable defaults. See the documentation on the appropriate
786Policy module for more details.
59b05e08 787
11f53956
ES
788Instead of redefining the severity for a given Policy, you can
789completely disable a Policy by prepending a '-' to the name of the
790module in your configuration file. In this manner, the Policy will
791never be loaded, regardless of the C<-severity> given to the
792Perl::Critic constructor.
59b05e08
JRT
793
794A simple configuration might look like this:
795
7b84ff16
JRT
796 #--------------------------------------------------------------
797 # I think these are really important, so always load them
798
799 [TestingAndDebugging::RequireUseStrict]
800 severity = 5
59b05e08 801
7b84ff16
JRT
802 [TestingAndDebugging::RequireUseWarnings]
803 severity = 5
59b05e08 804
7b84ff16
JRT
805 #--------------------------------------------------------------
806 # I think these are less important, so only load when asked
59b05e08 807
7b84ff16
JRT
808 [Variables::ProhibitPackageVars]
809 severity = 2
59b05e08 810
7b84ff16 811 [ControlStructures::ProhibitPostfixControls]
097f3455
JRT
812 allow = if unless # My custom configuration
813 severity = cruel # Same as "severity = 2"
59b05e08 814
7b84ff16
JRT
815 #--------------------------------------------------------------
816 # Give these policies a custom theme. I can activate just
817 # these policies by saying `perlcritic -theme larry`
59b05e08 818
7b84ff16 819 [Modules::RequireFilenameMatchesPackage]
c94fb804 820 add_themes = larry
59b05e08 821
7b84ff16 822 [TestingAndDebugging::RequireTestLables]
c94fb804 823 add_themes = larry curly moe
59b05e08 824
7b84ff16
JRT
825 #--------------------------------------------------------------
826 # I do not agree with these at all, so never load them
1e7b8681 827
7b84ff16
JRT
828 [-NamingConventions::ProhibitMixedCaseVars]
829 [-NamingConventions::ProhibitMixedCaseSubs]
830
831 #--------------------------------------------------------------
832 # For all other Policies, I accept the default severity,
833 # so no additional configuration is required for them.
8bc162ba 834
b87fc7eb 835For additional configuration examples, see the F<perlcriticrc> file
16cfe89e 836that is included in this F<examples> directory of this distribution.
b87fc7eb 837
11f53956
ES
838Damian Conway's own Perl::Critic configuration is also included in
839this distribution as F<examples/perlcriticrc-conway>.
e87a2153 840
df89052a 841
59b05e08
JRT
842=head1 THE POLICIES
843
11f53956
ES
844A large number of Policy modules are distributed with Perl::Critic.
845They are described briefly in the companion document
846L<Perl::Critic::PolicySummary|Perl::Critic::PolicySummary> and in more
847detail in the individual modules themselves. Say C<"perlcritic -doc
848PATTERN"> to see the perldoc for all Policy modules that match the
f135623f 849regex C<m/PATTERN/ixms>
38ce10c1 850
11f53956
ES
851There are a number of distributions of additional policies on CPAN.
852If L<Perl::Critic|Perl::Critic> doesn't contain a policy that you
853want, some one may have already written it. See the L</"SEE ALSO">
854section below for a list of some of these distributions.
a41e8614 855
7b84ff16 856
7711a331 857=head1 POLICY THEMES
2c2751eb 858
11f53956
ES
859Each Policy is defined with one or more "themes". Themes can be used
860to create arbitrary groups of Policies. They are intended to provide
861an alternative mechanism for selecting your preferred set of Policies.
862For example, you may wish disable a certain subset of Policies when
863analyzing test scripts. Conversely, you may wish to enable only a
864specific subset of Policies when analyzing modules.
7b84ff16 865
c8dbb393 866The Policies that ship with Perl::Critic are have been broken into the
11f53956
ES
867following themes. This is just our attempt to provide some basic
868logical groupings. You are free to invent new themes that suit your
869needs.
c8dbb393
JRT
870
871 THEME DESCRIPTION
872 --------------------------------------------------------------------------
873 core All policies that ship with Perl::Critic
874 pbp Policies that come directly from "Perl Best Practices"
875 bugs Policies that that prevent or reveal bugs
876 maintenance Policies that affect the long-term health of the code
877 cosmetic Policies that only have a superficial effect
878 complexity Policies that specificaly relate to code complexity
7711a331 879 security Policies that relate to security issues
c8dbb393
JRT
880 tests Policies that are specific to test scripts
881
882
11f53956
ES
883Any Policy may fit into multiple themes. Say C<"perlcritic -list"> to
884get a listing of all available Policies and the themes that are
885associated with each one. You can also change the theme for any
886Policy in your F<.perlcriticrc> file. See the L<"CONFIGURATION">
887section for more information about that.
7b84ff16 888
11f53956
ES
889Using the C<-theme> option, you can create an arbitrarily complex rule
890that determines which Policies will be loaded. Precedence is the same
891as regular Perl code, and you can use parentheses to enforce
892precedence as well. Supported operators are:
7b84ff16 893
14d80662 894 Operator Altertative Example
c3b1b521 895 ----------------------------------------------------------------------------
14d80662
JRT
896 && and 'pbp && core'
897 || or 'pbp || (bugs && security)'
898 ! not 'pbp && ! (portability || complexity)'
7b84ff16 899
11f53956
ES
900Theme names are case-insensitive. If the C<-theme> is set to an empty
901string, then it evaluates as true all Policies.
7b84ff16 902
df89052a 903
59b05e08
JRT
904=head1 BENDING THE RULES
905
11f53956
ES
906Perl::Critic takes a hard-line approach to your code: either you
907comply or you don't. In the real world, it is not always practical
908(nor even possible) to fully comply with coding standards. In such
909cases, it is wise to show that you are knowingly violating the
910standards and that you have a Damn Good Reason (DGR) for doing so.
59b05e08 911
11f53956
ES
912To help with those situations, you can direct Perl::Critic to ignore
913certain lines or blocks of code by using pseudo-pragmas:
59b05e08
JRT
914
915 require 'LegacyLibaray1.pl'; ## no critic
916 require 'LegacyLibrary2.pl'; ## no critic
917
918 for my $element (@list) {
919
920 ## no critic
921
922 $foo = ""; #Violates 'ProhibitEmptyQuotes'
923 $barf = bar() if $foo; #Violates 'ProhibitPostfixControls'
924 #Some more evil code...
925
926 ## use critic
927
928 #Some good code...
929 do_something($_);
930 }
931
11f53956
ES
932The C<"## no critic"> comments direct Perl::Critic to ignore the
933remaining lines of code until the end of the current block, or until a
934C<"## use critic"> comment is found (whichever comes first). If the
935C<"## no critic"> comment is on the same line as a code statement,
936then only that line of code is overlooked. To direct perlcritic to
937ignore the C<"## no critic"> comments, use the C<-force> option.
938
939A bare C<"## no critic"> comment disables all the active Policies. If
940you wish to disable only specific Policies, add a list of Policy names
941as arguments, just as you would for the C<"no strict"> or C<"no
942warnings"> pragmas. For example, this would disable the
943C<ProhibitEmptyQuotes> and C<ProhibitPostfixControls> policies until
944the end of the block or until the next C<"## use critic"> comment
945(whichever comes first):
c70a9ff6 946
c48094aa 947 ## no critic (EmptyQuotes, PostfixControls)
c70a9ff6 948
7711a331
JRT
949 # Now exempt from ValuesAndExpressions::ProhibitEmptyQuotes
950 $foo = "";
951
952 # Now exempt ControlStructures::ProhibitPostfixControls
953 $barf = bar() if $foo;
c70a9ff6 954
7711a331
JRT
955 # Still subjected to ValuesAndExpression::RequireNumberSeparators
956 $long_int = 10000000000;
957
11f53956
ES
958Since the Policy names are matched against the C<"## no critic">
959arguments as regular expressions, you can abbreviate the Policy names
960or disable an entire family of Policies in one shot like this:
c70a9ff6 961
c48094aa 962 ## no critic (NamingConventions)
c70a9ff6 963
7711a331
JRT
964 # Now exempt from NamingConventions::ProhibitMixedCaseVars
965 my $camelHumpVar = 'foo';
966
967 # Now exempt from NamingConventions::ProhibitMixedCaseSubs
968 sub camelHumpSub {}
c70a9ff6 969
11f53956
ES
970The argument list must be enclosed in parentheses and must contain one
971or more comma-separated barewords (e.g. don't use quotes). The
972C<"## no critic"> pragmas can be nested, and Policies named by an
973inner pragma will be disabled along with those already disabled an
974outer pragma.
c70a9ff6 975
11f53956
ES
976Some Policies like C<Subroutines::ProhibitExcessComplexity> apply to
977an entire block of code. In those cases, C<"## no critic"> must
978appear on the line where the violation is reported. For example:
35892a39
JRT
979
980 sub complicated_function { ## no critic (ProhibitExcessComplexity)
981 # Your code here...
982 }
983
11f53956
ES
984Policies such as C<Documentation::RequirePodSections> apply to the
985entire document, in which case violations are reported at line 1.
35892a39 986
11f53956
ES
987Use this feature wisely. C<"## no critic"> should be used in the
988smallest possible scope, or only on individual lines of code. And you
989should always be as specific as possible about which policies you want
990to disable (i.e. never use a bare C<"## no critic">). If Perl::Critic
991complains about your code, try and find a compliant solution before
992resorting to this feature.
1c5955e4 993
1bef6e21 994
11f53956 995=head1 THE L<Perl::Critic|Perl::Critic> PHILOSOPHY
b87b00dd 996
11f53956
ES
997Coding standards are deeply personal and highly subjective. The goal
998of Perl::Critic is to help you write code that conforms with a set of
999best practices. Our primary goal is not to dictate what those
1000practices are, but rather, to implement the practices discovered by
1001others. Ultimately, you make the rules -- Perl::Critic is merely a
1002tool for encouraging consistency. If there is a policy that you think
1003is important or that we have overlooked, we would be very grateful for
1004contributions, or you can simply load your own private set of policies
1005into Perl::Critic.
b87b00dd 1006
df89052a 1007
59b05e08
JRT
1008=head1 EXTENDING THE CRITIC
1009
11f53956
ES
1010The modular design of Perl::Critic is intended to facilitate the
1011addition of new Policies. You'll need to have some understanding of
1012L<PPI|PPI>, but most Policy modules are pretty straightforward and
1013only require about 20 lines of code. Please see the
1014L<Perl::Critic::DEVELOPER|Perl::Critic::DEVELOPER> file included in
1015this distribution for a step-by-step demonstration of how to create
1016new Policy modules.
59b05e08 1017
524bce7c 1018If you develop any new Policy modules, feel free to send them to C<<
11f53956
ES
1019<thaljef@cpan.org> >> and I'll be happy to put them into the
1020Perl::Critic distribution. Or if you would like to work on the
1021Perl::Critic project directly, check out our repository at
1022L<http://perlcritic.tigris.org>. To subscribe to our mailing list,
1023send a message to C<< <dev-subscribe@perlcritic.tigris.org> >>.
524bce7c 1024
11f53956
ES
1025The Perl::Critic team is also available for hire. If your
1026organization has its own coding standards, we can create custom
1027Policies to enforce your local guidelines. Or if your code base is
1028prone to a particular defect pattern, we can design Policies that will
1029help you catch those costly defects B<before> they go into production.
1030To discuss your needs with the Perl::Critic team, just contact C<<
1031<thaljef@cpan.org> >>.
59b05e08 1032
df89052a 1033
59b05e08
JRT
1034=head1 PREREQUISITES
1035
1036Perl::Critic requires the following modules:
1037
11f53956 1038L<B::Keywords|B::Keywords>
1edbd692 1039
11f53956 1040L<Config::Tiny|Config::Tiny>
59b05e08 1041
11f53956 1042L<Exception::Class|Exception::Class>
f7bb182e 1043
11f53956 1044L<File::Spec|File::Spec>
59b05e08 1045
11f53956 1046L<File::Spec::Unix|File::Spec::Unix>
1e7b8681 1047
11f53956 1048L<IO::String|IO::String>
59b05e08 1049
11f53956 1050L<List::MoreUtils|List::MoreUtils>
59b05e08 1051
11f53956 1052L<List::Util|List::Util>
f7bb182e 1053
11f53956 1054L<Module::Pluggable|Module::Pluggable>
1e7b8681 1055
11f53956 1056L<PPI|PPI>
1e7b8681 1057
11f53956 1058L<Pod::PlainText|Pod::PlainText>
a60e94d6 1059
11f53956 1060L<Pod::Usage|Pod::Usage>
59b05e08 1061
11f53956 1062L<Readonly|Readonly>
59b05e08 1063
11f53956 1064L<Scalar::Util|Scalar::Util>
f7bb182e 1065
11f53956 1066L<String::Format|String::Format>
59b05e08 1067
11f53956 1068L<version|version>
a60e94d6 1069
df89052a 1070
59b05e08
JRT
1071The following modules are optional, but recommended for complete
1072testing:
1073
11f53956 1074L<File::HomeDir|File::HomeDir>
a60e94d6 1075
11f53956 1076L<File::Which|File::Which>
a60e94d6 1077
11f53956 1078L<IO::String|IO::String>
a60e94d6 1079
11f53956 1080L<IPC::Open2|IPC::Open2>
a60e94d6 1081
11f53956 1082L<Perl::Tidy|Perl::Tidy>
a60e94d6 1083
11f53956 1084L<Pod::Spell|Pod::Spell>
a60e94d6 1085
11f53956 1086L<Test::Pod|Test::Pod>
59b05e08 1087
11f53956 1088L<Test::Pod::Coverage|Test::Pod::Coverage>
59b05e08 1089
11f53956 1090L<Text::ParseWords|Text::ParseWords>
a60e94d6 1091
df89052a 1092
25e89cf1
ES
1093=head1 CONTACTING THE DEVELOPMENT TEAM
1094
1095You are encouraged to subscribe to the mailing list; send a message to
1096C<< <users-subscribe@perlcritic.tigris.org> >>. See also
1097L<the archives|http://perlcritic.tigris.org/servlets/SummarizeList?listName=users>.
1098You can also contact the author at C<< <thaljef@cpan.org> >>.
1099
11f53956
ES
1100At least one member of the development team has started hanging around
1101in L<irc://irc.perl.org/#perlcritic>.
098d393b 1102
df89052a 1103
3123bf46
ES
1104=head1 SEE ALSO
1105
11f53956
ES
1106There are a number of distributions of additional Policies available.
1107A few are listed here:
3123bf46 1108
11f53956 1109L<Perl::Critic::More|Perl::Critic::More>
a60e94d6 1110
11f53956 1111L<Perl::Critic::Bangs|Perl::Critic::Bangs>
a60e94d6 1112
11f53956 1113L<Perl::Critic::Lax|Perl::Critic::Lax>
a60e94d6 1114
11f53956 1115L<Perl::Critic::StricterSubs|Perl::Critic::StricterSubs>
a60e94d6 1116
11f53956 1117L<Perl::Critic::Swift|Perl::Critic::Swift>
3123bf46 1118
11f53956 1119L<Perl::Critic::Tics|Perl::Critic::Tics>
a60e94d6 1120
d032ff5e
JRT
1121These distributions enable you to use Perl::Critic in your unit tests:
1122
11f53956 1123L<Test::Perl::Critic|Test::Perl::Critic>
a60e94d6 1124
11f53956 1125L<Test::Perl::Critic::Progressive|Test::Perl::Critic::Progressive>
d032ff5e 1126
3123bf46
ES
1127There are also a couple of distributions that will install all the
1128Perl::Critic related modules known to the development team:
1129
11f53956 1130L<Bundle::Perl::Critic|Bundle::Perl::Critic>
a60e94d6 1131
11f53956 1132L<Task::Perl::Critic|Task::Perl::Critic>
3123bf46 1133
11f53956
ES
1134If you want to make sure you have absolutely everything, you can use
1135these:
a60e94d6 1136
11f53956 1137L<Bundle::Perl::Critic::IncludingOptionalDependencies|Bundle::Perl::Critic::IncludingOptionalDependencies>
a60e94d6 1138
11f53956 1139L<Task::Perl::Critic::IncludingOptionalDependencies|Task::Perl::Critic::IncludingOptionalDependencies>
a60e94d6 1140
df89052a 1141
59b05e08
JRT
1142=head1 BUGS
1143
11f53956
ES
1144Scrutinizing Perl code is hard for humans, let alone machines. If you
1145find any bugs, particularly false-positives or false-negatives from a
1bef6e21 1146Perl::Critic::Policy, please submit them to
59b05e08
JRT
1147L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Perl-Critic>. Thanks.
1148
fc0fffee
ES
1149Most policies will produce false-negatives if they cannot understand a
1150particular block of code.
1151
df89052a 1152
59b05e08
JRT
1153=head1 CREDITS
1154
11f53956
ES
1155Adam Kennedy - For creating L<PPI|PPI>, the heart and soul of
1156L<Perl::Critic|Perl::Critic>.
59b05e08 1157
b87b00dd 1158Damian Conway - For writing B<Perl Best Practices>, finally :)
59b05e08 1159
b87b00dd 1160Chris Dolan - For contributing the best features and Policy modules.
59b05e08 1161
7711a331 1162Andy Lester - Wise sage and master of all-things-testing.
9cdbdce6 1163
7711a331 1164Elliot Shank - The self-proclaimed quality freak.
9cdbdce6 1165
7711a331 1166Giuseppe Maxia - For all the great ideas and positive encouragement.
9cdbdce6 1167
b87b00dd 1168and Sharon, my wife - For putting up with my all-night code sessions.
59b05e08 1169
11f53956
ES
1170Thanks also to the Perl Foundation for providing a grant to support
1171Chris Dolan's project to implement twenty PBP policies.
369abea9
CD
1172L<http://www.perlfoundation.org/april_1_2007_new_grant_awards>
1173
df89052a 1174
59b05e08
JRT
1175=head1 AUTHOR
1176
1177Jeffrey Ryan Thalhammer <thaljef@cpan.org>
1178
df89052a 1179
59b05e08
JRT
1180=head1 COPYRIGHT
1181
20dfddeb 1182Copyright (c) 2005-2008 Jeffrey Ryan Thalhammer. All rights reserved.
59b05e08 1183
11f53956
ES
1184This program is free software; you can redistribute it and/or modify
1185it under the same terms as Perl itself. The full text of this license
1186can be found in the LICENSE file included with this module.
59b05e08
JRT
1187
1188=cut
737d3b65 1189
7711a331 1190##############################################################################
737d3b65
CD
1191# Local Variables:
1192# mode: cperl
1193# cperl-indent-level: 4
1194# fill-column: 78
1195# indent-tabs-mode: nil
1196# c-indentation-style: bsd
1197# End:
96fed375 1198# ex: set ts=8 sts=4 sw=4 tw=78 ft=perl expandtab shiftround :