Package: org.gmetrics.metric.crap

## [Groovy] Class CrapMetric

- org.gmetrics.metric.crap.CrapMetric

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

  Authors:
    Chris Mair

- - ### Properties Summary

    Properties
    Type | Name and description
    --- | ---
    `MethodMetric` | `complexityMetric`
    `MethodMetric` | `coverageMetric`
    `String` | `name`

  - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `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

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class AbstractMethodMetric` | `applyToClosure, applyToMethod, calculate, calculate, calculateForClass`
    `class AbstractMetric` | `applyToClass, applyToPackage, calculateForClass, calculateForPackage, createAggregateMetricResult, isNotAnInterface`

- - ### Property Detail

    - #### MethodMetric complexityMetric

    - #### MethodMetric coverageMetric

    - #### final String name

  - ### Method Detail

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

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

    - #### 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