From: Steve Hancock Date: Thu, 24 Aug 2023 17:36:06 +0000 (-0700) Subject: activate ProhibitUnusedCapture and ProhibitCaptureWithoutTest X-Git-Tag: 20230701.04~20 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=6880efdae091441d550c750a14bbf0a62d6944f0;p=perltidy.git activate ProhibitUnusedCapture and ProhibitCaptureWithoutTest This makes a few changes to allow perltidy to pass these these tests. But PerlCritic misses many of these, so I'll fix them as I find them. --- diff --git a/.perlcriticrc b/.perlcriticrc index b6a2fc8f..a8133409 100644 --- a/.perlcriticrc +++ b/.perlcriticrc @@ -113,11 +113,6 @@ max_nests=9 # substr. So skip this one. [-BuiltinFunctions::ProhibitLvalueSubstr] -# 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] diff --git a/lib/Perl/Tidy.pm b/lib/Perl/Tidy.pm index 4c1e51dd..ff72fad2 100644 --- a/lib/Perl/Tidy.pm +++ b/lib/Perl/Tidy.pm @@ -4436,7 +4436,7 @@ sub check_options { # Since perltidy only encodes in utf8, problems can occur if we let it # decode anything else. See discussions for issue git #83. my $encoding = $rOpts->{'character-encoding'}; - if ( $encoding !~ /^\s*(guess|none|utf8|utf-8)\s*$/i ) { + if ( $encoding !~ /^\s*(?:guess|none|utf8|utf-8)\s*$/i ) { Die(<)/ + && $last_nonblank_token !~ /^(?:[\]\}\)\&]|\-\>)/ ) { @@ -4628,7 +4628,7 @@ EOM # 'method' in older scripts. if ( $tok_kw eq 'method' && $guess_if_method ) { if ( $expecting == OPERATOR - || $next_nonblank_token !~ /^(\w|\:)/ + || $next_nonblank_token !~ /^[\w\:]/ || !$self->method_ok_here() ) { $self->do_UNKNOWN_BAREWORD($next_nonblank_token); @@ -4656,7 +4656,7 @@ EOM # package($x) - error if ( $tok_kw eq 'class' ) { if ( $expecting == OPERATOR - || $next_nonblank_token !~ /^(\w|\:)/ + || $next_nonblank_token !~ /^[\w\:]/ || !$self->class_ok_here() ) { $self->do_UNKNOWN_BAREWORD($next_nonblank_token);