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


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


The following Policy modules are distributed with Perl::Critic. The Policy modules have been categorized according to the table of contents in Damian Conway's book Perl Best Practices. Since most coding standards take the form ``do this...'' or ``don't do that...'', I have adopted the convention of naming each module RequireSomething or ProhibitSomething. Each Policy is listed here with its default severity. If you don't agree with the default severity, you can change it in your .perlcriticrc file. See the documentation of each module for its specific details.


the Perl::Critic::Policy::BuiltinFunctions::ProhibitBooleanGrep manpage

Use List::MoreUtils::any instead of grep in boolean context. [Severity 2]

the Perl::Critic::Policy::BuiltinFunctions::ProhibitComplexMappings manpage

Map blocks should have a single statement. [Severity 3]

the Perl::Critic::Policy::BuiltinFunctions::ProhibitLvalueSubstr manpage

Use 4-argument substr instead of writing substr($foo, 2, 6) = $bar. [Severity 3]

the Perl::Critic::Policy::BuiltinFunctions::ProhibitReverseSortBlock manpage

Forbid $b before $a in sort blocks. [Severity 1]

the Perl::Critic::Policy::BuiltinFunctions::ProhibitSleepViaSelect manpage

Use the Time::HiRes manpage instead of something like select(undef, undef, undef, .05). [Severity 5]

the Perl::Critic::Policy::BuiltinFunctions::ProhibitStringyEval manpage

Write eval { my $foo; bar($foo) } instead of eval "my $foo; bar($foo);". [Severity 5]

the Perl::Critic::Policy::BuiltinFunctions::ProhibitStringySplit manpage

Write split /-/, $string instead of split '-', $string. [Severity 2]

the Perl::Critic::Policy::BuiltinFunctions::ProhibitUniversalCan manpage

Write eval { $foo->can($name) } instead of UNIVERSAL::can($foo, $name). [Severity 3]

the Perl::Critic::Policy::BuiltinFunctions::ProhibitUniversalIsa manpage

Write eval { $foo->isa($pkg) } instead of UNIVERSAL::isa($foo, $pkg). [Severity 3]

the Perl::Critic::Policy::BuiltinFunctions::ProhibitVoidGrep manpage

Don't use grep in void contexts. [Severity 3]

the Perl::Critic::Policy::BuiltinFunctions::ProhibitVoidMap manpage

Don't use map in void contexts. [Severity 3]

the Perl::Critic::Policy::BuiltinFunctions::RequireBlockGrep manpage

Write grep { $_ =~ /$pattern/ } @list instead of grep /$pattern/, @list. [Severity 4]

the Perl::Critic::Policy::BuiltinFunctions::RequireBlockMap manpage

Write map { $_ =~ /$pattern/ } @list instead of map /$pattern/, @list. [Severity 4]

the Perl::Critic::Policy::BuiltinFunctions::RequireGlobFunction manpage

Use glob q{*} instead of <*>. [Severity 5]

the Perl::Critic::Policy::BuiltinFunctions::RequireSimpleSortBlock manpage

Sort blocks should have a single statement. [Severity 3]

the Perl::Critic::Policy::ClassHierarchies::ProhibitAutoloading manpage

AUTOLOAD methods should be avoided. [Severity 3]

the Perl::Critic::Policy::ClassHierarchies::ProhibitExplicitISA manpage

Employ use base instead of @ISA. [Severity 3]

the Perl::Critic::Policy::ClassHierarchies::ProhibitOneArgBless manpage

Write bless {}, $class; instead of just bless {};. [Severity 5]

the Perl::Critic::Policy::CodeLayout::ProhibitHardTabs manpage

Use spaces instead of tabs. [Severity 3]

the Perl::Critic::Policy::CodeLayout::ProhibitParensWithBuiltins manpage

Write open $handle, $path instead of open($handle, $path). [Severity 1]

the Perl::Critic::Policy::CodeLayout::ProhibitQuotedWordLists manpage

Write qw(foo bar baz) instead of ('foo', 'bar', 'baz'). [Severity 2]

the Perl::Critic::Policy::CodeLayout::ProhibitTrailingWhitespace manpage

Don't use whitespace at the end of lines. [Severity 1]

the Perl::Critic::Policy::CodeLayout::RequireConsistentNewlines manpage

Use the same newline through the source. [Severity 4]

the Perl::Critic::Policy::CodeLayout::RequireTidyCode manpage

Must run code through perltidy. [Severity 1]

the Perl::Critic::Policy::CodeLayout::RequireTrailingCommas manpage

Put a comma at the end of every multi-line list declaration, including the last one. [Severity 1]

the Perl::Critic::Policy::ControlStructures::ProhibitCStyleForLoops manpage

Write for(0..20) instead of for($i=0; $i<=20; $i++). [Severity 2]

the Perl::Critic::Policy::ControlStructures::ProhibitCascadingIfElse manpage

Don't write long ``if-elsif-elsif-elsif-elsif...else'' chains. [Severity 3]

the Perl::Critic::Policy::ControlStructures::ProhibitDeepNests manpage

Don't write deeply nested loops and conditionals. [Severity 3]

the Perl::Critic::Policy::ControlStructures::ProhibitMutatingListFunctions manpage

Don't modify $_ in list functions. [Severity 5]

the Perl::Critic::Policy::ControlStructures::ProhibitNegativeExpressionsInUnlessAndUntilConditions manpage

Don't use operators like not, !~, and le within until and unless. [Severity 3]

the Perl::Critic::Policy::ControlStructures::ProhibitPostfixControls manpage

Write if($condition){ do_something() } instead of do_something() if $condition. [Severity 2]

the Perl::Critic::Policy::ControlStructures::ProhibitUnlessBlocks manpage

Write if(! $condition) instead of unless($condition). [Severity 2]

the Perl::Critic::Policy::ControlStructures::ProhibitUnreachableCode manpage

Don't write code after an unconditional die, exit, or next. [Severity 4]

the Perl::Critic::Policy::ControlStructures::ProhibitUntilBlocks manpage

Write while(! $condition) instead of until($condition). [Severity 2]

the Perl::Critic::Policy::Documentation::PodSpelling manpage

Check your spelling. [Severity 1]

the Perl::Critic::Policy::Documentation::RequirePodAtEnd manpage

All POD should be after __END__. [Severity 1]

the Perl::Critic::Policy::Documentation::RequirePodSections manpage

Organize your POD into the customary sections. [Severity 2]

the Perl::Critic::Policy::ErrorHandling::RequireCarping manpage

Use functions from the Carp manpage instead of warn or die. [Severity 3]

the Perl::Critic::Policy::InputOutput::ProhibitBacktickOperators manpage

Discourage stuff like @files = `ls $directory`. [Severity 3]

the Perl::Critic::Policy::InputOutput::ProhibitBarewordFileHandles manpage

Write open my $fh, q{<}, $filename; instead of open FH, q{<}, $filename;. [Severity 5]

the Perl::Critic::Policy::InputOutput::ProhibitExplicitStdin manpage

Use ``<>'' or ``<ARGV>'' or a prompting module instead of ``<STDIN>''. [Severity 4]

the Perl::Critic::Policy::InputOutput::ProhibitInteractiveTest manpage

Use prompt() instead of -t. [Severity 5]

the Perl::Critic::Policy::InputOutput::ProhibitJoinedReadline manpage

Use ``local $/ = undef'' or File::Slurp instead of joined readline. [Severity 3]

the Perl::Critic::Policy::InputOutput::ProhibitOneArgSelect manpage

Never write select($fh). [Severity 4]

the Perl::Critic::Policy::InputOutput::ProhibitReadlineInForLoop manpage

Write while( $line = <> ){...} instead of for(<>){...}. [Severity 4]

the Perl::Critic::Policy::InputOutput::ProhibitTwoArgOpen manpage

Write open $fh, q{<}, $filename; instead of open $fh, "<$filename";. [Severity 5]

the Perl::Critic::Policy::InputOutput::RequireBriefOpen manpage

Close filehandles as soon as possible after opening them. [Severity 4]

the Perl::Critic::Policy::InputOutput::RequireCheckedClose manpage

Write my $error = close $fh; instead of close $fh;. [Severity 2]

the Perl::Critic::Policy::InputOutput::RequireCheckedOpen manpage

Write my $error = open $fh, $mode, $filename; instead of open $fh, $mode, $filename;. [Severity 3]

the Perl::Critic::Policy::InputOutput::RequireCheckedSyscalls manpage

Return value of flagged function ignored. [Severity 1]

the Perl::Critic::Policy::InputOutput::RequireBracedFileHandleWithPrint manpage

Write print {$FH} $foo, $bar; instead of print $FH $foo, $bar;. [Severity 1]

the Perl::Critic::Policy::Miscellanea::ProhibitFormats manpage

Do not use format. [Severity 3]

the Perl::Critic::Policy::Miscellanea::ProhibitTies manpage

Do not use tie. [Severity 2]

the Perl::Critic::Policy::Miscellanea::RequireRcsKeywords manpage

Put source-control keywords in every file. [Severity 2]

the Perl::Critic::Policy::Modules::ProhibitAutomaticExportation manpage

Export symbols via @EXPORT_OK or %EXPORT_TAGS instead of @EXPORT. [Severity 4]

the Perl::Critic::Policy::Modules::ProhibitEvilModules manpage

Ban modules that aren't blessed by your shop. [Severity 5]

the Perl::Critic::Policy::Modules::ProhibitExcessMainComplexity manpage

Minimize complexity in code that is outside of subroutines. [Severity 3]

the Perl::Critic::Policy::Modules::ProhibitMultiplePackages manpage

Put packages (especially subclasses) in separate files. [Severity 4]

the Perl::Critic::Policy::Modules::RequireBarewordIncludes manpage

Write require Module instead of require ''. [Severity 5]

the Perl::Critic::Policy::Modules::RequireEndWithOne manpage

End each module with an explicitly 1; instead of some funky expression. [Severity 4]

the Perl::Critic::Policy::Modules::RequireExplicitPackage manpage

Always make the package explicit. [Severity 4]

the Perl::Critic::Policy::Modules::RequireFilenameMatchesPackage manpage

Package declaration must match filename. [Severity 5]

the Perl::Critic::Policy::Modules::RequireVersionVar manpage

Give every module a $VERSION number. [Severity 2]

the Perl::Critic::Policy::NamingConventions::ProhibitAmbiguousNames manpage

Don't use vague variable or subroutine names like 'last' or 'record'. [Severity 3]

the Perl::Critic::Policy::NamingConventions::ProhibitMixedCaseSubs manpage

Write sub my_function{} instead of sub MyFunction{}. [Severity 1]

the Perl::Critic::Policy::NamingConventions::ProhibitMixedCaseVars manpage

Write $my_variable = 42 instead of $MyVariable = 42. [Severity 1]

the Perl::Critic::Policy::References::ProhibitDoubleSigils manpage

Write @{ $array_ref } instead of @$array_ref. [Severity 2]

the Perl::Critic::Policy::RegularExpressions::ProhibitCaptureWithoutTest manpage

Capture variable used outside conditional. [Severity 3]

the Perl::Critic::Policy::RegularExpressions::ProhibitComplexRegexes manpage

Split long regexps into smaller qr// chunks. [Severity 3]

the Perl::Critic::Policy::RegularExpressions::ProhibitEnumeratedClasses manpage

Use named character classes instead of explicit character lists. [Severity 1]

the Perl::Critic::Policy::RegularExpressions::ProhibitEscapedMetacharacters manpage

Use character classes for literal metachars instead of escapes. [Severity 1]

the Perl::Critic::Policy::RegularExpressions::ProhibitFixedStringMatches manpage

Use eq or hash instead of fixed-pattern regexps. [Severity 2]

the Perl::Critic::Policy::RegularExpressions::ProhibitSingleCharAlternation manpage

Use [abc] instead of a|b|c. [Severity 1]

the Perl::Critic::Policy::RegularExpressions::ProhibitUnusedCapture manpage

Only use a capturing group if you plan to use the captured value. [Severity 3]

the Perl::Critic::Policy::RegularExpressions::ProhibitUnusualDelimiters manpage

Use only // or {} to delimit regexps. [Severity 1]

the Perl::Critic::Policy::RegularExpressions::RequireBracesForMultiline manpage

Use { and } to delimit multi-line regexps. [Severity 1]

the Perl::Critic::Policy::RegularExpressions::RequireExtendedFormatting manpage

Always use the /x modifier with regular expressions. [Severity 3]

the Perl::Critic::Policy::RegularExpressions::RequireLineBoundaryMatching manpage

Always use the /m modifier with regular expressions. [Severity 2]

the Perl::Critic::Policy::Subroutines::ProhibitAmpersandSigils manpage

Don't call functions with a leading ampersand sigil. [Severity 2]

the Perl::Critic::Policy::Subroutines::ProhibitBuiltinHomonyms manpage

Don't declare your own open function. [Severity 4]

the Perl::Critic::Policy::Subroutines::ProhibitExcessComplexity manpage

Minimize complexity by factoring code into smaller subroutines. [Severity 3]

the Perl::Critic::Policy::Subroutines::ProhibitExplicitReturnUndef manpage

Return failure with bare return instead of return undef. [Severity 5]

the Perl::Critic::Policy::Subroutines::ProhibitNestedSubs manpage

sub never { sub correct {} }. [Severity 5]

the Perl::Critic::Policy::Subroutines::ProhibitManyArgs manpage

Too many arguments. [Severity 3]

the Perl::Critic::Policy::Subroutines::ProhibitSubroutinePrototypes manpage

Don't write sub my_function (@@) {}. [Severity 5]

the Perl::Critic::Policy::Subroutines::ProtectPrivateSubs manpage

Prevent access to private subs in other packages. [Severity 3]

the Perl::Critic::Policy::Subroutines::RequireArgUnpacking manpage

Always unpack @_ first. [Severity 4]

the Perl::Critic::Policy::Subroutines::RequireFinalReturn manpage

End every path through a subroutine with an explicit return statement. [Severity 4]

the Perl::Critic::Policy::TestingAndDebugging::ProhibitNoStrict manpage

Prohibit various flavors of no strict. [Severity 5]

the Perl::Critic::Policy::TestingAndDebugging::ProhibitNoWarnings manpage

Prohibit various flavors of no warnings. [Severity 4]

the Perl::Critic::Policy::TestingAndDebugging::ProhibitProlongedStrictureOverride manpage

Don't turn off strict for large blocks of code. [Severity 4]

the Perl::Critic::Policy::TestingAndDebugging::RequireTestLabels manpage

Tests should all have labels. [Severity 3]

the Perl::Critic::Policy::TestingAndDebugging::RequireUseStrict manpage

Always use strict. [Severity 5]

the Perl::Critic::Policy::TestingAndDebugging::RequireUseWarnings manpage

Always use warnings. [Severity 4]

the Perl::Critic::Policy::ValuesAndExpressions::ProhibitCommaSeparatedStatements manpage

Don't use the comma operator as a statement separator. [Severity 4]

the Perl::Critic::Policy::ValuesAndExpressions::ProhibitConstantPragma manpage

Don't use constant $FOO => 15. [Severity 4]

the Perl::Critic::Policy::ValuesAndExpressions::ProhibitEmptyQuotes manpage

Write q{} instead of ''. [Severity 2]

the Perl::Critic::Policy::ValuesAndExpressions::ProhibitEscapedCharacters manpage

Write "\N{DELETE}" instead of "\x7F", etc. [Severity 2]

the Perl::Critic::Policy::ValuesAndExpressions::ProhibitImplicitNewlines manpage

Use concatenation or HEREDOCs instead of literal line breaks in strings. [Severity 3]

the Perl::Critic::Policy::ValuesAndExpressions::ProhibitInterpolationOfLiterals manpage

Always use single quotes for literal strings. [Severity 1]

the Perl::Critic::Policy::ValuesAndExpressions::ProhibitLeadingZeros manpage

Write oct(755) instead of 0755. [Severity 5]

the Perl::Critic::Policy::ValuesAndExpressions::ProhibitLongChainsOfMethodCalls manpage

Long chains of method calls indicate tightly coupled code. [Severity 2]

the Perl::Critic::Policy::ValuesAndExpressions::ProhibitMismatchedOperators manpage

Don't mix numeric operators with string operands, or vice-versa. [Severity 3]

the Perl::Critic::Policy::ValuesAndExpressions::ProhibitMixedBooleanOperators manpage

Write !$foo && $bar || $baz instead of not $foo && $bar or $baz. [Severity 4]

the Perl::Critic::Policy::ValuesAndExpressions::ProhibitNoisyQuotes manpage

Use q{} or qq{} instead of quotes for awkward-looking strings. [Severity 2]

the Perl::Critic::Policy::ValuesAndExpressions::ProhibitQuotesAsQuotelikeOperatorDelimiters manpage

Don't use quotes (', ", `) as delimiters for the quote-like operators. [Severity 3]

the Perl::Critic::Policy::ValuesAndExpressions::ProhibitVersionStrings manpage

Don't use strings like v1.4 or 1.4.5 when including other modules. [Severity 3]

the Perl::Critic::Policy::ValuesAndExpressions::RequireInterpolationOfMetachars manpage

Warns that you might have used single quotes when you really wanted double-quotes. [Severity 1]

the Perl::Critic::Policy::ValuesAndExpressions::RequireNumberSeparators manpage

Write 141_234_397.0145 instead of 141234397.0145 . [Severity 2]

the Perl::Critic::Policy::ValuesAndExpressions::RequireQuotedHeredocTerminator manpage

Write print <<'THE_END' or print <<"THE_END" . [Severity 3]

the Perl::Critic::Policy::ValuesAndExpressions::RequireUpperCaseHeredocTerminator manpage

Write <<'THE_END'; instead of <<'theEnd'; . [Severity 2]

the Perl::Critic::Policy::Variables::ProhibitConditionalDeclarations manpage

Do not write my $foo = $bar if $baz; . [Severity 5]

the Perl::Critic::Policy::Variables::ProhibitLocalVars manpage

Use my instead of local, except when you have to. [Severity 2]

the Perl::Critic::Policy::Variables::ProhibitMatchVars manpage

Avoid $`, $&, $' and their English equivalents. [Severity 4]

the Perl::Critic::Policy::Variables::ProhibitPackageVars manpage

Eliminate globals declared with our or use vars. [Severity 3]

the Perl::Critic::Policy::Variables::ProhibitPerl4PackageNames manpage

Use double colon (::) to separate package name components instead of single quotes ('). [Severity 2]

the Perl::Critic::Policy::Variables::ProhibitPunctuationVars manpage

Write $EVAL_ERROR instead of $@. [Severity 2]

the Perl::Critic::Policy::Variables::ProtectPrivateVars manpage

Prevent access to private vars in other packages. [Severity 3]

the Perl::Critic::Policy::Variables::RequireInitializationForLocalVars manpage

Write local $foo = $bar; instead of just local $foo;. [Severity 3]

the Perl::Critic::Policy::Variables::RequireLexicalLoopIterators manpage

Write for my $element (@list) {...} instead of for $element (@list) {...}. [Severity 5]

the Perl::Critic::Policy::Variables::RequireLocalizedPunctuationVars manpage

Magic variables should be assigned as ``local''. [Severity 4]

the Perl::Critic::Policy::Variables::RequireNegativeIndices manpage

Negative array index should be used. [Severity 4]


Jeffrey Ryan Thalhammer <>


Copyright (c) 2005-2007 Jeffrey Ryan Thalhammer. All rights reserved.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. The full text of this license can be found in the LICENSE file included with this module.

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