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