boftx has asked for the wisdom of the Perl Monks concerning the following question:
The shop I am at has decided to try using perlcritic as one part of establishing code standards. Fair enough. But running it on some existing code reveals that perlcritic complains about things that are either a) what I consider to be a deeply ingrained perl idiom, or b) fully legal, in fact required, aspects of Moose.
Here is a skeleton Moose module that demonstrates both of the conditions I have mentioned above (perlcritic output is at the end of the module.)
package CriticTest; use Moose; our $VERSION = '1.01'; has 'needs_build' => ( isa => 'Int', is => 'rw', lazy => 1, builder => '_build_needs_build', ); sub _build_needs_build { my $self = shift; my %args = @_; return $self; } 1; __END__ [~/perl/test]$ perlcritic -1 CriticTest.pm Private subroutine/method '_build_needs_build' declared but not used a +t line 14, column 1. Eliminate dead code. (Severity: 3) Always unpack @_ first at line 14, column 1. See page 178 of PBP. (S +everity: 4)
I know that I could pepper my code with ## nocritic tags, but that seems particularly wrong for what is (IMHO) perfectly acceptable Perl. I also know that I could disable the rule that is complaining about unpacking @_, but that rule is quite desirable when dealing with non-OOP sub-routines.
Can anyone point me in the right direction to deal with what I think is undesirable behavior by perlcritic?
|
|---|