Subject: | Left curlys as literals in regexps are deprecated |
The use of left curly brackets ("{") as literals in regular expressions
is deprecated, and as of Perl 5.17.0 produces a compiler warning. Given
the code policies required for self-compliance, the solution is to make
them into a singleton character class (i.e. "[{]").
A change in the version of PPIx::Regexp was also done, because that also
turned out to have literal curlies (blush!).
I'm calling this unimportant because it will be a year before production
code starts to complain.
The fix has been prepared and tested (under Perl 5.14.2, 5.16.0 and
5.17.0, though n=1 for each Perl). It will be committed shortly after
the creation of this ticket. An svn diff of the substantive portion of
the change (i.e. not the 'Changes' file entry) is attached.
Subject: | LiteralCurly.diff |
Index: lib/Perl/Critic/Policy/CodeLayout/RequireTidyCode.pm
===================================================================
--- lib/Perl/Critic/Policy/CodeLayout/RequireTidyCode.pm (revision 4121)
+++ lib/Perl/Critic/Policy/CodeLayout/RequireTidyCode.pm (working copy)
@@ -76,7 +76,7 @@
# Remove the shell fix code from the top of program, if applicable
## no critic (ProhibitComplexRegexes)
my $shebang_re = qr< [#]! [^\015\012]+ [\015\012]+ >xms;
- my $shell_re = qr<eval [ ] 'exec [ ] [^\015\012]* [ ] \$0 [ ] \${1[+]"\$@"}'
+ my $shell_re = qr<eval [ ] 'exec [ ] [^\015\012]* [ ] \$0 [ ] \$[{]1[+]"\$@"}'
[ \t]*[\012\015]+ [ \t]* if [^\015\012]+ [\015\012]+ >xms;
$source =~ s/\A ($shebang_re) $shell_re /$1/xms;
Index: lib/Perl/Critic/Document.pm
===================================================================
--- lib/Perl/Critic/Document.pm (revision 4121)
+++ lib/Perl/Critic/Document.pm (working copy)
@@ -548,7 +548,7 @@
# fixing strings. This matches most of the ones I've found in my own Perl
# distribution, but it may not be bullet-proof.
- my $fixin_rx = qr<^eval 'exec .* \$0 \${1[+]"\$@"}'\s*[\r\n]\s*if.+;>ms; ## no critic (ExtendedFormatting)
+ my $fixin_rx = qr<^eval 'exec .* \$0 \$[{]1[+]"\$@"}'\s*[\r\n]\s*if.+;>ms; ## no critic (ExtendedFormatting)
if ( $first_stmnt =~ $fixin_rx ) {
my $line = $first_stmnt->location->[0];
$self->{_disabled_line_map}->{$line}->{ALL} = 1;
===================================================================
--- inc/Perl/Critic/BuildUtilities.pm (revision 4121)
+++ inc/Perl/Critic/BuildUtilities.pm (working copy)
@@ -58,7 +58,7 @@
'PPI::Node' => '1.215',
'PPI::Token::Quote::Single' => '1.215',
'PPI::Token::Whitespace' => '1.215',
- 'PPIx::Regexp' => '0.022', # RT 72151
+ 'PPIx::Regexp' => '0.027', # Literal { deprecated in re
'PPIx::Utilities::Node' => '1.001',
'PPIx::Utilities::Statement' => '1.001',
'Perl::Tidy' => 0,