Subject: | Bug in policy ValuesAndExpressions::ProhibitCommaSeparatedStatements |
Hi,
The following seems to be a bug in
Perl::Critic::Policy::ValuesAndExpressions::ProhibitCommaSeparatedStatements
The following piece of code causes the error to be reported beneath it:
# cal table suffixes based on mode
has q{_cal_table_suffixes} => (
isa => q{HashRef},
is => q{ro},
lazy_build => 1,
);
sub _build__cal_table_suffixes {
my ( $self ) = @_;
return {
1 => $self->pb_cal_pipeline_conf()->{cal_table_suffix},
2 => $self->pb_cal_pipeline_conf()->{mode2_cal_table_suffix},
};
}
not ok 49 - Test::Perl::Critic for
"lib/npg_pipeline/roles/business/harold_calibration_reqs.pm"
# Failed test 'Test::Perl::Critic for
"lib/npg_pipeline/roles/business/harold_calibration_reqs.pm"'
# at
/Users/ajb/dev/perl/5.10.1/lib/site_perl/5.10.1/Test/Perl/Critic.pm line
110.
#
# Perl::Critic found these violations in
"lib/npg_pipeline/roles/business/harold_calibration_reqs.pm":
# Comma used to separate statements at line 202, column 5. See pages
68,71 of PBP. (Severity: 4)
Whereas if I declare the HashRef into a scalar, and then return the scalar
sub _build__cal_table_suffixes {
my ( $self ) = @_;
my $return = {
1 => $self->pb_cal_pipeline_conf()->{cal_table_suffix},
2 => $self->pb_cal_pipeline_conf()->{mode2_cal_table_suffix},
};
return $return;
}
ok 49 - Test::Perl::Critic for
"lib/npg_pipeline/roles/business/harold_calibration_reqs.pm"
With laziness and the idea of less code introduces less errors, I see
not being allowed to directly create the anonymous hash in the return to
be a bug, rather than an improvement to code readability and
maintainability. (I would be happy to see and follow an explicit policy
which disallowed this, but not based inside another unrelated policy).
Thanks for Perl::Critic, I hope that this bug report is useful.
Cheers
Andy