Perl::Critic::PolicySummary(3)

NAME
Perl::Critic::PolicySummary - Descriptions of the Policy modules included with Perl::Critic itself.

DESCRIPTION
The following Policy modules are distributed with Perl::Critic. (There are additional Policies that can be found in add-on distributions.) 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 (try "perlcritic --profile-proto" for a starting version). See the documentation of each module for its specific details.

POLICIES

  BuiltinFunctions::ProhibitBooleanGrep
Use "any" from "List::Util", "List::SomeUtils", or "List::MoreUtils" instead of "grep" in boolean context. [Default severity 2]

  BuiltinFunctions::ProhibitComplexMappings
Map blocks should have a single statement. [Default severity 3]

  BuiltinFunctions::ProhibitLvalueSubstr
Use 4-argument "substr" instead of writing "substr($foo, 2, 6) = $bar". [Default severity 3]

  BuiltinFunctions::ProhibitReverseSortBlock
Forbid $b before $a in sort blocks. [Default severity 1]

  BuiltinFunctions::ProhibitShiftRef
Prohibit "\shift" in code [Default severity 3]

  BuiltinFunctions::ProhibitSleepViaSelect
Use Time::HiRes instead of something like "select(undef, undef, undef, .05)". [Default severity 5]

  BuiltinFunctions::ProhibitStringyEval
Write "eval { my $foo; bar($foo) }" instead of "eval "my $foo; bar($foo);"". [Default severity 5]

  BuiltinFunctions::ProhibitStringySplit
Write "split /-/, $string" instead of "split '-', $string". [Default severity 2]

  BuiltinFunctions::ProhibitUniversalCan
Write "eval { $foo->can($name) }" instead of "UNIVERSAL::can($foo, $name)". [Default severity 3]

  BuiltinFunctions::ProhibitUniversalIsa
Write "eval { $foo->isa($pkg) }" instead of "UNIVERSAL::isa($foo, $pkg)". [Default severity 3]

  BuiltinFunctions::ProhibitUselessTopic
Don't pass $_ to built-in functions that assume it, or to most filetest operators. [Default severity 2]

  BuiltinFunctions::ProhibitVoidGrep
Don't use "grep" in void contexts. [Default severity 3]

  BuiltinFunctions::ProhibitVoidMap
Don't use "map" in void contexts. [Default severity 3]

  BuiltinFunctions::RequireBlockGrep
Write "grep { /$pattern/ } @list" instead of "grep /$pattern/, @list". [Default severity 4]

  BuiltinFunctions::RequireBlockMap
Write "map { /$pattern/ } @list" instead of "map /$pattern/, @list". [Default severity 4]

  BuiltinFunctions::RequireGlobFunction
Use "glob q{*}" instead of <*>. [Default severity 5]

  BuiltinFunctions::RequireSimpleSortBlock
Sort blocks should have a single statement. [Default severity 3]

  ClassHierarchies::ProhibitAutoloading
AUTOLOAD methods should be avoided. [Default severity 3]

  ClassHierarchies::ProhibitExplicitISA
Employ "use parent" instead of @ISA. [Default severity 3]

  ClassHierarchies::ProhibitOneArgBless
Write "bless {}, $class;" instead of just "bless {};". [Default severity 5]

  CodeLayout::ProhibitHardTabs
Use spaces instead of tabs. [Default severity 3]

  CodeLayout::ProhibitParensWithBuiltins
Write "open $handle, $path" instead of "open($handle, $path)". [Default severity 1]

  CodeLayout::ProhibitQuotedWordLists
Write "qw(foo bar baz)" instead of "('foo', 'bar', 'baz')". [Default severity 2]

  CodeLayout::ProhibitTrailingWhitespace
Don't use whitespace at the end of lines. [Default severity 1]

  CodeLayout::RequireConsistentNewlines
Use the same newline through the source. [Default severity 4]

  CodeLayout::RequireTidyCode
Must run code through perltidy. [Default severity 1]

  CodeLayout::RequireTrailingCommas
Put a comma at the end of every multi-line list declaration, including the last one. [Default severity 1]

  ControlStructures::ProhibitCStyleForLoops
Write for(0..20) instead of "for($i=0; $i<=20; $i++)". [Default severity 2]

  ControlStructures::ProhibitCascadingIfElse
Don't write long "if-elsif-elsif-elsif-elsif...else" chains. [Default severity 3]

  ControlStructures::ProhibitDeepNests
Don't write deeply nested loops and conditionals. [Default severity 3]

  ControlStructures::ProhibitLabelsWithSpecialBlockNames
Don't use labels that are the same as the special block names. [Default severity 4]

  ControlStructures::ProhibitMutatingListFunctions
Don't modify $_ in list functions. [Default severity 5]

  ControlStructures::ProhibitNegativeExpressionsInUnlessAndUntilConditions
Don't use operators like "not", "!~", and "le" within "until" and "unless". [Default severity 3]

  ControlStructures::ProhibitPostfixControls
Write "if($condition){ do_something() }" instead of "do_something() if $condition". [Default severity 2]

  ControlStructures::ProhibitUnlessBlocks
Write "if(! $condition)" instead of unless($condition). [Default severity 2]

  ControlStructures::ProhibitUnreachableCode
Don't write code after an unconditional "die, exit, or next". [Default severity 4]

  ControlStructures::ProhibitUntilBlocks
Write "while(! $condition)" instead of until($condition). [Default severity 2]

  ControlStructures::ProhibitYadaOperator
Never use "..." in production code. [Default severity 4]

  Documentation::PodSpelling
Check your spelling. [Default severity 1]

  Documentation::RequirePackageMatchesPodName
The "=head1 NAME" section should match the package. [Default severity 1]

  Documentation::RequirePodAtEnd
All POD should be after "__END__". [Default severity 1]

  Documentation::RequirePodSections
Organize your POD into the customary sections. [Default severity 2]

  ErrorHandling::RequireCarping
Use functions from Carp instead of "warn" or "die". [Default severity 3]

  ErrorHandling::RequireCheckingReturnValueOfEval
You can't depend upon the value of $@/$EVAL_ERROR to tell whether an "eval" failed. [Default severity 3]

  InputOutput::ProhibitBacktickOperators
Discourage stuff like "@files = `ls $directory`". [Default severity 3]

  InputOutput::ProhibitBarewordDirHandles
Write "opendir my $dh, $dirname;" instead of "opendir DH, $dirname;". [Default severity 5]

  InputOutput::ProhibitBarewordFileHandles
Write "open my $fh, q{<}, $filename;" instead of "open FH, q{<}, $filename;". [Default severity 5]

  InputOutput::ProhibitExplicitStdin
Use "<>" or "<ARGV>" or a prompting module instead of "<STDIN>". [Default severity 4]

  InputOutput::ProhibitInteractiveTest
Use prompt() instead of -t. [Default severity 5]

  InputOutput::ProhibitJoinedReadline
Use "local $/ = undef" or Path::Tiny instead of joined readline. [Default severity 3]

  InputOutput::ProhibitOneArgSelect
Never write select($fh). [Default severity 4]

  InputOutput::ProhibitReadlineInForLoop
Write "while( $line = <> ){...}" instead of "for(<>){...}". [Default severity 4]

  InputOutput::ProhibitTwoArgOpen
Write "open $fh, q{<}, $filename;" instead of "open $fh, "<$filename";". [Default severity 5]

  InputOutput::RequireBracedFileHandleWithPrint
Write "print {$FH} $foo, $bar;" instead of "print $FH $foo, $bar;". [Default severity 1]

  InputOutput::RequireBriefOpen
Close filehandles as soon as possible after opening them. [Default severity 4]

  InputOutput::RequireCheckedClose
Write "my $error = close $fh;" instead of "close $fh;". [Default severity 2]

  InputOutput::RequireCheckedOpen
Write "my $error = open $fh, $mode, $filename;" instead of "open $fh, $mode, $filename;". [Default severity 3]

  InputOutput::RequireCheckedSyscalls
Return value of flagged function ignored. [Default severity 1]

  InputOutput::RequireEncodingWithUTF8Layer
Write "open $fh, q{<:encoding(UTF-8)}, $filename;" instead of "open $fh, q{<:utf8}, $filename;". [Default severity 5]

  Miscellanea::ProhibitFormats
Do not use "format". [Default severity 3]

  Miscellanea::ProhibitTies
Do not use "tie". [Default severity 2]

  Miscellanea::ProhibitUnrestrictedNoCritic
Forbid a bare "## no critic" [Default severity 3]

  Miscellanea::ProhibitUselessNoCritic
Remove ineffective "## no critic" annotations. [Default severity 2]

  Modules::ProhibitAutomaticExportation
Export symbols via @EXPORT_OK or %EXPORT_TAGS instead of @EXPORT. [Default severity 4]

  Modules::ProhibitConditionalUseStatements
Avoid putting conditional logic around compile-time includes. [Default severity 3]

  Modules::ProhibitEvilModules
Ban modules that aren't blessed by your shop. [Default severity 5]

  Modules::ProhibitExcessMainComplexity
Minimize complexity in code that is outside of subroutines. [Default severity 3]

  Modules::ProhibitMultiplePackages
Put packages (especially subclasses) in separate files. [Default severity 4]

  Modules::RequireBarewordIncludes
Write "require Module" instead of "require 'Module.pm'". [Default severity 5]

  Modules::RequireEndWithOne
End each module with an explicitly "1;" instead of some funky expression. [Default severity 4]

  Modules::RequireExplicitPackage
Always make the "package" explicit. [Default severity 4]

  Modules::RequireFilenameMatchesPackage
Package declaration must match filename. [Default severity 5]

  Modules::RequireNoMatchVarsWithUseEnglish
"use English" must be passed a "-no_match_vars" argument. [Default severity 2]

  Modules::RequireVersionVar
Give every module a $VERSION number. [Default severity 2]

  NamingConventions::Capitalization
Distinguish different program components by case. [Default severity 1]

  NamingConventions::ProhibitAmbiguousNames
Don't use vague variable or subroutine names like 'last' or 'record'. [Default severity 3]

  Objects::ProhibitIndirectSyntax
Prohibit indirect object call syntax. [Default severity 4]

  References::ProhibitDoubleSigils
Write "@{ $array_ref }" instead of @$array_ref. [Default severity 2]

  RegularExpressions::ProhibitCaptureWithoutTest
Capture variable used outside conditional. [Default severity 3]

  RegularExpressions::ProhibitComplexRegexes
Split long regexps into smaller "qr//" chunks. [Default severity 3]

  RegularExpressions::ProhibitEnumeratedClasses
Use named character classes instead of explicit character lists. [Default severity 1]

  RegularExpressions::ProhibitEscapedMetacharacters
Use character classes for literal meta-characters instead of escapes. [Default severity 1]

  RegularExpressions::ProhibitFixedStringMatches
Use "eq" or hash instead of fixed-pattern regexps. [Default severity 2]

  RegularExpressions::ProhibitSingleCharAlternation
Use "[abc]" instead of "a|b|c". [Default severity 1]

  RegularExpressions::ProhibitUnusedCapture
Only use a capturing group if you plan to use the captured value. [Default severity 3]

  RegularExpressions::ProhibitUnusualDelimiters
Use only "//" or "{}" to delimit regexps. [Default severity 1]

  RegularExpressions::ProhibitUselessTopic
Don't use $_ to match against regexes. [Default severity 2]

  RegularExpressions::RequireBracesForMultiline
Use "{" and "}" to delimit multi-line regexps. [Default severity 1]

  RegularExpressions::RequireDotMatchAnything
Always use the "/s" modifier with regular expressions. [Default severity 2]

  RegularExpressions::RequireExtendedFormatting
Always use the "/x" modifier with regular expressions. [Default severity 3]

  RegularExpressions::RequireLineBoundaryMatching
Always use the "/m" modifier with regular expressions. [Default severity 2]

  Subroutines::ProhibitAmpersandSigils
Don't call functions with a leading ampersand sigil. [Default severity 2]

  Subroutines::ProhibitBuiltinHomonyms
Don't declare your own "open" function. [Default severity 4]

  Subroutines::ProhibitExcessComplexity
Minimize complexity by factoring code into smaller subroutines. [Default severity 3]

  Subroutines::ProhibitExplicitReturnUndef
Return failure with bare "return" instead of "return undef". [Default severity 5]

  Subroutines::ProhibitManyArgs
Too many arguments. [Default severity 3]

  Subroutines::ProhibitNestedSubs
"sub never { sub correct {} }". [Default severity 5]

  Subroutines::ProhibitReturnSort
Behavior of "sort" is not defined if called in scalar context. [Default severity 5]

  Subroutines::ProhibitSubroutinePrototypes
Don't write "sub my_function (@@) {}". [Default severity 5]

  Subroutines::ProhibitUnusedPrivateSubroutines
Prevent unused private subroutines. [Default severity 3]

  Subroutines::ProtectPrivateSubs
Prevent access to private subs in other packages. [Default severity 3]

  Subroutines::RequireArgUnpacking
Always unpack @_ first. [Default severity 4]

  Subroutines::RequireFinalReturn
End every path through a subroutine with an explicit "return" statement. [Default severity 4]

  TestingAndDebugging::ProhibitNoStrict
Prohibit various flavors of "no strict". [Default severity 5]

  TestingAndDebugging::ProhibitNoWarnings
Prohibit various flavors of "no warnings". [Default severity 4]

  TestingAndDebugging::ProhibitProlongedStrictureOverride
Don't turn off strict for large blocks of code. [Default severity 4]

  TestingAndDebugging::RequireTestLabels
Tests should all have labels. [Default severity 3]

  TestingAndDebugging::RequireUseStrict
Always "use strict". [Default severity 5]

  TestingAndDebugging::RequireUseWarnings
Always "use warnings". [Default severity 4]

  ValuesAndExpressions::ProhibitCommaSeparatedStatements
Don't use the comma operator as a statement separator. [Default severity 4]

  ValuesAndExpressions::ProhibitComplexVersion
Prohibit version values from outside the module. [Default severity 3]

  ValuesAndExpressions::ProhibitConstantPragma
Don't "use constant FOO => 15". [Default severity 4]

  ValuesAndExpressions::ProhibitEmptyQuotes
Write "q{}" instead of ''. [Default severity 2]

  ValuesAndExpressions::ProhibitEscapedCharacters
Write "\N{DELETE}" instead of "\x7F", etc. [Default severity 2]

  ValuesAndExpressions::ProhibitImplicitNewlines
Use concatenation or HEREDOCs instead of literal line breaks in strings. [Default severity 3]

  ValuesAndExpressions::ProhibitInterpolationOfLiterals
Always use single quotes for literal strings. [Default severity 1]

  ValuesAndExpressions::ProhibitLeadingZeros
Write oct(755) instead of 0755. [Default severity 5]

  ValuesAndExpressions::ProhibitLongChainsOfMethodCalls
Long chains of method calls indicate tightly coupled code. [Default severity 2]

  ValuesAndExpressions::ProhibitMagicNumbers
Don't use values that don't explain themselves. [Default severity 2]

  ValuesAndExpressions::ProhibitMismatchedOperators
Don't mix numeric operators with string operands, or vice-versa. [Default severity 3]

  ValuesAndExpressions::ProhibitMixedBooleanOperators
Write " !$foo && $bar || $baz " instead of " not $foo && $bar or $baz". [Default severity 4]

  ValuesAndExpressions::ProhibitNoisyQuotes
Use "q{}" or "qq{}" instead of quotes for awkward-looking strings. [Default severity 2]

  ValuesAndExpressions::ProhibitQuotesAsQuotelikeOperatorDelimiters
Don't use quotes ("'", """, "`") as delimiters for the quote-like operators. [Default severity 3]

  ValuesAndExpressions::ProhibitSpecialLiteralHeredocTerminator
Don't write " print <<'__END__' ". [Default severity 3]

  ValuesAndExpressions::ProhibitVersionStrings
Don't use strings like "v1.4" or 1.4.5 when including other modules. [Default severity 3]

  ValuesAndExpressions::RequireConstantVersion
Require $VERSION to be a constant rather than a computed value. [Default severity 2]

  ValuesAndExpressions::RequireInterpolationOfMetachars
Warns that you might have used single quotes when you really wanted double-quotes. [Default severity 1]

  ValuesAndExpressions::RequireNumberSeparators
Write " 141_234_397.0145 " instead of 141234397.0145 . [Default severity 2]

  ValuesAndExpressions::RequireQuotedHeredocTerminator
Write " print <<'THE_END' " or " print <<"THE_END" ". [Default severity 3]

  ValuesAndExpressions::RequireUpperCaseHeredocTerminator
Write " <<'THE_END'; " instead of " <<'theEnd'; ". [Default severity 2]

  Variables::ProhibitAugmentedAssignmentInDeclaration
Do not write " my $foo .= 'bar'; ". [Default severity 4]

  Variables::ProhibitConditionalDeclarations
Do not write " my $foo = $bar if $baz; ". [Default severity 5]

  Variables::ProhibitEvilVariables
Ban variables that aren't blessed by your shop. [Default severity 5]

  Variables::ProhibitLocalVars
Use "my" instead of "local", except when you have to. [Default severity 2]

  Variables::ProhibitMatchVars
Avoid "$`", $&, "$'" and their English equivalents. [Default severity 4]

  Variables::ProhibitPackageVars
Eliminate globals declared with "our" or "use vars". [Default severity 3]

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

  Variables::ProhibitPunctuationVars
Write $EVAL_ERROR instead of $@. [Default severity 2]

  Variables::ProhibitReusedNames
Do not reuse a variable name in a lexical scope [Default severity 3]

  Variables::ProhibitUnusedVariables
Don't ask for storage you don't need. [Default severity 3]

  Variables::ProtectPrivateVars
Prevent access to private vars in other packages. [Default severity 3]

  Variables::RequireInitializationForLocalVars
Write "local $foo = $bar;" instead of just "local $foo;". [Default severity 3]

  Variables::RequireLexicalLoopIterators
Write "for my $element (@list) {...}" instead of "for $element (@list) {...}". [Default severity 5]

  Variables::RequireLocalizedPunctuationVars
Magic variables should be assigned as "local". [Default severity 4]

  Variables::RequireNegativeIndices
Negative array index should be used. [Default severity 4]

VERSION
This is part of Perl::Critic version 1.126.

AUTHOR
Jeffrey Ryan Thalhammer <jeff@imaginative-software.com>

COPYRIGHT
Copyright (c) 2005-2011 Imaginative Software Systems. 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.