org.gmetrics.metric.abc
Class AbcMetric
java.lang.Object
org.gmetrics.metric.AbstractMetric
org.gmetrics.metric.AbstractMethodMetric
org.gmetrics.metric.abc.AbcMetric
- All Implemented Interfaces:
- groovy.lang.GroovyObject, Metric
public class AbcMetric
- extends AbstractMethodMetric
- implements groovy.lang.GroovyObject
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.
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
- Version:
- $Revision: 28 $ - $Date: 2009-12-12 22:47:13 -0500 (Sat, 12 Dec 2009) $
- Author:
- Chris Mair
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
AbcMetric
public AbcMetric()
getName
public final java.lang.String getName()
- Specified by:
getName in interface Metric
calculate
public java.lang.Object calculate(org.codehaus.groovy.ast.MethodNode methodNode,
SourceCode sourceCode)
- Specified by:
calculate in class AbstractMethodMetric
calculate
public java.lang.Object calculate(org.codehaus.groovy.ast.expr.ClosureExpression closureExpression,
SourceCode sourceCode)
- Specified by:
calculate in class AbstractMethodMetric
createAggregateMetricResult
protected java.lang.Object createAggregateMetricResult(java.util.Collection childMetricResults)
- Overrides:
createAggregateMetricResult in class AbstractMetric
getMetaClass
public groovy.lang.MetaClass getMetaClass()
- Specified by:
getMetaClass in interface groovy.lang.GroovyObject- Overrides:
getMetaClass in class AbstractMethodMetric
setMetaClass
public void setMetaClass(groovy.lang.MetaClass metaClass)
- Specified by:
setMetaClass in interface groovy.lang.GroovyObject- Overrides:
setMetaClass in class AbstractMethodMetric
invokeMethod
public java.lang.Object invokeMethod(java.lang.String name,
java.lang.Object args)
- Specified by:
invokeMethod in interface groovy.lang.GroovyObject- Overrides:
invokeMethod in class AbstractMethodMetric
getProperty
public java.lang.Object getProperty(java.lang.String name)
- Specified by:
getProperty in interface groovy.lang.GroovyObject- Overrides:
getProperty in class AbstractMethodMetric
setProperty
public void setProperty(java.lang.String name,
java.lang.Object value)
- Specified by:
setProperty in interface groovy.lang.GroovyObject- Overrides:
setProperty in class AbstractMethodMetric
Copyright © 2010. All Rights Reserved.