in reply to perlcritic & test files

UPDATE:
I try ## no critic (Modules::RequireExplicitPackage) at end of first line, but it don't help - error appear for next line
When I add ## no critic (Modules::RequireExplicitPackage) before the first line, the Code not contained in explicit package.  Violates encapsulation message disappears for me:
## no critic (Modules::RequireExplicitPackage) use lib qw( lib ); use strict; use warnings; use Test::More tests => 1;

This was my original response...


According to the POD for Perl::Critic::Policy::Modules::RequireExplicitPackage, there are no hooks for disabling this check. However, it does say:

so this Policy doesn't apply to files that begin with a perl shebang.
If you add a shebang line to your test file, the check is suppressed:
#!/usr/bin/env perl
If you don't want to do that, then you could just post-process the output of perlcritic and filter out these messages.

You can also request that this feature be added to the module at https://rt.cpan.org/Public/Dist/Display.html?Name=Perl-Critic. Better yet, figure out how to modify the module yourself and submit a patch (that increases the chances of having the feature added).

Replies are listed 'Best First'.
Re^2: perlcritic & test files
by Bor (Beadle) on Aug 03, 2011 at 10:11 UTC
    Thank you
    This is what I want
    Somehow I forgot this trick (for this policy it can be use)