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

People
Owner: Nobody in particular
Requestors: perl [...] galumph.com
Cc:
AdminCc:

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



CC: Heiko <heiko [...] hexco.de>
Subject: RequireLocalizedPunctuationVars doesn't handle lexicalized $a and $b.
Date: Sun, 09 Mar 2008 16:58:52 -0500
To: bug-Perl-Critic [...] rt.cpan.org
From: Elliot Shank <perl [...] galumph.com>
Variables::RequireLocalizedPunctuationVars.pm gives Magic variables should be assigned as "local" at line 11, column 15. See pages 81,82 of PBP. (Severity: 4) Magic variables should be assigned as "local" at line 12, column 15. See pages 81,82 of PBP. (Severity: 4) on this code: for my $entry ( sort { my @a = split m{,}xms, $a; my @b = split m{,}xms, $b; $a[0] cmp $b[0] || $a[1] <=> $b[1] } qw( b,6 c,3 ) ) { print; } While '$a' is a punctuation variable, 'my @a' is none (and 'my $a' would also be none). The patch makes sure to return without a violation in the presence of 'my' or 'local'. If there were a list of punctuation variables to consult including sigils, this false alarm would vanish also.
--- RequireLocalizedPunctuationVars.pm.org 2008-02-25 23:28:36.890625000 +0100 +++ RequireLocalizedPunctuationVars.pm.new 2008-02-23 23:55:53.046875000 +0100 @@ -58,7 +58,7 @@ # Quick exit if in good form my $modifier = $elem->sprevious_sibling; return if $modifier && $modifier->isa('PPI::Token::Word') - && $modifier eq 'local'; + && ($modifier eq 'local' || $modifier eq 'my'); # Implementation note: Can't rely on PPI::Token::Magic, # unfortunately, because we need English too
Subject: Re: [rt.cpan.org #33937] RequireLocalizedPunctuationVars doesn't handle lexicalized $a and $b.
Date: Sun, 09 Mar 2008 19:05:59 -0500
To: bug-Perl-Critic [...] rt.cpan.org
From: Elliot Shank <perl [...] galumph.com>
Elliot Shank via RT wrote: Show quoted text
> Variables::RequireLocalizedPunctuationVars.pm gives > Magic variables should be assigned as "local" at line 11, column 15. See pages 81,82 of PBP. (Severity: 4) > Magic variables should be assigned as "local" at line 12, column 15. See pages 81,82 of PBP. (Severity: 4) > > on this code: > for my $entry ( > sort { > my @a = split m{,}xms, $a; > my @b = split m{,}xms, $b; > $a[0] cmp $b[0] || $a[1] <=> $b[1] > } qw( b,6 c,3 ) > ) > { > print; > } > > While '$a' is a punctuation variable, 'my @a' is none (and 'my $a' > would also be none). The patch makes sure to return without a > violation in the presence of 'my' or 'local'. If there were a list of > punctuation variables to consult including sigils, this false alarm > would vanish also.
This is something I hope I never see in any code that I deal with. However, it is not the job of this specific policy to complain about that. Applied.
Subject: Re: [rt.cpan.org #33937] RequireLocalizedPunctuationVars doesn't handle lexicalized $a and $b.
Date: Sun, 9 Mar 2008 21:59:41 -0500
To: bug-Perl-Critic [...] rt.cpan.org
From: Chris Dolan <chris [...] chrisdolan.net>
On Mar 9, 2008, at 7:06 PM, Elliot Shank via RT wrote: Show quoted text
> Queue: Perl-Critic > Ticket <URL: http://rt.cpan.org/Ticket/Display.html?id=33937 > > > Elliot Shank via RT wrote:
>> sort { >> my @a = split m{,}xms, $a; >> my @b = split m{,}xms, $b; >> $a[0] cmp $b[0] || $a[1] <=> $b[1] >> } qw( b,6 c,3 ) >>
> This is something I hope I never see in any code that I deal with. > However, it is not the job of this specific policy to complain > about that. >
I agree with Elliot's firth sentence. A better implementation would be: map { $_->[0] } sort { $a->[1] cmp $b->[1] || $a->[2] <=> $b->[2] } map { [ $_, split m{,}xms, $_ ] } @arr; The original version requires Perl to perform the split operation 2 * N * ln(N) times, while the Schwartz version requires only N split operations (and less cache thrash). Where N=2, this is hardly worth it, but for any value of N that you would hesitate to unroll its a big win. http://en.wikipedia.org/wiki/Schwartzian_transform Chris
Subject: Re: [rt.cpan.org #33937] RequireLocalizedPunctuationVars doesn't handle lexicalized $a and $b.
Date: Sat, 24 May 2008 15:16:04 -0500
To: bug-Perl-Critic [...] rt.cpan.org
From: Elliot Shank <perl [...] galumph.com>
Released in 1.084 today.