NAME
Perl::Critic::Policy::Mardem::ProhibitConditionComplexity - condition complexity "if/while/for/... (...){}"
DESCRIPTION
This Policy approximates the McCabe score within a coditional block "eg if(...)".
See http://en.wikipedia.org/wiki/Cyclomatic_complexity
It should help to find complex conditions, which should be extracted into subs, to be more testable.
eg. from
if( $a && $b || $c > 20 ) { ... }
to
if( _some_test ($a, $b, $c) ) { .. }
sub _some_test {
my ($a, $b, $c ) = @_;
return $a && $b || $c > 20;
}
CONFIGURATION
The maximum acceptable McCabe can be set with the max_mccabe
configuration item. Any block with a McCabe score higher than this number will generate a policy violation. The default is 2.
An example section for a .perlcriticrc:
[Mardem::ProhibitConditionComplexity]
max_mccabe = 1
AFFILIATION
This policy is part of Perl::Critic::Mardem.
AUTHOR
Markus Demml, mardem@cpan.com
LICENSE AND COPYRIGHT
Copyright (c) 2024, Markus Demml
This library is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. The full text of this license can be found in the LICENSE file included with this module.