Groovy Documentation

org.gmetrics.metric.crap
[Groovy] Class CrapMetric

java.lang.Object
  org.gmetrics.metric.AbstractMetric
      org.gmetrics.metric.AbstractMethodMetric
          org.gmetrics.metric.crap.CrapMetric

class CrapMetric
extends AbstractMethodMetric

Metric to calculate the CRAP metric See http://www.artima.com/weblogs/viewpost.jsp?thread=210575

Authors:
Chris Mair


Property Summary
MethodMetric complexityMetric

MethodMetric coverageMetric

String name

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

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

protected BigDecimal calculateCrapScore(BigDecimal complexity, BigDecimal coverage)

Calculate the CRAP metric score

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

Property Detail

complexityMetric

MethodMetric complexityMetric


coverageMetric

MethodMetric coverageMetric


name

final String name


 
Method Detail

calculate

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


calculate

@Override
MetricResult calculate(org.codehaus.groovy.ast.MethodNode methodNode, SourceCode sourceCode)


calculateCrapScore

protected BigDecimal calculateCrapScore(BigDecimal complexity, BigDecimal coverage)
Calculate the CRAP metric score
Parameters:
complexity - - the cyclomatic complexity of a method
coverage - - the code coverage (by line) of a method
Returns:
the CRAP Metric score Given a Java method m, C.R.A.P. for m is calculated as follows: C.R.A.P.(m) = comp(m)^2 * (1 ? cov(m)/100)^3 + comp(m) See http://www.artima.com/weblogs/viewpost.jsp?thread=210575


 

Groovy Documentation