Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the Perl-Critic CPAN distribution.

Report information
The Basics
Id: 38530
Status: resolved
Priority: 0/
Queue: Perl-Critic

People
Owner: Nobody in particular
Requestors: user42 [...] zip.com.au
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: RequireInterpolationOfMetachars allow double backslashes
Date: Sun, 17 Aug 2008 11:51:59 +1000
To: bug-perl-critic [...] rt.cpan.org
From: Kevin Ryde <user42 [...] zip.com.au>
Where RequireInterpolationOfMetachars warns about '\t' it also warns about a correctly escaped '\\t'. perlcritic --single-policy=RequireInterpolation metatab.pl => String *may* require interpolation at line 1, column 11. See page 51 of PBP. (Severity: 1) I guess there's a chance you've miscounted your backslashes, but I think the default could be to take doubled backslashes at face value and consider them correct. So the warning would be only for '\t' and similar with an odd number of preceding backslashes. Maybe a pattern for that, along the lines of other ProhibitInterpolation, could be like (^|[^\\])\\(\\\\)*[tnrf...

Message body is not shown because sender requested not to inline it.

Subject: Re: [rt.cpan.org #38530] RequireInterpolationOfMetachars allow double backslashes
Date: Sat, 16 Aug 2008 22:25:18 -0500
To: bug-Perl-Critic [...] rt.cpan.org
From: Elliot Shank <perl [...] galumph.com>
Kevin Ryde via RT wrote: Show quoted text
> Where RequireInterpolationOfMetachars warns about '\t' it also warns > about a correctly escaped '\\t'.
And exactly how is the policy supposed to know that? Since the backslash is ignored in single quotes, it looks like an intent to escape a backslash. It doesn't matter that the "t" comes after.
Subject: Re: [rt.cpan.org #38530] RequireInterpolationOfMetachars allow double backslashes
Date: Tue, 19 Aug 2008 11:53:26 +1000
To: bug-Perl-Critic [...] rt.cpan.org
From: Kevin Ryde <user42 [...] zip.com.au>
"Elliot Shank via RT" <bug-Perl-Critic@rt.cpan.org> writes: Show quoted text
> > Since the backslash is ignored in single quotes,
I believe it's used for literal single quote and literal backslash, eg. print 'a backslash \\ and a single \' ...'; => a backslash \ and a single ' ... as described in perldata "Scalar value constructors" double-quoted string literals are subject to backslash and variable substitution; single-quoted strings are not (except for "\'" and "\\"). (I'm not so sure about q{}, but start with '' at least ...)
Subject: Re: [rt.cpan.org #38530] RequireInterpolationOfMetachars allow double backslashes
Date: Thu, 21 Aug 2008 09:33:43 -0700
To: "bug-Perl-Critic [...] rt.cpan.org" <bug-Perl-Critic [...] rt.cpan.org>
From: Jeffrey Thalhammer <jeff [...] imaginative-software.com>
Thanks for reporting this. I'll see if we can improve this somehow. -Jeff On Aug 16, 2008, at 6:52 PM, "Kevin Ryde via RT" <bug-Perl-Critic@rt.cpan.org Show quoted text
> wrote:
Show quoted text
> Sat Aug 16 21:52:31 2008: Request 38530 was acted upon. > Transaction: Ticket created by user42@zip.com.au > Queue: Perl-Critic > Subject: RequireInterpolationOfMetachars allow double backslashes > Broken in: (no value) > Severity: (no value) > Owner: Nobody > Requestors: user42@zip.com.au > Status: new > Ticket <URL: http://rt.cpan.org/Ticket/Display.html?id=38530 > > > > Where RequireInterpolationOfMetachars warns about '\t' it also warns > about a correctly escaped '\\t'. > > perlcritic --single-policy=RequireInterpolation metatab.pl > => > String *may* require interpolation at line 1, column 11. See > page 51 of PBP. (Severity: 1) > > I guess there's a chance you've miscounted your backslashes, but I > think > the default could be to take doubled backslashes at face value and > consider them correct. So the warning would be only for '\t' and > similar with an odd number of preceding backslashes. > > Maybe a pattern for that, along the lines of other > ProhibitInterpolation, could be like > > (^|[^\\])\\(\\\\)*[tnrf... > > > my $str = '\\table';
I have been working on this in branch rt38530. Sorry for branching the world; I'll do better next time. I _think_ I've got this done. I basically accepted the suggested regular expression, but made the parentheses non-capturing and used \A instead of ^ in the first parenthesis. Tests were added to demonstrate the problem. They fail without the change, and succeed with it.