]> git.donarmstrong.com Git - perltidy.git/commitdiff
activate PC RegularExpressions::ProhibitSingleCharAlternation
authorSteve Hancock <perltidy@users.sourceforge.net>
Thu, 24 Aug 2023 22:43:56 +0000 (15:43 -0700)
committerSteve Hancock <perltidy@users.sourceforge.net>
Thu, 24 Aug 2023 22:43:56 +0000 (15:43 -0700)
.perlcriticrc
lib/Perl/Tidy.pm
lib/Perl/Tidy/Tokenizer.pm

index a8133409782af897758484582e1192141f27a8b4..38ad7418d99e54292106145301fd4f9cba432ec3 100644 (file)
@@ -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
index ff72fad2578b0259d7bbd9dc0429575b0be88368..cf3485038d426a54fa52aba11bc0bfa968c074b6 100644 (file)
@@ -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);
         }
index 9654dd255a5ee60b6e1cda868774fe6cfdfcc9b1..d29b52b0b939b3160b1488a48880b304aa179d81 100644 (file)
@@ -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*$/ ) {