1Perl::Critic::PolicySumUmsaerry(C3o)ntributed Perl DocumPeenrtla:t:iCornitic::PolicySummary(3)
2
3
4

NAME

6       Perl::Critic::PolicySummary - Descriptions of the Policy modules
7       included with Perl::Critic itself.
8

DESCRIPTION

10       The following Policy modules are distributed with Perl::Critic.  (There
11       are additional Policies that can be found in add-on distributions.)
12       The Policy modules have been categorized according to the table of
13       contents in Damian Conway's book Perl Best Practices.  Since most
14       coding standards take the form "do this..." or "don't do that...", I
15       have adopted the convention of naming each module "RequireSomething" or
16       "ProhibitSomething".  Each Policy is listed here with its default
17       severity.  If you don't agree with the default severity, you can change
18       it in your .perlcriticrc file.  See the documentation of each module
19       for its specific details.
20

POLICIES

22   Perl::Critic::Policy::BuiltinFunctions::ProhibitBooleanGrep
23       Use "List::MoreUtils::any" instead of "grep" in boolean context.
24       [Severity 2]
25
26   Perl::Critic::Policy::BuiltinFunctions::ProhibitComplexMappings
27       Map blocks should have a single statement. [Severity 3]
28
29   Perl::Critic::Policy::BuiltinFunctions::ProhibitLvalueSubstr
30       Use 4-argument "substr" instead of writing "substr($foo, 2, 6) = $bar".
31       [Severity 3]
32
33   Perl::Critic::Policy::BuiltinFunctions::ProhibitReverseSortBlock
34       Forbid $b before $a in sort blocks. [Severity 1]
35
36   Perl::Critic::Policy::BuiltinFunctions::ProhibitSleepViaSelect
37       Use Time::HiRes instead of something like "select(undef, undef, undef,
38       .05)". [Severity 5]
39
40   Perl::Critic::Policy::BuiltinFunctions::ProhibitStringyEval
41       Write "eval { my $foo; bar($foo) }" instead of "eval "my $foo;
42       bar($foo);"". [Severity 5]
43
44   Perl::Critic::Policy::BuiltinFunctions::ProhibitStringySplit
45       Write "split /-/, $string" instead of "split '-', $string". [Severity
46       2]
47
48   Perl::Critic::Policy::BuiltinFunctions::ProhibitUniversalCan
49       Write "eval { $foo->can($name) }" instead of "UNIVERSAL::can($foo,
50       $name)". [Severity 3]
51
52   Perl::Critic::Policy::BuiltinFunctions::ProhibitUniversalIsa
53       Write "eval { $foo->isa($pkg) }" instead of "UNIVERSAL::isa($foo,
54       $pkg)". [Severity 3]
55
56   Perl::Critic::Policy::BuiltinFunctions::ProhibitVoidGrep
57       Don't use "grep" in void contexts. [Severity 3]
58
59   Perl::Critic::Policy::BuiltinFunctions::ProhibitVoidMap
60       Don't use "map" in void contexts. [Severity 3]
61
62   Perl::Critic::Policy::BuiltinFunctions::RequireBlockGrep
63       Write "grep { $_ =~ /$pattern/ } @list" instead of "grep /$pattern/,
64       @list". [Severity 4]
65
66   Perl::Critic::Policy::BuiltinFunctions::RequireBlockMap
67       Write "map { $_ =~ /$pattern/ } @list" instead of "map /$pattern/,
68       @list". [Severity 4]
69
70   Perl::Critic::Policy::BuiltinFunctions::RequireGlobFunction
71       Use "glob q{*}" instead of <*>. [Severity 5]
72
73   Perl::Critic::Policy::BuiltinFunctions::RequireSimpleSortBlock
74       Sort blocks should have a single statement. [Severity 3]
75
76   Perl::Critic::Policy::ClassHierarchies::ProhibitAutoloading
77       AUTOLOAD methods should be avoided. [Severity 3]
78
79   Perl::Critic::Policy::ClassHierarchies::ProhibitExplicitISA
80       Employ "use base" instead of @ISA. [Severity 3]
81
82   Perl::Critic::Policy::ClassHierarchies::ProhibitOneArgBless
83       Write "bless {}, $class;" instead of just "bless {};". [Severity 5]
84
85   Perl::Critic::Policy::CodeLayout::ProhibitHardTabs
86       Use spaces instead of tabs. [Severity 3]
87
88   Perl::Critic::Policy::CodeLayout::ProhibitParensWithBuiltins
89       Write "open $handle, $path" instead of "open($handle, $path)".
90       [Severity 1]
91
92   Perl::Critic::Policy::CodeLayout::ProhibitQuotedWordLists
93       Write "qw(foo bar baz)" instead of "('foo', 'bar', 'baz')". [Severity
94       2]
95
96   Perl::Critic::Policy::CodeLayout::ProhibitTrailingWhitespace
97       Don't use whitespace at the end of lines. [Severity 1]
98
99   Perl::Critic::Policy::CodeLayout::RequireConsistentNewlines
100       Use the same newline through the source. [Severity 4]
101
102   Perl::Critic::Policy::CodeLayout::RequireTidyCode
103       Must run code through perltidy. [Severity 1]
104
105   Perl::Critic::Policy::CodeLayout::RequireTrailingCommas
106       Put a comma at the end of every multi-line list declaration, including
107       the last one. [Severity 1]
108
109   Perl::Critic::Policy::ControlStructures::ProhibitCStyleForLoops
110       Write "for(0..20)" instead of "for($i=0; $i<=20; $i++)". [Severity 2]
111
112   Perl::Critic::Policy::ControlStructures::ProhibitCascadingIfElse
113       Don't write long "if-elsif-elsif-elsif-elsif...else" chains. [Severity
114       3]
115
116   Perl::Critic::Policy::ControlStructures::ProhibitDeepNests
117       Don't write deeply nested loops and conditionals. [Severity 3]
118
119   Perl::Critic::Policy::ControlStructures::ProhibitLabelsWithSpecialBlockNames
120       Don't use labels that are the same as the special block names.
121       [Severity 4]
122
123   Perl::Critic::Policy::ControlStructures::ProhibitMutatingListFunctions
124       Don't modify $_ in list functions. [Severity 5]
125
126   Perl::Critic::Policy::ControlStructures::ProhibitNegativeExpressionsInUnlessAndUntilConditions
127       Don't use operators like "not", "!~", and "le" within "until" and
128       "unless". [Severity 3]
129
130   Perl::Critic::Policy::ControlStructures::ProhibitPostfixControls
131       Write "if($condition){ do_something() }" instead of "do_something() if
132       $condition". [Severity 2]
133
134   Perl::Critic::Policy::ControlStructures::ProhibitUnlessBlocks
135       Write "if(! $condition)" instead of "unless($condition)". [Severity 2]
136
137   Perl::Critic::Policy::ControlStructures::ProhibitUnreachableCode
138       Don't write code after an unconditional "die, exit, or next". [Severity
139       4]
140
141   Perl::Critic::Policy::ControlStructures::ProhibitUntilBlocks
142       Write "while(! $condition)" instead of "until($condition)". [Severity
143       2]
144
145   Perl::Critic::Policy::Documentation::PodSpelling
146       Check your spelling. [Severity 1]
147
148   Perl::Critic::Policy::Documentation::RequirePackageMatchesPodName
149       The "=head1 NAME" section should match the package. [Severity 1]
150
151   Perl::Critic::Policy::Documentation::RequirePodAtEnd
152       All POD should be after "__END__". [Severity 1]
153
154   Perl::Critic::Policy::Documentation::RequirePodSections
155       Organize your POD into the customary sections. [Severity 2]
156
157   Perl::Critic::Policy::ErrorHandling::RequireCarping
158       Use functions from Carp instead of "warn" or "die". [Severity 3]
159
160   Perl::Critic::Policy::ErrorHandling::RequireCheckingReturnValueOfEval
161       You can't depend upon the value of $@/$EVAL_ERROR to tell whether an
162       "eval" failed. [Severity 3]
163
164   Perl::Critic::Policy::InputOutput::ProhibitBacktickOperators
165       Discourage stuff like "@files = `ls $directory`". [Severity 3]
166
167   Perl::Critic::Policy::InputOutput::ProhibitBarewordFileHandles
168       Write "open my $fh, q{<}, $filename;" instead of "open FH, q{<},
169       $filename;". [Severity 5]
170
171   Perl::Critic::Policy::InputOutput::ProhibitExplicitStdin
172       Use "<>" or "<ARGV>" or a prompting module instead of "<STDIN>".
173       [Severity 4]
174
175   Perl::Critic::Policy::InputOutput::ProhibitInteractiveTest
176       Use prompt() instead of -t. [Severity 5]
177
178   Perl::Critic::Policy::InputOutput::ProhibitJoinedReadline
179       Use "local $/ = undef" or File::Slurp instead of joined readline.
180       [Severity 3]
181
182   Perl::Critic::Policy::InputOutput::ProhibitOneArgSelect
183       Never write "select($fh)". [Severity 4]
184
185   Perl::Critic::Policy::InputOutput::ProhibitReadlineInForLoop
186       Write "while( $line = <> ){...}" instead of "for(<>){...}". [Severity
187       4]
188
189   Perl::Critic::Policy::InputOutput::ProhibitTwoArgOpen
190       Write "open $fh, q{<}, $filename;" instead of "open $fh,
191       "<$filename";". [Severity 5]
192
193   Perl::Critic::Policy::InputOutput::RequireBracedFileHandleWithPrint
194       Write "print {$FH} $foo, $bar;" instead of "print $FH $foo, $bar;".
195       [Severity 1]
196
197   Perl::Critic::Policy::InputOutput::RequireBriefOpen
198       Close filehandles as soon as possible after opening them. [Severity 4]
199
200   Perl::Critic::Policy::InputOutput::RequireCheckedClose
201       Write "my $error = close $fh;" instead of "close $fh;". [Severity 2]
202
203   Perl::Critic::Policy::InputOutput::RequireCheckedOpen
204       Write "my $error = open $fh, $mode, $filename;" instead of "open $fh,
205       $mode, $filename;". [Severity 3]
206
207   Perl::Critic::Policy::InputOutput::RequireCheckedSyscalls
208       Return value of flagged function ignored. [Severity 1]
209
210   Perl::Critic::Policy::Miscellanea::ProhibitFormats
211       Do not use "format". [Severity 3]
212
213   Perl::Critic::Policy::Miscellanea::ProhibitTies
214       Do not use "tie". [Severity 2]
215
216   Perl::Critic::Policy::Miscellanea::ProhibitUnrestrictedNoCritic
217       Forbid a bare "## no critic" [Severity 3]
218
219   Perl::Critic::Policy::Miscellanea::ProhibitUselessNoCritic
220       Remove ineffective "## no critic" annotations. [Severity 2]
221
222   Perl::Critic::Policy::Miscellanea::RequireRcsKeywords
223       Put source-control keywords in every file. [Severity 2]
224
225   Perl::Critic::Policy::Modules::ProhibitAutomaticExportation
226       Export symbols via @EXPORT_OK or %EXPORT_TAGS instead of @EXPORT.
227       [Severity 4]
228
229   Perl::Critic::Policy::Modules::ProhibitEvilModules
230       Ban modules that aren't blessed by your shop. [Severity 5]
231
232   Perl::Critic::Policy::Modules::ProhibitExcessMainComplexity
233       Minimize complexity in code that is outside of subroutines. [Severity
234       3]
235
236   Perl::Critic::Policy::Modules::ProhibitMultiplePackages
237       Put packages (especially subclasses) in separate files. [Severity 4]
238
239   Perl::Critic::Policy::Modules::RequireBarewordIncludes
240       Write "require Module" instead of "require 'Module.pm'". [Severity 5]
241
242   Perl::Critic::Policy::Modules::RequireEndWithOne
243       End each module with an explicitly "1;" instead of some funky
244       expression. [Severity 4]
245
246   Perl::Critic::Policy::Modules::RequireExplicitPackage
247       Always make the "package" explicit. [Severity 4]
248
249   Perl::Critic::Policy::Modules::RequireFilenameMatchesPackage
250       Package declaration must match filename. [Severity 5]
251
252   Perl::Critic::Policy::Modules::RequireNoMatchVarsWithUseEnglish
253       "use English" must be passed a "-no_match_vars" argument. [Severity 2]
254
255   Perl::Critic::Policy::Modules::RequireVersionVar
256       Give every module a $VERSION number. [Severity 2]
257
258   Perl::Critic::Policy::NamingConventions::Capitalization
259       Distinguish different program components by case. [Severity 1]
260
261   Perl::Critic::Policy::NamingConventions::ProhibitAmbiguousNames
262       Don't use vague variable or subroutine names like 'last' or 'record'.
263       [Severity 3]
264
265   Perl::Critic::Policy::Objects::ProhibitIndirectSyntax
266       Prohibit indirect object call syntax. [Severity 4]
267
268   Perl::Critic::Policy::References::ProhibitDoubleSigils
269       Write "@{ $array_ref }" instead of @$array_ref. [Severity 2]
270
271   Perl::Critic::Policy::RegularExpressions::ProhibitCaptureWithoutTest
272       Capture variable used outside conditional. [Severity 3]
273
274   Perl::Critic::Policy::RegularExpressions::ProhibitComplexRegexes
275       Split long regexps into smaller "qr//" chunks. [Severity 3]
276
277   Perl::Critic::Policy::RegularExpressions::ProhibitEnumeratedClasses
278       Use named character classes instead of explicit character lists.
279       [Severity 1]
280
281   Perl::Critic::Policy::RegularExpressions::ProhibitEscapedMetacharacters
282       Use character classes for literal meta-characters instead of escapes.
283       [Severity 1]
284
285   Perl::Critic::Policy::RegularExpressions::ProhibitFixedStringMatches
286       Use "eq" or hash instead of fixed-pattern regexps. [Severity 2]
287
288   Perl::Critic::Policy::RegularExpressions::ProhibitSingleCharAlternation
289       Use "[abc]" instead of "a|b|c". [Severity 1]
290
291   Perl::Critic::Policy::RegularExpressions::ProhibitUnusedCapture
292       Only use a capturing group if you plan to use the captured value.
293       [Severity 3]
294
295   Perl::Critic::Policy::RegularExpressions::ProhibitUnusualDelimiters
296       Use only "//" or "{}" to delimit regexps. [Severity 1]
297
298   Perl::Critic::Policy::RegularExpressions::RequireBracesForMultiline
299       Use "{" and "}" to delimit multi-line regexps. [Severity 1]
300
301   Perl::Critic::Policy::RegularExpressions::RequireDotMatchAnything
302       Always use the "/s" modifier with regular expressions. [Severity 2]
303
304   Perl::Critic::Policy::RegularExpressions::RequireExtendedFormatting
305       Always use the "/x" modifier with regular expressions. [Severity 3]
306
307   Perl::Critic::Policy::RegularExpressions::RequireLineBoundaryMatching
308       Always use the "/m" modifier with regular expressions. [Severity 2]
309
310   Perl::Critic::Policy::Subroutines::ProhibitAmpersandSigils
311       Don't call functions with a leading ampersand sigil. [Severity 2]
312
313   Perl::Critic::Policy::Subroutines::ProhibitBuiltinHomonyms
314       Don't declare your own "open" function. [Severity 4]
315
316   Perl::Critic::Policy::Subroutines::ProhibitExcessComplexity
317       Minimize complexity by factoring code into smaller subroutines.
318       [Severity 3]
319
320   Perl::Critic::Policy::Subroutines::ProhibitExplicitReturnUndef
321       Return failure with bare "return" instead of "return undef". [Severity
322       5]
323
324   Perl::Critic::Policy::Subroutines::ProhibitManyArgs
325       Too many arguments. [Severity 3]
326
327   Perl::Critic::Policy::Subroutines::ProhibitNestedSubs
328       "sub never { sub correct {} }". [Severity 5]
329
330   Perl::Critic::Policy::Subroutines::ProhibitReturnSort
331       Behavior of "sort" is not defined if called in scalar context.
332       [Severity 5]
333
334   Perl::Critic::Policy::Subroutines::ProhibitSubroutinePrototypes
335       Don't write "sub my_function (@@) {}". [Severity 5]
336
337   Perl::Critic::Policy::Subroutines::ProtectPrivateSubs
338       Prevent access to private subs in other packages. [Severity 3]
339
340   Perl::Critic::Policy::Subroutines::RequireArgUnpacking
341       Always unpack @_ first. [Severity 4]
342
343   Perl::Critic::Policy::Subroutines::RequireFinalReturn
344       End every path through a subroutine with an explicit "return"
345       statement. [Severity 4]
346
347   Perl::Critic::Policy::TestingAndDebugging::ProhibitNoStrict
348       Prohibit various flavors of "no strict". [Severity 5]
349
350   Perl::Critic::Policy::TestingAndDebugging::ProhibitNoWarnings
351       Prohibit various flavors of "no warnings". [Severity 4]
352
353   Perl::Critic::Policy::TestingAndDebugging::ProhibitProlongedStrictureOverride
354       Don't turn off strict for large blocks of code. [Severity 4]
355
356   Perl::Critic::Policy::TestingAndDebugging::RequireTestLabels
357       Tests should all have labels. [Severity 3]
358
359   Perl::Critic::Policy::TestingAndDebugging::RequireUseStrict
360       Always "use strict". [Severity 5]
361
362   Perl::Critic::Policy::TestingAndDebugging::RequireUseWarnings
363       Always "use warnings". [Severity 4]
364
365   Perl::Critic::Policy::ValuesAndExpressions::ProhibitCommaSeparatedStatements
366       Don't use the comma operator as a statement separator. [Severity 4]
367
368   Perl::Critic::Policy::ValuesAndExpressions::ProhibitComplexVersion
369       Prohibit version values from outside the module. [Severity 3]
370
371   Perl::Critic::Policy::ValuesAndExpressions::ProhibitConstantPragma
372       Don't "use constant FOO => 15". [Severity 4]
373
374   Perl::Critic::Policy::ValuesAndExpressions::ProhibitEmptyQuotes
375       Write "q{}" instead of ''. [Severity 2]
376
377   Perl::Critic::Policy::ValuesAndExpressions::ProhibitEscapedCharacters
378       Write "\N{DELETE}" instead of "\x7F", etc. [Severity 2]
379
380   Perl::Critic::Policy::ValuesAndExpressions::ProhibitImplicitNewlines
381       Use concatenation or HEREDOCs instead of literal line breaks in
382       strings. [Severity 3]
383
384   Perl::Critic::Policy::ValuesAndExpressions::ProhibitInterpolationOfLiterals
385       Always use single quotes for literal strings. [Severity 1]
386
387   Perl::Critic::Policy::ValuesAndExpressions::ProhibitLeadingZeros
388       Write "oct(755)" instead of 0755. [Severity 5]
389
390   Perl::Critic::Policy::ValuesAndExpressions::ProhibitLongChainsOfMethodCalls
391       Long chains of method calls indicate tightly coupled code. [Severity 2]
392
393   Perl::Critic::Policy::ValuesAndExpressions::ProhibitMagicNumbers
394       Don't use values that don't explain themselves. [Severity 2]
395
396   Perl::Critic::Policy::ValuesAndExpressions::ProhibitMismatchedOperators
397       Don't mix numeric operators with string operands, or vice-versa.
398       [Severity 3]
399
400   Perl::Critic::Policy::ValuesAndExpressions::ProhibitMixedBooleanOperators
401       Write " !$foo && $bar || $baz " instead of " not $foo && $bar or $baz".
402       [Severity 4]
403
404   Perl::Critic::Policy::ValuesAndExpressions::ProhibitNoisyQuotes
405       Use "q{}" or "qq{}" instead of quotes for awkward-looking strings.
406       [Severity 2]
407
408   Perl::Critic::Policy::ValuesAndExpressions::ProhibitQuotesAsQuotelikeOperatorDelimiters
409       Don't use quotes ("'", """, "`") as delimiters for the quote-like
410       operators. [Severity 3]
411
412   Perl::Critic::Policy::ValuesAndExpressions::ProhibitSpecialLiteralHeredocTerminator
413       Don't write " print <<'__END__' ". [Severity 3]
414
415   Perl::Critic::Policy::ValuesAndExpressions::ProhibitVersionStrings
416       Don't use strings like "v1.4" or 1.4.5 when including other modules.
417       [Severity 3]
418
419   Perl::Critic::Policy::ValuesAndExpressions::RequireConstantVersion
420       Require $VERSION to be a constant rather than a computed value.
421       [Severity 2]
422
423   Perl::Critic::Policy::ValuesAndExpressions::RequireInterpolationOfMetachars
424       Warns that you might have used single quotes when you really wanted
425       double-quotes. [Severity 1]
426
427   Perl::Critic::Policy::ValuesAndExpressions::RequireNumberSeparators
428       Write " 141_234_397.0145 " instead of  141234397.0145 . [Severity 2]
429
430   Perl::Critic::Policy::ValuesAndExpressions::RequireQuotedHeredocTerminator
431       Write " print <<'THE_END' " or " print <<"THE_END" ". [Severity 3]
432
433   Perl::Critic::Policy::ValuesAndExpressions::RequireUpperCaseHeredocTerminator
434       Write " <<'THE_END'; " instead of " <<'theEnd'; ". [Severity 2]
435
436   Perl::Critic::Policy::Variables::ProhibitConditionalDeclarations
437       Do not write " my $foo = $bar if $baz; ". [Severity 5]
438
439   Perl::Critic::Policy::Variables::ProhibitLocalVars
440       Use "my" instead of "local", except when you have to. [Severity 2]
441
442   Perl::Critic::Policy::Variables::ProhibitMatchVars
443       Avoid "$`", $&, "$'" and their English equivalents. [Severity 4]
444
445   Perl::Critic::Policy::Variables::ProhibitPackageVars
446       Eliminate globals declared with "our" or "use vars". [Severity 3]
447
448   Perl::Critic::Policy::Variables::ProhibitPerl4PackageNames
449       Use double colon (::) to separate package name components instead of
450       single quotes ('). [Severity 2]
451
452   Perl::Critic::Policy::Variables::ProhibitPunctuationVars
453       Write $EVAL_ERROR instead of $@. [Severity 2]
454
455   Perl::Critic::Policy::Variables::ProhibitReusedNames
456       Do not reuse a variable name in a lexical scope [Severity 3]
457
458   Perl::Critic::Policy::Variables::ProhibitUnusedVariables
459       Don't ask for storage you don't need. [Severity 3]
460
461   Perl::Critic::Policy::Variables::ProtectPrivateVars
462       Prevent access to private vars in other packages. [Severity 3]
463
464   Perl::Critic::Policy::Variables::RequireInitializationForLocalVars
465       Write "local $foo = $bar;" instead of just "local $foo;". [Severity 3]
466
467   Perl::Critic::Policy::Variables::RequireLexicalLoopIterators
468       Write "for my $element (@list) {...}" instead of "for $element (@list)
469       {...}". [Severity 5]
470
471   Perl::Critic::Policy::Variables::RequireLocalizedPunctuationVars
472       Magic variables should be assigned as "local". [Severity 4]
473
474   Perl::Critic::Policy::Variables::RequireNegativeIndices
475       Negative array index should be used. [Severity 4]
476

VERSION

478       This is part of Perl::Critic version 1.106.
479

AUTHOR

481       Jeffrey Ryan Thalhammer <thaljef@cpan.org>
482
484       Copyright (c) 2005-2009 Jeffrey Ryan Thalhammer.  All rights reserved.
485
486       This program is free software; you can redistribute it and/or modify it
487       under the same terms as Perl itself.  The full text of this license can
488       be found in the LICENSE file included with this module.
489
490
491
492perl v5.12.1                      2010-09-08    Perl::Critic::PolicySummary(3)
Impressum