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
MIME-Version: 1.0
X-Mailer: MIME-tools 5.418 (Entity 5.418)
Content-Type: text/plain; charset="utf8"
Content-Disposition: inline
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
Content-Length: 427
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
MIME-Version: 1.0
X-Mailer: MIME-tools 5.418 (Entity 5.418)
Content-Disposition: inline
Message-Id: <rt-3.6.HEAD-32651-1182337454-1749.27654-0-0 [...] rt.cpan.org>
Content-Type: text/plain; charset="utf8"
Content-Transfer-Encoding: binary
From: Bernhard.Schmalhofer [...] gmx.de
X-RT-Original-Encoding: utf-8
X-RT-Original-Encoding: utf-8
Content-Length: 205
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;
MIME-Version: 1.0
X-Mailer: MIME-tools 5.418 (Entity 5.418)
Message-Id: <rt-3.6.HEAD-19931-1191586445-143.27654-0-0 [...] rt.cpan.org>
Content-Type: multipart/mixed; boundary="----------=_1191586445-19931-1"
From: Bernhard.Schmalhofer [...] gmx.de
X-RT-Original-Encoding: utf-8
Content-Length: 0
Content-Disposition: inline
Content-Type: text/plain; charset="utf8"
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
Content-Length: 303
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.
MIME-Version: 1.0
X-Mailer: MIME-tools 5.418 (Entity 5.418)
Content-Type: multipart/mixed; boundary="----------=_1191586444-19931-0"
Content-Length: 0
Content-Type: text/plain; charset="utf8"
Content-Disposition: inline
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
X-RT-Original-Encoding: utf-8
Content-Length: 0
Content-Type: application/x-perl; name="comma_used.pl"
Content-Disposition: inline; filename="comma_used.pl"
Content-Transfer-Encoding: base64
Content-Length: 333
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;
MIME-Version: 1.0
In-Reply-To: <rt-3.6.HEAD-19931-1191586445-143.27654-0-0 [...] rt.cpan.org>
X-Mailer: MIME-tools 5.418 (Entity 5.418)
Content-Disposition: inline
References: <rt-3.6.HEAD-19931-1191586445-143.27654-0-0 [...] rt.cpan.org>
Message-Id: <rt-3.6.HEAD-11225-1192424532-888.27654-0-0 [...] rt.cpan.org>
Content-Type: text/plain; charset="utf8"
Content-Transfer-Encoding: binary
From: ELLIOTJS [...] cpan.org
X-RT-Original-Encoding: utf-8
X-RT-Original-Encoding: utf-8
Content-Length: 45
Confirmed in current P::C code in subversion.
MIME-Version: 1.0
In-Reply-To: <rt-3.6.HEAD-11225-1192424532-888.27654-0-0 [...] rt.cpan.org>
X-Mailer: MIME-tools 5.418 (Entity 5.418)
Content-Disposition: inline
References: <rt-3.6.HEAD-19931-1191586445-143.27654-0-0 [...] rt.cpan.org> <rt-3.6.HEAD-11225-1192424532-888.27654-0-0 [...] rt.cpan.org>
Message-Id: <rt-3.6.HEAD-11230-1192427159-1099.27654-0-0 [...] rt.cpan.org>
Content-Type: text/plain; charset="utf8"
Content-Transfer-Encoding: binary
From: ELLIOTJS [...] cpan.org
X-RT-Original-Encoding: utf-8
X-RT-Original-Encoding: utf-8
Content-Length: 45
Fixed in subversion. Will be in next release.
MIME-Version: 1.0
In-Reply-To: <rt-3.6.HEAD-11230-1192427159-1099.27654-0-0 [...] rt.cpan.org>
X-Mailer: MIME-tools 5.418 (Entity 5.418)
Content-Disposition: inline
References: <rt-3.6.HEAD-19931-1191586445-143.27654-0-0 [...] rt.cpan.org> <rt-3.6.HEAD-11225-1192424532-888.27654-0-0 [...] rt.cpan.org> <rt-3.6.HEAD-11230-1192427159-1099.27654-0-0 [...] rt.cpan.org>
Message-Id: <rt-3.6.HEAD-9667-1193044808-566.27654-0-0 [...] rt.cpan.org>
Content-Type: text/plain; charset="utf8"
Content-Transfer-Encoding: binary
From: ELLIOTJS [...] cpan.org
X-RT-Original-Encoding: utf-8
X-RT-Original-Encoding: utf-8
Content-Length: 39
Fix released in 1.079_003. Please test.
MIME-Version: 1.0
In-Reply-To: <rt-3.6.HEAD-9667-1193044808-566.27654-0-0 [...] rt.cpan.org>
X-Mailer: MIME-tools 5.418 (Entity 5.418)
Content-Disposition: inline
References: <rt-3.6.HEAD-19931-1191586445-143.27654-0-0 [...] rt.cpan.org> <rt-3.6.HEAD-11225-1192424532-888.27654-0-0 [...] rt.cpan.org> <rt-3.6.HEAD-11230-1192427159-1099.27654-0-0 [...] rt.cpan.org> <rt-3.6.HEAD-9667-1193044808-566.27654-0-0 [...] rt.cpan.org>
Message-Id: <rt-3.6.HEAD-9667-1193138357-1572.27654-0-0 [...] rt.cpan.org>
Content-Type: text/plain; charset="utf8"
Content-Transfer-Encoding: binary
From: Bernhard.Schmalhofer [...] gmx.de
X-RT-Original-Encoding: utf-8
X-RT-Original-Encoding: utf-8
Content-Length: 196
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
MIME-Version: 1.0
In-Reply-To: <rt-3.6.HEAD-9667-1193138357-1572.27654-0-0 [...] rt.cpan.org>
X-Mailer: MIME-tools 5.418 (Entity 5.418)
Content-Disposition: inline
Charset: utf8
References: <rt-3.6.HEAD-19931-1191586445-143.27654-0-0 [...] rt.cpan.org> <rt-3.6.HEAD-11225-1192424532-888.27654-0-0 [...] rt.cpan.org> <rt-3.6.HEAD-11230-1192427159-1099.27654-0-0 [...] rt.cpan.org> <rt-3.6.HEAD-9667-1193044808-566.27654-0-0 [...] rt.cpan.org> <rt-3.6.HEAD-9667-1193138357-1572.27654-0-0 [...] rt.cpan.org>
Message-Id: <rt-3.6.HEAD-30024-1197127171-1567.27654-0-0 [...] rt.cpan.org>
Content-Type: text/plain
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
X-RT-Original-Encoding: utf-8
Content-Length: 329
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, ) ;
MIME-Version: 1.0
In-Reply-To: <rt-3.6.HEAD-30024-1197127171-1567.27654-0-0 [...] rt.cpan.org>
X-Mailer: MIME-tools 5.418 (Entity 5.418)
Content-Disposition: inline
Charset: utf8
References: <rt-3.6.HEAD-19931-1191586445-143.27654-0-0 [...] rt.cpan.org> <rt-3.6.HEAD-11225-1192424532-888.27654-0-0 [...] rt.cpan.org> <rt-3.6.HEAD-11230-1192427159-1099.27654-0-0 [...] rt.cpan.org> <rt-3.6.HEAD-9667-1193044808-566.27654-0-0 [...] rt.cpan.org> <rt-3.6.HEAD-9667-1193138357-1572.27654-0-0 [...] rt.cpan.org> <rt-3.6.HEAD-30024-1197127171-1567.27654-0-0 [...] rt.cpan.org>
Message-Id: <rt-3.6.HEAD-30020-1197129561-1428.27654-0-0 [...] rt.cpan.org>
Content-Type: text/plain
Content-Transfer-Encoding: binary
From: ELLIOTJS [...] cpan.org
X-RT-Original-Encoding: utf-8
X-RT-Original-Encoding: utf-8
Content-Length: 222
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.
MIME-Version: 1.0
In-Reply-To: <rt-3.6.HEAD-30020-1197129561-1428.27654-0-0 [...] rt.cpan.org>
X-Mailer: MIME-tools 5.418 (Entity 5.418)
Content-Disposition: inline
Charset: utf8
References: <rt-3.6.HEAD-19931-1191586445-143.27654-0-0 [...] rt.cpan.org> <rt-3.6.HEAD-11225-1192424532-888.27654-0-0 [...] rt.cpan.org> <rt-3.6.HEAD-11230-1192427159-1099.27654-0-0 [...] rt.cpan.org> <rt-3.6.HEAD-9667-1193044808-566.27654-0-0 [...] rt.cpan.org> <rt-3.6.HEAD-9667-1193138357-1572.27654-0-0 [...] rt.cpan.org> <rt-3.6.HEAD-30024-1197127171-1567.27654-0-0 [...] rt.cpan.org> <rt-3.6.HEAD-30020-1197129561-1428.27654-0-0 [...] rt.cpan.org>
Message-Id: <rt-3.6.HEAD-8725-1197748693-1643.27654-0-0 [...] rt.cpan.org>
Content-Type: text/plain
Content-Transfer-Encoding: binary
From: ELLIOTJS [...] cpan.org
X-RT-Original-Encoding: utf-8
X-RT-Original-Encoding: utf-8
Content-Length: 816
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.
MIME-Version: 1.0
In-Reply-To: <rt-3.6.HEAD-8725-1197748693-1643.27654-0-0 [...] rt.cpan.org>
X-Mailer: MIME-tools 5.418 (Entity 5.418)
Content-Disposition: inline
Charset: utf8
References: <rt-3.6.HEAD-19931-1191586445-143.27654-0-0 [...] rt.cpan.org> <rt-3.6.HEAD-11225-1192424532-888.27654-0-0 [...] rt.cpan.org> <rt-3.6.HEAD-11230-1192427159-1099.27654-0-0 [...] rt.cpan.org> <rt-3.6.HEAD-9667-1193044808-566.27654-0-0 [...] rt.cpan.org> <rt-3.6.HEAD-9667-1193138357-1572.27654-0-0 [...] rt.cpan.org> <rt-3.6.HEAD-30024-1197127171-1567.27654-0-0 [...] rt.cpan.org> <rt-3.6.HEAD-30020-1197129561-1428.27654-0-0 [...] rt.cpan.org> <rt-3.6.HEAD-8725-1197748693-1643.27654-0-0 [...] rt.cpan.org>
Message-Id: <rt-3.6.HEAD-8750-1197756625-320.27654-0-0 [...] rt.cpan.org>
Content-Type: text/plain
Content-Transfer-Encoding: binary
From: ELLIOTJS [...] cpan.org
X-RT-Original-Encoding: utf-8
X-RT-Original-Encoding: utf-8
Content-Length: 65
I've just uploaded 1.081_001 with this change in it. Kindly test.
MIME-Version: 1.0
In-Reply-To: <rt-3.6.HEAD-8750-1197756625-320.27654-0-0 [...] rt.cpan.org>
X-Mailer: MIME-tools 5.418 (Entity 5.418)
Content-Disposition: inline
Charset: utf8
References: <rt-3.6.HEAD-19931-1191586445-143.27654-0-0 [...] rt.cpan.org> <rt-3.6.HEAD-11225-1192424532-888.27654-0-0 [...] rt.cpan.org> <rt-3.6.HEAD-11230-1192427159-1099.27654-0-0 [...] rt.cpan.org> <rt-3.6.HEAD-9667-1193044808-566.27654-0-0 [...] rt.cpan.org> <rt-3.6.HEAD-9667-1193138357-1572.27654-0-0 [...] rt.cpan.org> <rt-3.6.HEAD-30024-1197127171-1567.27654-0-0 [...] rt.cpan.org> <rt-3.6.HEAD-30020-1197129561-1428.27654-0-0 [...] rt.cpan.org> <rt-3.6.HEAD-8725-1197748693-1643.27654-0-0 [...] rt.cpan.org> <rt-3.6.HEAD-8750-1197756625-320.27654-0-0 [...] rt.cpan.org>
Message-Id: <rt-3.6.HEAD-30564-1205097901-1059.27654-0-0 [...] rt.cpan.org>
Content-Type: text/plain
Content-Transfer-Encoding: binary
From: ELLIOTJS [...] cpan.org
X-RT-Original-Encoding: utf-8
X-RT-Original-Encoding: utf-8
Content-Length: 49
This fix was released yesterday as part of 1.082.
MIME-Version: 1.0
In-Reply-To: <rt-3.6.HEAD-30564-1205097901-1059.27654-0-0 [...] rt.cpan.org>
X-Mailer: MIME-tools 5.427 (Entity 5.427)
Content-Disposition: inline
References: <rt-3.6.HEAD-19931-1191586445-143.27654-0-0 [...] rt.cpan.org> <rt-3.6.HEAD-11225-1192424532-888.27654-0-0 [...] rt.cpan.org> <rt-3.6.HEAD-11230-1192427159-1099.27654-0-0 [...] rt.cpan.org> <rt-3.6.HEAD-9667-1193044808-566.27654-0-0 [...] rt.cpan.org> <rt-3.6.HEAD-9667-1193138357-1572.27654-0-0 [...] rt.cpan.org> <rt-3.6.HEAD-30024-1197127171-1567.27654-0-0 [...] rt.cpan.org> <rt-3.6.HEAD-30020-1197129561-1428.27654-0-0 [...] rt.cpan.org> <rt-3.6.HEAD-8725-1197748693-1643.27654-0-0 [...] rt.cpan.org> <rt-3.6.HEAD-8750-1197756625-320.27654-0-0 [...] rt.cpan.org> <rt-3.6.HEAD-30564-1205097901-1059.27654-0-0 [...] rt.cpan.org>
Content-Type: text/plain; charset="UTF-8"
Message-ID: <rt-3.8.HEAD-2359-1288914296-615.27654-0-0 [...] rt.cpan.org>
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
Content-Length: 243
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.