From: Steve Hancock Date: Thu, 24 Aug 2023 22:43:56 +0000 (-0700) Subject: activate PC RegularExpressions::ProhibitSingleCharAlternation X-Git-Tag: 20230701.04~19 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=b9acb738b02b7bbb34588900180e3e300396fe48;p=perltidy.git activate PC RegularExpressions::ProhibitSingleCharAlternation --- diff --git a/.perlcriticrc b/.perlcriticrc index a8133409..38ad7418 100644 --- a/.perlcriticrc +++ b/.perlcriticrc @@ -200,12 +200,6 @@ max_nests=9 # As the documentation says, this policy is not for everyone! [-RegularExpressions::ProhibitEnumeratedClasses] -# 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 # uniform style for quotes. My editor has color coding which indicates # interpolation. Double quotes do not increase processing time by any diff --git a/lib/Perl/Tidy.pm b/lib/Perl/Tidy.pm index ff72fad2..cf348503 100644 --- a/lib/Perl/Tidy.pm +++ b/lib/Perl/Tidy.pm @@ -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|\?)$/i ) { + elsif ( $i =~ /^-(?: help | [ h \? ] )$/xi ) { usage(); Exit(0); } diff --git a/lib/Perl/Tidy/Tokenizer.pm b/lib/Perl/Tidy/Tokenizer.pm index 9654dd25..d29b52b0 100644 --- a/lib/Perl/Tidy/Tokenizer.pm +++ b/lib/Perl/Tidy/Tokenizer.pm @@ -1015,8 +1015,8 @@ sub get_line { # The first test here very significantly speeds things up, but be sure to # keep the regex and hash %other_line_endings the same. if ( $other_line_endings{ substr( $input_line, -1 ) } ) { - if ( $input_line =~ s/((\r|\035|\032)+)$// ) { - $input_line_separator = $2 . $input_line_separator; + if ( $input_line =~ s/([\r\035\032])+$// ) { + $input_line_separator = $1 . $input_line_separator; } } @@ -9035,7 +9035,7 @@ sub is_possible_numerator { $max_token_index ); } - if ( $next_nonblank_token =~ /(\(|\$|\w|\.|\@)/ ) { + if ( $next_nonblank_token =~ / [ \( \$ \w \. \@ ] /x ) { $is_possible_numerator = 1; } elsif ( $next_nonblank_token =~ /^\s*$/ ) {