Groovy Documentation

org.gmetrics.metric.cyclomatic
[Groovy] 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: 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) \$


Property Summary
String name

 
Method Summary
MetricResult calculate(org.codehaus.groovy.ast.MethodNode methodNode, SourceCode sourceCode)

MetricResult calculate(org.codehaus.groovy.ast.expr.ClosureExpression closureExpression, SourceCode sourceCode)

 
Methods inherited from class AbstractMethodMetric
calculate, calculate, calculateForClass
 
Methods inherited from class AbstractMetric
applyToClass, applyToPackage, calculateForClass, calculateForPackage, createAggregateMetricResult, isNotAnInterface
 

Property Detail

name

final String name


 
Method Detail

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