From: Steve Hancock Date: Wed, 23 Aug 2023 23:01:15 +0000 (-0700) Subject: update perlcritic settings X-Git-Tag: 20230701.03~1 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=f62ff8c5a5ed3a48dc1a4ceefb9bff03684cde77;p=perltidy.git update perlcritic settings --- diff --git a/.perlcriticrc b/.perlcriticrc index 17814ee6..f6f7424d 100644 --- a/.perlcriticrc +++ b/.perlcriticrc @@ -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 diff --git a/lib/Perl/Tidy.pm b/lib/Perl/Tidy.pm index 7db75d87..537125c9 100644 --- a/lib/Perl/Tidy.pm +++ b/lib/Perl/Tidy.pm @@ -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); }