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