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: 56629
Status: open
Priority: 0/
Queue: Perl-Critic

People
Owner: Nobody in particular
Requestors: JARIAALTO [...] cpan.org
Cc:
AdminCc:

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



Subject: Quotes used with an empty string (false positive)
Download (untitled) / with headers
text/plain 203b
Quotes used with an empty string at line 4, column 31. See page 53 of PBP. 1 #!/usr/bin/perl 2 use strict; 3 4 my $var = $debug ? "DEBUG:" : ""; This is a proper initialization.
Subject: Re: [rt.cpan.org #56629] Quotes used with an empty string (false positive)
Date: Thu, 15 Apr 2010 08:11:10 -0500
To: bug-Perl-Critic [...] rt.cpan.org
From: Elliot Shank <perl [...] galumph.com>
Download (untitled) / with headers
text/plain 343b
On 4/15/10 6:33 AM, Jari Aalto via RT wrote: Show quoted text
> Quotes used with an empty string at line 4, column 31. See page 53 of > PBP. > > > 1 #!/usr/bin/perl > 2 use strict; > 3 > 4 my $var = $debug ? "DEBUG:" : ""; > > > This is a proper initialization.
This is a true positive. If you disagree with this policy, disable it.
Download (untitled) / with headers
text/plain 1.9k
On Thu Apr 15 09:11:25 2010, clonezone wrote: Show quoted text
> On 4/15/10 6:33 AM, Jari Aalto via RT wrote:
> > Quotes used with an empty string at line 4, column 31. See page 53
of Show quoted text
> > PBP. > > > > > > 1 #!/usr/bin/perl > > 2 use strict; > > 3 > > 4 > > > > > > This is a proper initialization.
> > This is a true positive. If you disagree with this policy, disable
it. The following the advice of: ValuesAndExpressions::ProhibitEmptyQuotes would produce code that would be unlike in all other languages. The ping-pong with changing quotes ( q() vs qq() ) don't work in real. When the code is later changed and variables are inserted inside quotes, you're forced to "rewrite" quoting syntax again and again. That's no fun at all in a version controlled environments with team of developers. The XPers said it: less is more. Picking one set of quotes keep everything nicely under control. my $debug = "DEBUG:"; Later: my $debug = "DEBUG $LIBRARY:" # No need for quote ping-pong Oh, the Conway's style probably suggests: my $debug = 'DEBUG ' . $LIBRARY; Right. And let's apply that style convention here: my $debug = "$DEBUG:$LIBRARY ($LEVEL)"; Is this the path to the wisdom? Let's see: my $debug = $DEBUG . ':' . $LIBRARY . ' (' . $LEVEL . ')'; # Ouch The special meaning of q() is best reserved for exceptional cases which would make things more readable. Like in cases where double- backslashing can be avoided to actually be able to read the string: my $ascii = '\t\r\n'; The --verbose option could explain the various merits and problems of straight forward suggestions like '' (for literals) and "" (for interpolating). The readers could make an informed decisions whether to keep the style check in effect or not. C.f. "....However, Perl::Critic is not limited to PBP and will even support Policies that contradict Conway." It would be helpful to broaden the description strings.
Subject: Re: [rt.cpan.org #56629] Quotes used with an empty string (false positive)
Date: Mon, 26 Apr 2010 20:00:33 -0500
To: bug-Perl-Critic [...] rt.cpan.org
From: Elliot Shank <perl [...] galumph.com>
Download (untitled) / with headers
text/plain 1.5k
On 4/15/10 11:30 AM, Jari Aalto via RT wrote: Show quoted text
> The following the advice of: > > ValuesAndExpressions::ProhibitEmptyQuotes > > would produce code that would be unlike in all other languages.
So? Show quoted text
> The ping-pong with changing quotes ( q() vs qq() ) don't work in real.
I don't follow. Show quoted text
> The XPers said it: less is more.
They're talking about less code, not what sort of quotes you use. Show quoted text
> Picking one set of quotes keep > everything nicely under control. > > my $debug = "DEBUG:"; > > Later: > > my $debug = "DEBUG $LIBRARY:" # No need for quote ping-pong > > Oh, the Conway's style probably suggests: > > my $debug = 'DEBUG ' . $LIBRARY;
No, it doesn't. He says only to use interpolating expressions if you are actually interpolating. Show quoted text
> Right. And let's apply that style convention here: > > my $debug = "$DEBUG:$LIBRARY ($LEVEL)"; > > Is this the path to the wisdom? Let's see: > > my $debug = $DEBUG . ':' . $LIBRARY . ' (' . $LEVEL . ')'; # Ouch
Specious argument. The way I use quotes indicates /intent/. If you see double quotes in my code, it means I expect there to be interpolation involved. Otherwise, I expect that there won't be. If I'm scanning through some code and I see something in single quotes or within q<>, I know that I don't have to examine it any further to tell whether there's any interpolation happening. Show quoted text
> It would be helpful to broaden the description strings.
The problem is that the output would rapidly scroll off of the top of the screen. You can set the verboseness to include the full description of the policy using "%d".


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.