Groovy Documentation

org.gmetrics.metric.cyclomatic
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
author:
Chris Mair
version:
$Revision: 130 $ - $Date: 2010-07-21 22:46:24 -0400 (Wed, 21 Jul 2010) $


Property Summary
String name

 
Constructor Summary
CyclomaticComplexityMetric()

 
Method Summary
MetricResult calculate(MethodNode methodNode, SourceCode sourceCode)

MetricResult calculate(ClosureExpression closureExpression, SourceCode sourceCode)

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

Property Detail

name

final String name


 
Constructor Detail

CyclomaticComplexityMetric

CyclomaticComplexityMetric()


 
Method Detail

calculate

MetricResult calculate(MethodNode methodNode, SourceCode sourceCode)


calculate

MetricResult calculate(ClosureExpression closureExpression, SourceCode sourceCode)


 

Groovy Documentation