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

NAME

6       Perl::Critic::PolicySummary - Description of the bundled Policy modules
7

DESCRIPTION

9       The following Policy modules are distributed with Perl::Critic.  The
10       Policy modules have been categorized according to the table of contents
11       in Damian Conway's book Perl Best Practices.  Since most coding stan‐
12       dards take the form "do this..." or "don't do that...", I have adopted
13       the convention of naming each module "RequireSomething" or "Prohibit‐
14       Something".  Each Policy is listed here with it's default severity.  If
15       you don't agree with the default severity, you can change it in your
16       .perlcriticrc file.  See the documentation of each module for it's spe‐
17       cific details.
18

POLICIES

20       Perl::Critic::Policy::BuiltinFunctions::ProhibitLvalueSubstr
21
22       Use 4-argument "substr" instead of writing "substr($foo, 2, 6) = $bar"
23       [Severity 3]
24
25       Perl::Critic::Policy::BuiltinFunctions::ProhibitReverseSortBlock
26
27       Forbid $b before $a in sort blocks [Severity 1]
28
29       Perl::Critic::Policy::BuiltinFunctions::ProhibitSleepViaSelect
30
31       Use Time::HiRes instead of something like "select(undef, undef, undef,
32       .05)" [Severity 5]
33
34       Perl::Critic::Policy::BuiltinFunctions::ProhibitStringyEval
35
36       Write "eval { my $foo; bar($foo) }" instead of "eval "my $foo;
37       bar($foo);"" [Severity 5]
38
39       Perl::Critic::Policy::BuiltinFunctions::ProhibitStringySplit
40
41       Write "split /-/, $string" instead of "split '-', $string" [Severity 3]
42
43       Perl::Critic::Policy::BuiltinFunctions::ProhibitUniversalCan
44
45       Write "eval { $foo->can($name) }" instead of "UNIVERSAL::can($foo,
46       $name)" [Severity 3]
47
48       Perl::Critic::Policy::BuiltinFunctions::ProhibitUniversalIsa
49
50       Write "eval { $foo->isa($pkg) }" instead of "UNIVERSAL::isa($foo,
51       $pkg)" [Severity 3]
52
53       Perl::Critic::Policy::BuiltinFunctions::ProhibitVoidGrep
54
55       Don't use "grep" in void contexts. [Severity 3]
56
57       Perl::Critic::Policy::BuiltinFunctions::ProhibitVoidMap
58
59       Don't use "map" in void contexts. [Severity 3]
60
61       Perl::Critic::Policy::BuiltinFunctions::RequireBlockGrep
62
63       Write "grep { $_ =~ /$pattern/ } @list" instead of "grep /$pattern/,
64       @list" [Severity 4]
65
66       Perl::Critic::Policy::BuiltinFunctions::RequireBlockMap
67
68       Write "map { $_ =~ /$pattern/ } @list" instead of "map /$pattern/,
69       @list" [Severity 4]
70
71       Perl::Critic::Policy::BuiltinFunctions::RequireGlobFunction
72
73       Use "glob q{*}" instead of <*> [Severity 5]
74
75       Perl::Critic::Policy::BuiltinFunctions::RequireSimpleSortBlock
76
77       Sort blocks should have a single statement [Severity 3]
78
79       Perl::Critic::Policy::ClassHierarchies::ProhibitAutoloading
80
81       AUTOLOAD methods should be avoided [Severity 3]
82
83       Perl::Critic::Policy::ClassHierarchies::ProhibitExplicitISA
84
85       Employ "use base" instead of @ISA [Severity 3]
86
87       Perl::Critic::Policy::ClassHierarchies::ProhibitOneArgBless
88
89       Write "bless {}, $class;" instead of just "bless {};" [Severity 5]
90
91       Perl::Critic::Policy::CodeLayout::ProhibitHardTabs
92
93       Use spaces instead of tabs. [Severity 3]
94
95       Perl::Critic::Policy::CodeLayout::ProhibitParensWithBuiltins
96
97       Write "open $handle, $path" instead of "open($handle, $path)" [Severity
98       1]
99
100       Perl::Critic::Policy::CodeLayout::ProhibitQuotedWordLists
101
102       Write "qw(foo bar baz)" instead of "('foo', 'bar', 'baz')" [Severity 2]
103
104       Perl::Critic::Policy::CodeLayout::ProhibitTrailingWhitespace
105
106       Don't use whitespace at the end of lines. [Severity 1]
107
108       Perl::Critic::Policy::CodeLayout::RequireConsistentNewlines
109
110       Use the same newline through the source [Severity 4]
111
112       Perl::Critic::Policy::CodeLayout::RequireTidyCode
113
114       Must run code through perltidy. [Severity 1]
115
116       Perl::Critic::Policy::CodeLayout::RequireTrailingCommas
117
118       Put a comma at the end of every multi-line list declaration, including
119       the last one. [Severity 1]
120
121       Perl::Critic::Policy::ControlStructures::ProhibitCStyleForLoops
122
123       Write "for(0..20)" instead of "for($i=0; $i<=20; $i++)" [Severity 2]
124
125       Perl::Critic::Policy::ControlStructures::ProhibitCascadingIfElse
126
127       Don't write long "if-elsif-elsif-elsif-elsif...else" chains. [Severity
128       3]
129
130       Perl::Critic::Policy::ControlStructures::ProhibitDeepNests
131
132       Don't write deeply nested loops and conditionals. [Severity 2]
133
134       Perl::Critic::Policy::ControlStructures::ProhibitMutatingListFunctions
135
136       Don't modify $_ in list functions [Severity 5]
137
138       Perl::Critic::Policy::ControlStructures::ProhibitPostfixControls
139
140       Write "if($condition){ do_something() }" instead of "do_something() if
141       $condition" [Severity 2]
142
143       Perl::Critic::Policy::ControlStructures::ProhibitUnlessBlocks
144
145       Write "if(! $condition)" instead of "unless($condition)" [Severity 2]
146
147       Perl::Critic::Policy::ControlStructures::ProhibitUnreachableCode
148
149       Don't write code after an unconditional "die, exit, or next".  [Sever‐
150       ity 4]
151
152       Perl::Critic::Policy::ControlStructures::ProhibitUntilBlocks
153
154       Write "while(! $condition)" instead of "until($condition)" [Severity 2]
155
156       Perl::Critic::Policy::Documentation::RequirePodAtEnd
157
158       All POD should be after "__END__" [Severity 1]
159
160       Perl::Critic::Policy::Documentation::RequirePodSections
161
162       Organize your POD into the customary sections. [Severity 2]
163
164       Perl::Critic::Policy::ErrorHandling::RequireCarping
165
166       Use functions from Carp instead of "warn" or "die". [Severity 3]
167
168       Perl::Critic::Policy::InputOutput::ProhibitBacktickOperators
169
170       Discourage stuff like "@files = `ls $directory`" [Severity 3]
171
172       Perl::Critic::Policy::InputOutput::ProhibitBarewordFileHandles
173
174       Write "open my $fh, q{<}, $filename;" instead of "open FH, q{<}, $file‐
175       name;" [Severity 5]
176
177       Perl::Critic::Policy::InputOutput::ProhibitInteractiveTest
178
179       Use prompt() instead of -t [Severity 5]
180
181       Perl::Critic::Policy::InputOutput::ProhibitOneArgSelect
182
183       Never write "select($fh)" [Severity 4]
184
185       Perl::Critic::Policy::InputOutput::ProhibitReadlineInForLoop
186
187       Write "while( $line = <> ){...}" instead of "for(<>){...}" [Severity 4]
188
189       Perl::Critic::Policy::InputOutput::ProhibitTwoArgOpen
190
191       Write "open $fh, q{<}, $filename;" instead of "open $fh, "<$filename";"
192       [Severity 5]
193
194       Perl::Critic::Policy::InputOutput::RequireCheckedOpen
195
196       Write "my $error = open $fh, $mode, $filename;" instead of "open $fh,
197       $mode, $filename;" [Severity 3]
198
199       Perl::Critic::Policy::InputOutput::RequireCheckedClose
200
201       Write "my $error = close $fh;" instead of "close $fh;" [Severity 3]
202
203       Perl::Critic::Policy::InputOutput::RequireBracedFileHandleWithPrint
204
205       Write "print {$FH} $foo, $bar;" instead of "print $FH $foo, $bar;"
206       [Severity 1]
207
208       Perl::Critic::Policy::Miscellanea::ProhibitFormats
209
210       Do not use "format". [Severity 3]
211
212       Perl::Critic::Policy::Miscellanea::ProhibitTies
213
214       Do not use "tie". [Severity 2]
215
216       Perl::Critic::Policy::Miscellanea::RequireRcsKeywords
217
218       Put source-control keywords in every file. [Severity 2]
219
220       Perl::Critic::Policy::Modules::ProhibitAutomaticExportation
221
222       Export symbols via @EXPORT_OK or %EXPORT_TAGS instead of @EXPORT.
223       [Severity 3]
224
225       Perl::Critic::Policy::Modules::ProhibitEvilModules
226
227       Ban modules that aren't blessed by your shop. [Severity 5]
228
229       Perl::Critic::Policy::Modules::ProhibitMultiplePackages
230
231       Put packages (especially subclasses) in separate files. [Severity 4]
232
233       Perl::Critic::Policy::Modules::RequireBarewordIncludes
234
235       Write "require Module" instead of "require 'Module.pm'" [Severity 5]
236
237       Perl::Critic::Policy::Modules::RequireEndWithOne
238
239       End each module with an explicitly "1;" instead of some funky expres‐
240       sion. [Severity 4]
241
242       Perl::Critic::Policy::Modules::RequireExplicitPackage
243
244       Always make the "package" explicit. [Severity 4]
245
246       Perl::Critic::Policy::Modules::RequireFilenameMatchesPackage
247
248       Package declaration must match filename [Severity 5]
249
250       Perl::Critic::Policy::Modules::RequireVersionVar
251
252       Give every module a $VERSION number. [Severity 2]
253
254       Perl::Critic::Policy::NamingConventions::ProhibitAmbiguousNames
255
256       Don't use vague variable or subroutine names like 'last' or 'record'.
257       [Severity 3]
258
259       Perl::Critic::Policy::NamingConventions::ProhibitMixedCaseSubs
260
261       Write "sub my_function{}" instead of "sub MyFunction{}" [Severity 1]
262
263       Perl::Critic::Policy::NamingConventions::ProhibitMixedCaseVars
264
265       Write "$my_variable = 42" instead of "$MyVariable = 42" [Severity 1]
266
267       Perl::Critic::Policy::References::ProhibitDoubleSigils
268
269       Write "@{ $array_ref }" instead of @$array_ref [Severity 2]
270
271       Perl::Critic::Policy::RegularExpressions::ProhibitCaptureWithoutTest
272
273       Capture variable used outside conditional [Severity 3]
274
275       Perl::Critic::Policy::RegularExpressions::RequireExtendedFormatting
276
277       Always use the "/x" modifier with regular expressions. [Severity 2]
278
279       Perl::Critic::Policy::RegularExpressions::RequireLineBoundaryMatching
280
281       Always use the "/m" modifier with regular expressions. [Severity 3]
282
283       Perl::Critic::Policy::Subroutines::ProhibitAmpersandSigils
284
285       Don't call functions with a leading ampersand sigil. [Severity 2]
286
287       Perl::Critic::Policy::Subroutines::ProhibitBuiltinHomonyms
288
289       Don't declare your own "open" function. [Severity 4]
290
291       Perl::Critic::Policy::Subroutines::ProhibitExcessComplexity
292
293       Minimize complexity by factoring code into smaller subroutines. [Sever‐
294       ity 3]
295
296       Perl::Critic::Policy::Subroutines::ProhibitExplicitReturnUndef
297
298       Return failure with bare "return" instead of "return undef" [Severity
299       5]
300
301       Perl::Critic::Policy::Subroutines::ProhibitSubroutinePrototypes
302
303       Don't write "sub my_function (@@) {}" [Severity 5]
304
305       Perl::Critic::Policy::Subroutines::ProtectPrivateSubs
306
307       Prevent access to private subs in other packages [Severity 3]
308
309       Perl::Critic::Policy::Subroutines::RequireFinalReturn
310
311       End every path through a subroutine with an explicit "return" state‐
312       ment. [Severity 4]
313
314       Perl::Critic::Policy::TestingAndDebugging::ProhibitNoStrict
315
316       Prohibit various flavors of "no strict" [Severity 5]
317
318       Perl::Critic::Policy::TestingAndDebugging::ProhibitNoWarnings
319
320       Prohibit various flavors of "no warnings" [Severity 4]
321
322       Perl::Critic::Policy::TestingAndDebugging::ProhibitProlongedStricture‐
323       Override
324
325       Don't turn off strict for large blocks of code [Severity 4]
326
327       Perl::Critic::Policy::TestingAndDebugging::RequireTestLabels
328
329       Tests should all have labels [Severity 3]
330
331       Perl::Critic::Policy::TestingAndDebugging::RequireUseStrict
332
333       Always "use strict" [Severity 5]
334
335       Perl::Critic::Policy::TestingAndDebugging::RequireUseWarnings
336
337       Always "use warnings" [Severity 4]
338
339       Perl::Critic::Policy::ValuesAndExpressions::ProhibitCommaSeparated‐
340       Statements
341
342       Don't use the comma operator as a statement separator. [Severity 4]
343
344       Perl::Critic::Policy::ValuesAndExpressions::ProhibitConstantPragma
345
346       Don't "use constant $FOO => 15" [Severity 4]
347
348       Perl::Critic::Policy::ValuesAndExpressions::ProhibitEmptyQuotes
349
350       Write "q{}" instead of '' [Severity 2]
351
352       Perl::Critic::Policy::ValuesAndExpressions::ProhibitEscapedCharacters
353
354       Write "\N{DELETE}" instead of "\x7F", etc. [Severity 2]
355
356       Perl::Critic::Policy::ValuesAndExpressions::ProhibitInterpolationOfLit‐
357       erals
358
359       Always use single quotes for literal strings. [Severity 1]
360
361       Perl::Critic::Policy::ValuesAndExpressions::ProhibitLeadingZeros
362
363       Write "oct(755)" instead of 0755 [Severity 5]
364
365       Perl::Critic::Policy::ValuesAndExpressions::ProhibitMagicNumbers
366
367       Use Readonly to give meaningful names for numeric literals. [Severity
368       2]
369
370       Perl::Critic::Policy::ValuesAndExpressions::ProhibitMismatchedOperators
371
372       Don't mix numeric operators with string operands, or vice-versa.
373       [Severity 3]
374
375       Perl::Critic::Policy::ValuesAndExpressions::ProhibitMixedBooleanOpera‐
376       tors
377
378       Write " !$foo && $bar ⎪⎪ $baz " instead of " not $foo && $bar or $baz"
379       [Severity 4]
380
381       Perl::Critic::Policy::ValuesAndExpressions::ProhibitNoisyQuotes
382
383       Use "q{}" or "qq{}" instead of quotes for awkward-looking strings.
384       [Severity 2]
385
386       Perl::Critic::Policy::ValuesAndExpressions::ProhibitVersionStrings
387
388       Don't use strings like "v1.4" or 1.4.5 when including other modules.
389       [Severity 3]
390
391       Perl::Critic::Policy::ValuesAndExpressions::RequireInterpola‐
392       tionOfMetachars
393
394       Warns that you might have used single quotes when you really wanted
395       double-quotes. [Severity 1]
396
397       Perl::Critic::Policy::ValuesAndExpressions::RequireNumberSeparators
398
399       Write " 141_234_397.0145 " instead of  141234397.0145  [Severity 2]
400
401       Perl::Critic::Policy::ValuesAndExpressions::RequireQuotedHeredocTermi‐
402       nator
403
404       Write " print <<'THE_END' " or " print <<"THE_END" " [Severity 3]
405
406       Perl::Critic::Policy::ValuesAndExpressions::RequireUpperCaseHeredocTer‐
407       minator
408
409       Write " <<'THE_END'; " instead of " <<'theEnd'; " [Severity 1]
410
411       Perl::Critic::Policy::Variables::ProhibitConditionalDeclarations
412
413       Do not write " my $foo = $bar if $baz; " [Severity 5]
414
415       Perl::Critic::Policy::Variables::ProhibitLocalVars
416
417       Use "my" instead of "local", except when you have to. [Severity 2]
418
419       Perl::Critic::Policy::Variables::ProhibitMatchVars
420
421       Avoid $`, $&, $' and their English equivalents. [Severity 4]
422
423       Perl::Critic::Policy::Variables::ProhibitPackageVars
424
425       Eliminate globals declared with "our" or "use vars" [Severity 3]
426
427       Perl::Critic::Policy::Variables::ProhibitPerl4PackageNames
428
429       Use double colon (::) to separate package name components instead of
430       single quotes ('). [Severity 2]
431
432       Perl::Critic::Policy::Variables::ProhibitPunctuationVars
433
434       Write $EVAL_ERROR instead of $@ [Severity 2]
435
436       Perl::Critic::Policy::Variables::ProtectPrivateVars
437
438       Prevent access to private vars in other packages [Severity 3]
439
440       Perl::Critic::Policy::Variables::RequireInitializationForLocalVars
441
442       Write "local $foo = $bar;" instead of just "local $foo;" [Severity 3]
443
444       Perl::Critic::Policy::Variables::RequireLexicalLoopIterators
445
446       Write "for my $element (@list) {...}" instead of "for $element (@list)
447       {...}"
448
449       Perl::Critic::Policy::Variables::RequireNegativeIndices
450
451       Negative array index should be used [Severity 4]
452

AUTHOR

454       Jeffrey Ryan Thalhammer <thaljef@cpan.org>
455
457       Copyright (c) 2005-2007 Jeffrey Ryan Thalhammer.  All rights reserved.
458
459       This program is free software; you can redistribute it and/or modify it
460       under the same terms as Perl itself.  The full text of this license can
461       be found in the LICENSE file included with this module.
462
463
464
465perl v5.8.8                       2007-03-20    Perl::Critic::PolicySummary(3)
Impressum