Package: libperl-critic-perl Version: 1.118-1 Severity: normal Tags: patch Hi!
The Policy::Modules::RequireVersionVar triggers even on programs (i.e. non-modules and non-libraries). This is very annoying because while VERSION on modules serve a purpose for the code using them on import, VERSION on programs is mostly documentation if at all, and just useless for things like test suites for example. That's one of the reasons I've had to disable this globally on dpkg for example, and I know other people do the same for the same reason. And I'd rather have it enabled for modules. Here's a patch disabling the check for programs (which just requires either adding the extension to 'program-extensions' or adding a shebang to the scripts, things that are extremely reasonable), if that would not be acceptable to upstream, then I think at least this should be made configurable. Thanks, Guillem
From b36f2b9f87cd299634878aa3ad8b4e184b20d7ef Mon Sep 17 00:00:00 2001 From: Guillem Jover <guil...@hadrons.org> Date: Fri, 26 Apr 2013 23:41:56 +0200 Subject: [PATCH] Do not trigger Policy::Modules::RequireVersionVar on programs This generates tons of false positives, because non-modules (like test scripts or programs) should not require a VERSION. --- lib/Perl/Critic/Policy/Modules/RequireVersionVar.pm | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/Perl/Critic/Policy/Modules/RequireVersionVar.pm b/lib/Perl/Critic/Policy/Modules/RequireVersionVar.pm index d26282e..286253e 100644 --- a/lib/Perl/Critic/Policy/Modules/RequireVersionVar.pm +++ b/lib/Perl/Critic/Policy/Modules/RequireVersionVar.pm @@ -33,6 +33,13 @@ sub applies_to { return 'PPI::Document' } #----------------------------------------------------------------------------- +sub prepare_to_scan_document { + my ( $self, $document ) = @_; + return $document->is_module(); # Must be a library or module. +} + +#----------------------------------------------------------------------------- + sub violates { my ( $self, $elem, $doc ) = @_; @@ -136,7 +143,7 @@ distribution. =head1 DESCRIPTION -Every Perl file (modules, libraries, and programs) should have a +Every Perl module (modules, libraries) should have a package-scoped C<$VERSION> variable. The C<$VERSION> allows clients to insist on a particular revision of your file like this: -- 1.8.2.1