Subject: | False Positive: single arg select |
The following code results in a Perl::Critic::Policy::InputOutput::ProhibitOneArgSelect violation:
sub select {
# whatever...
}
While this may not be in line with Conway's other rules against homonymic sub names, it's definitely not a "one arg select" violation.
I'd suggest the following pre-condition (or something like it) be added to the InputOutput::ProhibitOneArgSelect::violates method:
return if $elem->sprevious_sibling eq 'sub';
Here's a failing test case to aid in implementing the fix:
use Test::More tests => 1;
use strict;
use Perl::Critic;
my $critic = Perl::Critic->new( -profile => 'NONE' );
$critic->add_policy(-policy=>'Perl::Critic::Policy::InputOutput::ProhibitOneArgSelect' );
my @errors = $critic->critique( \'sub select { return "foo" }' );
is( scalar(@errors), 0, 'no errors' ) or diag @errors;
Thanks for you great work on this set of modules. It's a great tool for increasing code quality!
Brian