subroutine - How to run perl critic from a script with ProhibitExcessComplexity enabled? -
subroutine - How to run perl critic from a script with ProhibitExcessComplexity enabled? -
how run perl critic script subroutines::prohibitexcesscomplexity
enabled ? tried next wasn't flagging complex 500+ line subroutines. not have .perlcriticrc
(neither want 1 there)
use perl::critic; run_critic('temp.pl'); exit; sub run_critic { $file = shift; $critic = perl::critic->new( -severity => 5, -policy => 'subroutines::prohibitexcesscomplexity', -verbose => 5, ); @violations = $critic->critique($file); print @violations; }
my perl::critic
version 1.116
perl -mperl::critic -e 'print "$perl::critic::version\n"' 1.116
view loaded policies
to view policies loaded, utilize perl::critic->policies
.
returns list containing references policy objects have been loaded engine. objects in order loaded. if view policies, can see it's not beingness added:
you see desired policy isn't added list:
use strict; utilize warnings; utilize perl::critic; run_critic($0); exit; sub run_critic { $file = shift; $critic = perl::critic->new( -severity => 5, -policy => 'subroutines::prohibitexcesscomplexity', -verbose => 5, ); print $critic->policies(); # view loaded policies @violations = $critic->critique($file); print @violations; }
outputs:
builtinfunctions::prohibitsleepviaselect builtinfunctions::prohibitstringyeval builtinfunctions::requireglobfunction classhierarchies::prohibitoneargbless controlstructures::prohibitmutatinglistfunctions inputoutput::prohibitbarewordfilehandles inputoutput::prohibitinteractivetest inputoutput::prohibittwoargopen inputoutput::requireencodingwithutf8layer modules::prohibitevilmodules modules::requirebarewordincludes modules::requirefilenamematchespackage subroutines::prohibitexplicitreturnundef subroutines::prohibitnestedsubs subroutines::prohibitreturnsort subroutines::prohibitsubroutineprototypes testinganddebugging::prohibitnostrict testinganddebugging::requireusestrict valuesandexpressions::prohibitleadingzeros variables::prohibitconditionaldeclarations variables::requirelexicalloopiterators
proper configuration option: -include
the problem constructor option -policy
not exist.
instead want utilize -include
:
-include
reference list of string @patterns
. policy modules match @ to the lowest degree 1 m/$pattern/ixms
loaded, irrespective of other settings. example:
therefore fixing constructor:
$critic = perl::critic->new( -severity => 5, -include => 'subroutines::prohibitexcesscomplexity', -verbose => 5, );
outputs:
builtinfunctions::prohibitsleepviaselect builtinfunctions::prohibitstringyeval builtinfunctions::requireglobfunction classhierarchies::prohibitoneargbless controlstructures::prohibitmutatinglistfunctions inputoutput::prohibitbarewordfilehandles inputoutput::prohibitinteractivetest inputoutput::prohibittwoargopen inputoutput::requireencodingwithutf8layer modules::prohibitevilmodules modules::requirebarewordincludes modules::requirefilenamematchespackage subroutines::prohibitexcesscomplexity # <--- ta da subroutines::prohibitexplicitreturnundef subroutines::prohibitnestedsubs subroutines::prohibitreturnsort subroutines::prohibitsubroutineprototypes testinganddebugging::prohibitnostrict testinganddebugging::requireusestrict valuesandexpressions::prohibitleadingzeros variables::prohibitconditionaldeclarations variables::requirelexicalloopiterators
perl subroutine perl-critic
Comments
Post a Comment