]> git.donarmstrong.com Git - perltidy.git/commitdiff
update perlcritic settings
authorSteve Hancock <perltidy@users.sourceforge.net>
Wed, 23 Aug 2023 23:01:15 +0000 (16:01 -0700)
committerSteve Hancock <perltidy@users.sourceforge.net>
Wed, 23 Aug 2023 23:01:15 +0000 (16:01 -0700)
.perlcriticrc
lib/Perl/Tidy.pm

index 17814ee6ef1f1bec1c6c452e708713a5fd5c1dc4..f6f7424d4c1b7abe9cca59ade9ecb2250902f32f 100644 (file)
@@ -69,11 +69,10 @@ short_subroutine_statements = 2
 # this can be fixed.
 [-Variables::RequireLocalizedPunctuationVars]
 
-# Unfortunately the perlcritic coding for this policy is buggy when lines=n is
-# specified.  For example if I use lines=n to increase 'n' above the default of
-# 9, then suddenly I get error messages for code which previously passed with
-# the default. So we have to skip this.
-[-InputOutput::RequireBriefOpen]
+# sub 'backup_method_copy' in Perl::Tidy.pm has about 25 lines between open
+# and close, largely comments, so set the limit a bit higher.
+[InputOutput::RequireBriefOpen]
+lines=30
 
 #--------------------------------------------------------------
 # Following is a list of policies to be skipped for severity=3:
@@ -114,15 +113,20 @@ max_nests=9
 # substr.  So skip this one.
 [-BuiltinFunctions::ProhibitLvalueSubstr]
 
-# These would be okay for new code, but do not change any debugged regular
-# expressions without good reason.  It is too easy to introduce a subtle error.
-# A problem with ReqireExtendedFormatting is that it makes things needlessly
-# complex when matching things like line feeds and carriage returns.
-[-RegularExpressions::RequireExtendedFormatting]
-[-RegularExpressions::ProhibitComplexRegexes]
+# There are a few of these in Tidy.pm, Formatter.pm, Tokenizer.pm that
+# could be fixed. Then these lines could be removed.
 [-RegularExpressions::ProhibitUnusedCapture]
 [-RegularExpressions::ProhibitCaptureWithoutTest]
 
+# There is one complex regex in Tokenizer.pm that should be simplified. Then
+# this line can be removed.
+[-RegularExpressions::ProhibitComplexRegexes]
+
+# A problem with ReqireExtendedFormatting is that it makes things needlessly
+# complex when matching things like line feeds and carriage returns. So
+# skip this.
+[-RegularExpressions::RequireExtendedFormatting]
+
 #--------------------------------------------------------------
 # Following is a list of policies to be skipped for severity=2:
 #--------------------------------------------------------------
@@ -132,8 +136,9 @@ max_nests=9
 # loss of code robustness.
 [-BuiltinFunctions::ProhibitUselessTopic]
 
-# These would be okay for new code, but do not change any debugged regular
+# These would be okay for most new code, but do not change any debugged regular
 # expressions without good reason.  It is too easy to introduce a subtle error.
+# So skip these for now.
 [-RegularExpressions::RequireDotMatchAnything]
 [-RegularExpressions::RequireLineBoundaryMatching]
 
@@ -192,13 +197,19 @@ max_nests=9
 # you have a comparison of the form $b->[*] <=> $a->[*]. So skip this.
 [-BuiltinFunctions::ProhibitReverseSortBlock]
 
-# These would be okay for new code, but do not change any debugged regular
-# expressions without good reason.  It is too easy to introduce a subtle error.
+# There are a few of these in perltidy that should be changed.
+[-RegularExpressions::RequireBracesForMultiline]
+
+# There are too many of these in perltidy to change, and they seem fine.
 [-RegularExpressions::ProhibitEscapedMetacharacters]
+
+# As the documentation says, this policy is not for everyone!
 [-RegularExpressions::ProhibitEnumeratedClasses]
-[-RegularExpressions::ProhibitUnusualDelimiters]
-[-RegularExpressions::ProhibitSingleCharAlternation]
-[-RegularExpressions::RequireBracesForMultiline]
+
+# This would be okay if it did not flag alternations of mixed single and
+# multiple characters. For example, it wants to combine the 'h' and '?' here:
+#        /^-(help|h|\?)$/i
+# which would make it harder to read
 [-RegularExpressions::ProhibitSingleCharAlternation]
 
 # Disagree. Double quotes are easier to read than single quotes and allow a
index 7db75d87cb8302e85a77aff0d3232758cdb26825..537125c930edde6a092b6db0e0e689da7e6058c1 100644 (file)
@@ -3114,10 +3114,10 @@ sub fileglob_to_re {
 
     # modified (corrected) from version in find2perl
     my $x = shift;
-    $x =~ s#([./^\$()])#\\$1#g;    # escape special characters
-    $x =~ s#\*#.*#g;               # '*' -> '.*'
-    $x =~ s#\?#.#g;                # '?' -> '.'
-    return "^$x\\z";               # match whole word
+    $x =~ s/([.\/^\$()])/\\$1/g;    # escape special characters
+    $x =~ s/\*/.*/g;                # '*' -> '.*'
+    $x =~ s/\?/./g;                 # '?' -> '.'
+    return "^$x\\z";                # match whole word
 } ## end sub fileglob_to_re
 
 sub make_logfile_header {
@@ -4138,7 +4138,7 @@ sub _process_command_line {
         elsif ( $i =~ /^-(pro|profile)=?$/ ) {
             Die("usage: -pro=filename or --profile=filename, no spaces\n");
         }
-        elsif ( $i =~ /^-(help|h|HELP|H|\?)$/ ) {
+        elsif ( $i =~ /^-(help|h|\?)$/i ) {
             usage();
             Exit(0);
         }