Login
RT #69322 - RegularExpressions::ProhibitEnumeratedClasses false positive
authorTom Wyant <harryfmudd@comcast.net>
Thu, 7 Jul 2011 00:15:39 +0000 (00:15 +0000)
committerTom Wyant <harryfmudd@comcast.net>
Thu, 7 Jul 2011 00:15:39 +0000 (00:15 +0000)
on [A-Za-z_]

Added '0-9' to the recognition code.

Changes
lib/Perl/Critic/Policy/RegularExpressions/ProhibitEnumeratedClasses.pm
t/RegularExpressions/ProhibitEnumeratedClasses.run

diff --git a/Changes b/Changes
index 9e190d7..875ebac 100644 (file)
--- a/Changes
+++ b/Changes
@@ -5,6 +5,8 @@ Next release, whenever it is:
       RT #68498.
     * ControlStructures::ProhibitMutatingListFunctions now understands that
       tr///r (introduced in 5.13.7) does not change its operand.
+    * RegularExpressions::ProhibitEnumeratedClasses no longer thinks
+      that [A-Za-z_] matches \w. RT #69322.
     * Subroutines::ProhibitManyArgs now recognizes '+' as a prototype
       character.
     Other Changes:
index faab756..36d644a 100644 (file)
@@ -29,7 +29,7 @@ Readonly::Scalar my $EXPL => [248];
 
 Readonly::Array my @PATTERNS => (  # order matters: most to least specific
    [q{ },'\\t','\\r','\\n']      => ['\\s', '\\S'],
-   ['A-Z','a-z','_']             => ['\\w', '\\W'],
+   ['A-Z','a-z','0-9','_']       => ['\\w', '\\W'], # RT 69322
    ['A-Z','a-z']                 => ['[[:alpha:]]','[[:^alpha:]]'],
    ['A-Z']                       => ['[[:upper:]]','[[:^upper:]]'],
    ['a-z']                       => ['[[:lower:]]','[[:^lower:]]'],
@@ -154,7 +154,7 @@ B<C<[\t\r\n\f\ ]>> vs. B<C<\s>>
 
 B<C<[\t\r\n\ ]>> vs. B<C<\s>>   (because many people forget C<\f>)
 
-B<C<[A-Za-z_]>> vs. B<C<\w>>
+B<C<[A-Za-z0-9_]>> vs. B<C<\w>>
 
 B<C<[A-Za-z]>> vs. B<C<\p{IsAlphabetic}>>
 
index 12c3232..031c7a4 100644 (file)
@@ -31,8 +31,8 @@ m/[\x{ffef}]/; # for code coverage
 m/[A-Z]/;      # \p{Uppercase}
 m/[a-z]/;      # \p{Lowercase}
 m/[0-9]/;      # \d
-m/[A-Za-z_]/;  # \w
-m/[a-z_A-Z]/;  # \w
+m/[A-Za-z0-9_]/;  # \w
+m/[0-9a-z_A-Z]/;  # \w
 m/[a-zA-Z]/;   # \p{Alphabetic}
 m/[ \t\r\n\f]/;# \s
 m/[\ \t\r\n]/; # \s
@@ -56,8 +56,8 @@ m/[\ \t\x{0a}\x{0d}]/; # \s
 m/[^\w]/;       # \W
 m/[^\s]/;       # \S
 m/[^0-9]/;      # \D
-m/[^A-Za-z_]/;  # \W
-m/[^a-z_A-Z]/;  # \W
+m/[^A-Za-z0-9_]/;  # \W
+m/[^0-9a-z_A-Z]/;  # \W
 m/[^a-zA-Z]/;   # \P{Alphabetic}
 m/[^ \t\r\n\f]/;# \S
 m/[^\ \t\r\n]/; # \S