org.gmetrics.metric.cyclomatic
Class CyclomaticComplexityMetric
java.lang.Object
org.gmetrics.metric.AbstractMetric
org.gmetrics.metric.AbstractMethodMetric
org.gmetrics.metric.cyclomatic.CyclomaticComplexityMetric
class CyclomaticComplexityMetric
extends AbstractMethodMetric
Metric for counting the (McCabe) Cyclomatic Complexity for methods and closure fields.
The counting rules for Groovy:
1. Each method starts with a complexity count of one.
2. Add one to the complexity count for each occurrence of:
if while for case catch && || ?: (ternary-operator) ?: (elvis-operator) ?. (null-check)
Additional notes:
- If a class field is initialized to a Closure (ClosureExpression), then that Closure is
analyzed just like a method.
See http://en.wikipedia.org/wiki/Cyclomatic_complexity
- Authors:
- Chris Mair
- Version:
- \$Revision: 130 \$ - \$Date: 2010-07-21 22:46:24 -0400 (Wed, 21 Jul 2010) \$
name
final String name
-
CyclomaticComplexityMetric
CyclomaticComplexityMetric()
-
calculate
MetricResult calculate(org.codehaus.groovy.ast.MethodNode methodNode, SourceCode sourceCode)
-
calculate
MetricResult calculate(org.codehaus.groovy.ast.expr.ClosureExpression closureExpression, SourceCode sourceCode)
-
Groovy Documentation