org.gmetrics.metric.abc
Class AbcMetric

java.lang.Object
  extended by org.gmetrics.metric.AbstractMetric
      extended by org.gmetrics.metric.AbstractMethodMetric
          extended by 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: 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

Constructor Summary
AbcMetric()
           
 
Method Summary
 java.lang.Object calculate(org.codehaus.groovy.ast.expr.ClosureExpression closureExpression, SourceCode sourceCode)
           
 java.lang.Object calculate(org.codehaus.groovy.ast.MethodNode methodNode, SourceCode sourceCode)
           
protected  java.lang.Object createAggregateMetricResult(java.util.Collection childMetricResults)
           
 groovy.lang.MetaClass getMetaClass()
           
 java.lang.String getName()
           
 java.lang.Object getProperty(java.lang.String name)
           
 java.lang.Object invokeMethod(java.lang.String name, java.lang.Object args)
           
 void setMetaClass(groovy.lang.MetaClass metaClass)
           
 void setProperty(java.lang.String name, java.lang.Object value)
           
 
Methods inherited from class org.gmetrics.metric.AbstractMethodMetric
calculateForClass, getBaseLevel
 
Methods inherited from class org.gmetrics.metric.AbstractMetric
applyToClass, applyToPackage, calculateForPackage, getEnabled, isEnabled, isNotAnInterface, setEnabled
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbcMetric

public AbcMetric()
Method Detail

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.