Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Perlcritic config - finding the names of the policies that generate an error?

I'm trying to get started using Perlcritic, and I'm working on refining my own configuration, leaving out all the rules I don't agree with or don't think are appropriate for me.

I know that I can do this using a .perlcrirticrc file, and that I can use the exclude directive in that file to exclude the policies I don't agree with, but to do that, I need to find the name of the policy that is causing the error I want to suppress.

I can't find a list of the policies in the documentation on CPAN anywhere, and the error messages do not give the name of the policy that is generating, so I'm at a total loss as to how I am supposed to generate my exclude list.

If anyone could point me to a way of mapping errors to policies, or even just point me to a list of the policies in core I'd be most grateful!

like image 435
Bart B Avatar asked Dec 06 '22 18:12

Bart B


1 Answers

The highly-unintuitive --verbose flag is what you want, according to How do I make Perl::Critic show the offending policy in its output?

gdarcy@greg-pc:~$ perlcritic --verbose 8 src/Some/Module.pm 
[TestingAndDebugging::RequireUseStrict] Code before strictures are enabled at line 19, column 1.  (Severity: 5)
[Variables::RequireLexicalLoopIterators] Loop iterator is not lexical at line 1899, column 4.  (Severity: 5)
[Variables::RequireLexicalLoopIterators] Loop iterator is not lexical at line 1911, column 4.  (Severity: 5)
[Variables::RequireLexicalLoopIterators] Loop iterator is not lexical at line 2487, column 4.  (Severity: 5)
[Variables::RequireLexicalLoopIterators] Loop iterator is not lexical at line 3902, column 2.  (Severity: 5)
like image 83
Greg D'Arcy Avatar answered Jan 11 '23 23:01

Greg D'Arcy