Subject: | Single paren in quoted string triggers "noisy string" warning |
The following code snippet
package Foo;
use warnings;
use strict;
my $f = '(' . ')';
1;
triggers these warnings, which I think are false positives:
Quotes used with a noisy string at line 4, column 9. See page 53 of PBP.
Quotes used with a noisy string at line 4, column 15. See page 53 of PBP.
On page 54 of PBP, Damian suggests that the following is OK:
my $printable_list = '(' . join(q{,}, @list) . ')';
indicating that quoted single parens are OK. In fact, I think that the q{} notation with any brace (like q{(} ) is much harder to read. So, I would suggest that bracing characters be excluded from this policy. Perhaps change this code in lib/Perl/Critic/Policy/ValuesAndExpressions/ProhibitNoisyQuotes.pm
my @matches = grep { m{\A ["|'] \W{1,2} ['|"] \z}x } @{$doubles_ref}, @{$singles_ref};
to this:
my @matches = grep { m{\A ["|'] [^\w(){}[\]<>]{1,2} ['|"] \z}x } @{$doubles_ref}, @{$singles_ref};
(Also, I'm curious why the ["|'] changes to ['|"] in the above. Is there a reason, like making a text editor happy, or is that a typo?)