Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

perlcritic - Is it possible to "nest" perlcriticrc files?

by TreyWaters (Initiate)
on Mar 09, 2016 at 19:45 UTC ( #1157215=perlquestion: print w/replies, xml ) Need Help??

TreyWaters has asked for the wisdom of the Perl Monks concerning the following question:

So, we have a "corporate" perlcriticrc file that we've been using before checking in our code. However, there are a few policies that I would prefer our team to be more strict on (and the owner of this file doesn't agree).

So, is it possible to create a .perlcriticrc which first loads the policy set from a second .perlcriticrc, then overrides anything loaded?

What I'm thinking is something like:

load_rc_file = /path/to/corporate/perlcriticrc # Corporate rc allows dead code. We don't want that [Subroutines:ProhibitUnusedPrivateSubroutines] # Corporate rc allows too high complexity. [Modules:ProhibitExcessMainComplexity] max_mccabe = 10

I'm just lost on how to "include" another perlcriticrc. I know that I can override with command-line options. Unfortunately, asking my team to add an option or two to their perlcritic runs is much too complicated.

Replies are listed 'Best First'.
Re: perlcritic - Is it possible to "nest" perlcriticrc files?
by Anonymous Monk on Mar 09, 2016 at 19:55 UTC

    Taking a peek at the source of Perl::Critic::UserProfile, it turns out the config file is just a Config::Tiny file. Unfortunately that doesn't support an "include file" feature, and Perl::Critic::Config doesn't seem to mention support for multiple files overriding one another. Unless I missed something poking around (very possible), I'm not sure this is possible and you might have to build your own solution.

      Bummer! Thanks for your input!
Re: perlcritic - Is it possible to "nest" perlcriticrc files?
by codiac (Beadle) on Mar 18, 2016 at 14:30 UTC
    Should be possible to do in a test file, untested for irony:
    use Test::More; ues Perl::Critic; my $policy = Perl::Critic->import( -verbose => 8, -severity => 5, -profile => '/path/to/corporate/perlcriticrc', -exclude => [ ], -include => [ 'Subroutines:ProhibitUnusedPrivateSubroutines', ], ); $policy->add_policy( -policy => 'Modules:ProhibitExcessMainComplexity' +, -params => {max_mccabe => 10} ) foreach my $file (globidyglob some files) { my @dohs = $policy->critique($file); is(0, not scalar @dohs, "for shame!"); }
    You could probably do it with Test::Perl::Critic, but I couldn't figure out how to get it to pass the max_mccabe param through off the top of my head and it's Friday beer O'clock time :)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1157215]
Approved by hippo
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (9)
As of 2023-12-11 15:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What's your preferred 'use VERSION' for new CPAN modules in 2023?











    Results (41 votes). Check out past polls.

    Notices?