Search code examples
perlperl-critic

how to modify rules in perlcritic


Hie ,

Perl critic (Source Code Analyser). I am new to this . Although I have studied the documentation and know how to run it (That's not enough!). I want to modify the rules (i.e include,exclude or add my own rules to it). I know .perlcriticrc file can do that. But I don't know how to do it.

Thank you


Solution

  • According to the doco for Perl::Critic, you can add a "policy" with the add_policy( -policy => $policy_name, -params => \%param_hash ) method:

    -policy is the name of a Perl::Critic::Policy subclass module. The 'Perl::Critic::Policy' portion of the name can be omitted for brevity. This argument is required.

    Then, when you look at the linked documentation for the subclass module (emphasis mine);

    To work with the Perl::Critic engine, your implementation must behave as described below. For a detailed explanation on how to make new Policy modules, please see the Perl::Critic::DEVELOPER document included in this distribution.

    ... we see there's a whole document covering exactly what you want to do.

    What part of that document are you having trouble with?