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

People
Owner: Nobody in particular
Requestors: Bernhard.Schmalhofer [...] gmx.de
Cc:
AdminCc:

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



Subject: False positive for ValuesAndExpressions::ProhibitCommaSeparatedStatements
Download (untitled) / with headers
text/plain 427b
Hi, I think i came accross a false positive. For the code: package main; # pragmata use strict; use warnings; use 5.008; my ( @head, @tail ); foreach ( @head, @tail ) { } 1; I get: me@home:> perlcritic -severity 4 comma_seperated.pl Comma used to separate statements at line 10, column 11. See pages 68,71 of PBP. (Severity: 4) Regards, Bernhard
From: Bernhard.Schmalhofer [...] gmx.de
Download (untitled) / with headers
text/plain 205b
Another example false positive might be: package main; # pragmata use strict; use warnings; use 5.008; my %my_hash; my $my_ref = { %myhash, }; 1;
From: Bernhard.Schmalhofer [...] gmx.de
Download (untitled) / with headers
text/plain 303b
On Mi. 20. Jun. 2007, 05:30:40, Bernhard.Schmalhofer@gmx.de wrote: When refactoring some code I came accross another false positive. my @arr1; @arr1 = split /b/, 'abc'; This occured with Perl::Critic 1.078 and PPI 1.118 on a Linux machine running Perl 5.8.0. An example file is attached.
Download comma_used.pl
text/x-perl 333b
package main; use strict; use warnings; use Data::Dumper; my @arr1; @arr1 = split /b/, 'abc'; my @arr2 = split /b/, 'abc'; my @arr3; @arr3 = split 'b', 'abc'; my @arr4 = split 'b', 'abc'; my @arr5; @arr5 = split m/b/, 'abc'; my @arr6 = split m/b/, 'abc'; print Dumper( \@arr1, \@arr2, \@arr3, \@arr4, \@arr5, \@arr6 ); 1;
From: ELLIOTJS [...] cpan.org
Confirmed in current P::C code in subversion.
From: ELLIOTJS [...] cpan.org
Fixed in subversion. Will be in next release.
From: ELLIOTJS [...] cpan.org
Fix released in 1.079_003. Please test.
From: Bernhard.Schmalhofer [...] gmx.de
Download (untitled) / with headers
text/plain 196b
On Mo. 22. Okt. 2007, 05:20:12, ELLIOTJS wrote: Show quoted text
> Fix released in 1.079_003. Please test.
Yes, this looks good. I checked 1.079_003 with the code snippet I posted last time. Thanks, Bernhard
Download (untitled) / with headers
text/plain 329b
I also get a bunch of false positives. Below are some examples. Perl::Critic version is 1.080. example 1: return { "string" => $aliased_history, TIME => $self->{something}, } ; example 2: %hash = map {$_, 1} @list ; example 3: $self->DoSomething ( { %{$a_hash_ref}, %{$another_hash_ref}}, @more_data, ) ;
From: ELLIOTJS [...] cpan.org
Download (untitled) / with headers
text/plain 222b
On Sat Dec 08 10:19:32 2007, NKH wrote: Show quoted text
> I also get a bunch of false positives. Below are some examples.
Confirmed. Failing tests checked in. Fix will most likely not happen until next weekend at the Chicago Hackathon.
From: ELLIOTJS [...] cpan.org
Download (untitled) / with headers
text/plain 816b
On Sat Dec 08 10:59:22 2007, ELLIOTJS wrote: Show quoted text
> On Sat Dec 08 10:19:32 2007, NKH wrote:
> > I also get a bunch of false positives. Below are some examples.
I fixed your second example, i.e. "%hash = map {$_, 1} @list ;", but only via a new "allow_last_statement_to_be_comma_separated_in_map_and_grep" option to the policy, because I really don't want people doing that, in general. There is, of course, the problem of using the fat comma instead forcing the left value to be stringified. But then you can disable this policy for that specific statement, i.e. put "## no critic (ProhibitCommaSeparatedStatements)" at the end of the line. Unfortunately, the first and third examples cannot be fixed at present, due to PPI mis-parsing those hash constructors as blocks. The tests for these have been marked TODO.
From: ELLIOTJS [...] cpan.org
I've just uploaded 1.081_001 with this change in it. Kindly test.
From: ELLIOTJS [...] cpan.org
This fix was released yesterday as part of 1.082.
Download (untitled) / with headers
text/plain 243b
Update: Example 1 above is also the subject of 61301 in the Perl-Critic queue. This in turn refers to the corresponding PPI ticket. A patch to PPI has been committed, but as of this moment not yet released. Example 3 above is still a puzzle.


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.