org.gmetrics.metric.abc
[Groovy] Class AbcMetric
java.lang.Object
org.gmetrics.metric.AbstractMetric
org.gmetrics.metric.AbstractMethodMetric
org.gmetrics.metric.abc.AbcMetric
class AbcMetric
extends AbstractMethodMetric
Calculate the ABC Metric for a class/method.
The ABC Counting Rules for Groovy:
1. Add one to the assignment count for each occurrence of an assignment operator, excluding
constant declarations: = *= /= %= += <<= >>= &= |= ^= >>>=
2. Add one to the assignment count for each occurrence of an increment or decrement operator
(prefix or postfix): ++ --
3. Add one to the branch count for each function call or class method call.
4. Add one to the branch count for each occurrence of the new operator.
5. Add one to the condition count for each use of a conditional operator:
== != <= >= < > <=> =~ ==~
6. Add one to the condition count for each use of the following keywords:
else case default try catch ?
7. Add one to the condition count for each unary conditional expression. These are cases where
a single variable/field/value is treated as a boolean value. Examples include if (x)
and return !ready
.
Additional notes:
- A property access is treated like a method call (and thus increments the branch count).
- If a class field is initialized to a Closure (ClosureExpression), then that Closure is
analyzed just like a method.
See http://www.softwarerenovation.com/ABCMetric.pdf
- Authors:
- Chris Mair
- Version:
- \$Revision: 130 \$ - \$Date: 2010-07-21 22:46:24 -0400 (Wed, 21 Jul 2010) \$
name
final String name
-
calculate
MetricResult calculate(org.codehaus.groovy.ast.MethodNode methodNode, SourceCode sourceCode)
-
calculate
MetricResult calculate(org.codehaus.groovy.ast.expr.ClosureExpression closureExpression, SourceCode sourceCode)
-
createAggregateMetricResult
protected MetricResult createAggregateMetricResult(Collection childMetricResults, org.codehaus.groovy.ast.ASTNode node)
-
Groovy Documentation