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