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: 218 \$ - \$Date: 2012-01-07 08:40:26 -0500 (Sat, 07 Jan 2012) \$