-severity = 3
+severity = 1
-# verbose = 8 # uncomment to see policy names
+# a helpful link:
+# https://perlmaven.com/perl-critic
+verbose = %f: [%p] %m at line %l, column %c.\n
+
+# Example for single policy on single module:
+# perlcritic --single-policy Subroutines::ProhibitSubroutinePrototypes Module.pm
#--------------------------------------------------------------
# Following is a list of policies to be skipped for severity=4:
#--------------------------------------------------------------
# There is a localization in Tokenizer.pm that is essential
-[-Variables::ProhibitLocalVars]
+[-Variables::ProhibitLocalVars]
# immediate initialization of locals is not appropriate where used
# in the Tokenizer.pm module
-[-Variables::RequireInitializationForLocalVars]
-
-# C-style for loops are avoided because profiling shows them to be slow. But
-# they are still needed for loops over tables with increments > 1. These can
-# be hidden from PerlCritic by writing them over multiple lines.
-# [-ControlStructures::ProhibitCStyleForLoops]
+[-Variables::RequireInitializationForLocalVars]
-# There is a stringy eval in Formatter.pm which is essential.
-[-BuiltinFunctions::ProhibitStringyEval]
+# There is a stringy eval in Formatter.pm which is essential.
+[-BuiltinFunctions::ProhibitStringyEval]
# Tidy.pm exports 'perltidy'. Changing this could break existing scripts.
[-Modules::ProhibitAutomaticExportation]
# print and close homonyms are appropriate where they are used.
[-Subroutines::ProhibitBuiltinHomonyms]
-# Nested subs are needed for error handling in Tidy.pm.
+# Nested subs are needed for error handling in Tidy.pm.
[-Subroutines::ProhibitNestedSubs]
# In critical routines this can significantly reduce processing speed
[-Subroutines::RequireArgUnpacking]
-# constants are needed for clean array indexing.
+# Perl::Tidy uses constants for efficient and robust coding of array indexes
+# and debug code.
[-ValuesAndExpressions::ProhibitConstantPragma]
# Adding quotes on here doc terminators causes needless "line noise" in the
# AUTOLOAD is only used in perltidy to help find and debug programming errors
[-ClassHierarchies::ProhibitAutoloading]
-# These are good general policies but are sometimes hard to avoid
+# These are good policies but can be sometimes hard to avoid without a
+# significant loss of processing efficiency. So they are excluded here but It
+# is worth running them as single policy now and then to see if improvements
+# can be made.
[-Subroutines::ProhibitExcessComplexity]
[-Modules::ProhibitExcessMainComplexity]
[-ControlStructures::ProhibitDeepNests]
[-ControlStructures::ProhibitCascadingIfElse]
-# An 'unless' is sometimes clearer than an 'if'
+# Sometimes an 'unless' is clearer than an 'if'
[-ControlStructures::ProhibitNegativeExpressionsInUnlessAndUntilConditions]
-# $@ is checked
-[-ErrorHandling::RequireCheckingReturnValueOfEval]
+# PerlCritic doesn't seem to recognize when $@ is checked
+[-ErrorHandling::RequireCheckingReturnValueOfEval]
-# this is a good general policy but not always best
+# This is a good general policy but not always the best for efficiency
[-Subroutines::ProhibitManyArgs]
[-ClassHierarchies::ProhibitExplicitISA]
# this is not always useful
[-RegularExpressions::RequireExtendedFormatting]
-# Changing debugged regexes is risky, especially complex regexes
+# Do not change any debugged regular expressions without good reason
[-RegularExpressions::ProhibitComplexRegexes]
-
-# perlcritic does not distinguish between use of parens for capture and for precedence
[-RegularExpressions::ProhibitUnusedCapture]
[-RegularExpressions::ProhibitCaptureWithoutTest]
+
+#--------------------------------------------------------------
+# Following is a list of policies to be skipped for severity=2:
+#--------------------------------------------------------------
+
+# Do not change any debugged regular expressions without good reason
+[-RegularExpressions::RequireDotMatchAnything]
+[-RegularExpressions::RequireLineBoundaryMatching]
+
+# This policy is rather silly
+[-ValuesAndExpressions::ProhibitNoisyQuotes]
+
+# In some cases a postfix control shows the logical flow best
+[-ControlStructures::ProhibitPostfixControls]
+
+# Sometimes an unless block is clearer than an if block
+[-ControlStructures::ProhibitUnlessBlocks]
+
+# The very few instances of boolean grep are fine. Profiling shows that
+# changing them would not result in a measureable improvement in speed.
+[-BuiltinFunctions::ProhibitBooleanGrep]
+
+# The only escaped characters in Perl::Tidy are in code for detecting and
+# setting line endings ( CR and LF ). This is fully debugged coding and
+# best left unchanged.
+[-ValuesAndExpressions::ProhibitEscapedCharacters]
+
+# These have been checked. This is a good idea but has to be turned off because
+# there are many cases where a number has been explained in a comment or is
+# obvious.
+[-ValuesAndExpressions::ProhibitMagicNumbers]
+
+#--------------------------------------------------------------
+# Following is a list of policies to be skipped for severity=1:
+#--------------------------------------------------------------
+
+# This is generally a good policy but occasional capitalization can be quite
+# effective so we have to ignore it:
+[-NamingConventions::Capitalization]
+
+# It would be nice if this option were configurable to skip STDERR and STDOUT
+# which are used by perltidy for debug statements. I don't think {*STDOUT} is
+# preferable to simply STDOUT. So we have to skip it.
+[-InputOutput::RequireBracedFileHandleWithPrint]
+
+# PerlCritic should not suggest this policy for complex sorts because it can
+# change program behavior. And it does not even make sense for sorts on
+# multiple keys, like this one which got flagged in Perl::Tidy
+# @candidates =
+# sort { $b->[1] <=> $a->[1] || $a->[0] <=> $b->[0] } @candidates;
+# Changing the first part requires changing the second part, so either way
+# you have a comparison of the form $b->[*] <=> $a->[*].
+[-BuiltinFunctions::ProhibitReverseSortBlock]
+
+# Do not change any debugged regular expressions without good reason
+[-RegularExpressions::ProhibitEscapedMetacharacters]
+[-RegularExpressions::ProhibitEnumeratedClasses]
+[-RegularExpressions::ProhibitUnusualDelimiters]
+[-RegularExpressions::ProhibitSingleCharAlternation]
+[-RegularExpressions::RequireBracesForMultiline]
+[-RegularExpressions::ProhibitSingleCharAlternation]
+
+# There is room for disagreement on this policy. Double quotes are easier to
+# read than single quotes and allow a uniform style for quotes. My editor has
+# color coding which indicates interpolation. Double quotes do not increase
+# processing time by any measurable amount. If I need to stick a "\n" at the
+# end of a string I don't have to remember to also change the quotes. So
+# skip this:
+[-ValuesAndExpressions::ProhibitInterpolationOfLiterals]
+
+# These have been checked and are correct as written
+[-ValuesAndExpressions::RequireInterpolationOfMetachars]
+
+# Disagree: parens can add clarity and may even be essential
+# i.e. these give different results:
+# my $len1=length $flag ? "yes" : "no";
+# my $len2=length ($flag ? "yes" : "no");
+[-CodeLayout::ProhibitParensWithBuiltins]
+
+# This is OK if we exclude 'print'
+[InputOutput::RequireCheckedSyscalls]
+exclude_functions = print