Subject: | False positive in RequireUpperCaseHeredocTerminator |
If a heredoc terminator is quoted with whitespace between the << and the
terminator, it fails to match the regular expression in the
RequireUpperCaseHeredocTerminator policy, potentially producing a
spurious policy violation. Example case:
my $text = << "END_TEXT";
text here
END_TEXT
The attached patch changes the regex to allow whitespace if it is
followed by a single or double quote.
Subject: | perlcritic_heredoc.patch |
--- Perl/Critic/Policy/ValuesAndExpressions/RequireUpperCaseHeredocTerminator.pm.org 2007-05-10 17:28:16.000000000 -0400
+++ Perl/Critic/Policy/ValuesAndExpressions/RequireUpperCaseHeredocTerminator.pm 2007-05-10 17:31:13.000000000 -0400
@@ -16,7 +16,7 @@
#-----------------------------------------------------------------------------
-my $heredoc_rx = qr{ \A << ["|']? [A-Z_] [A-Z0-9_]* ['|"]? \z }x;
+my $heredoc_rx = qr{ \A << (?: \s* ["|'])? [A-Z_] [A-Z0-9_]* ['|"]? \z }x;
my $desc = q{Heredoc terminator not alphanumeric and upper-case};
my $expl = [ 64 ];