Package: groovy.org.codenarc.rule.size

## [Groovy] Class CrapMetricRule

- groovy.org.codenarc.rule.size.CrapMetricRule

- Rule that calculates the CRAP Metric for methods/classes and checks against configured threshold values.

  Note that this rule requires the GMetrics 0.5 (or later) jar on the classpath, as well as a Cobertura XML coverage file. If either of these prerequisites is not available, this rule logs a warning messages and exits (i.e., does nothing).

  The `coberturaXmlFile` property must be set to the path to the Cobertura XML coverage file for the Groovy code being analyzed. By default, the path is relative to the classpath. But the path may be optionally prefixed by any of the valid java.net.URL prefixes, such as "file:" (to load from a relative or absolute path on the filesystem), or "http:". This property is REQUIRED.

  The `maxMethodCrapScore` property holds the threshold value for the CRAP crapMetric value for each method. If this value is non-zero, a method with a CRAP score value greater than this value is considered a violation. The `maxMethodCrapScore` property defaults to 30.

  The `maxClassAverageCrapScore` property holds the threshold value for the average CRAP crapMetric value for each class. If this value is non-zero, a class with an average CRAP score value greater than this value is considered a violation. The `maxMethodAverageCrapScore` property defaults to 30.

  The `maxClassCrapScore` property holds the threshold value for the total CRAP crapMetric value for each class. If this value is non-zero, a class with a total CRAP score value greater than this value is considered a violation. The `maxClassCrapScore` property defaults to 0.

  The `ignoreMethodNames` property optionally specifies one or more (comma-separated) method names that should be ignored (i.e., that should not cause a rule violation). The name(s) may optionally include wildcard characters ('*' or '?'). Note that the ignored methods still contribute to the class complexity value.

  This rule does NOT treat "closure fields" as methods (unlike some of the other size/complexity rules).
  See Also:
    The original 2007 blog post that defined the CRAP crapMetric.
    A 2011 blog post from Alberto Savoia, describing the formula, the motivation, and the CRAP4J tool.
    GMetrics CRAP crapMetric.
  Authors:
    Chris Mair

- - ### Field Summary

    Fields
    Modifiers | Name | Description
    --- | --- | ---
    `protected String` | `crapMetricClassName` |

  - ### Properties Summary

    Properties
    Type | Name and description
    --- | ---
    `String` | `coberturaXmlFile`
    `String` | `ignoreMethodNames`
    `BigDecimal` | `maxClassAverageMethodCrapScore`
    `BigDecimal` | `maxClassCrapScore`
    `BigDecimal` | `maxMethodCrapScore`
    `String` | `name`
    `int` | `priority`

  - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `AstVisitor` | `getAstVisitor()`
    `` | `boolean` | `isReady()`

- - ### Field Detail

    - #### protected String crapMetricClassName

  - ### Property Detail

    - #### String coberturaXmlFile

    - #### String ignoreMethodNames

    - #### BigDecimal maxClassAverageMethodCrapScore

    - #### BigDecimal maxClassCrapScore

    - #### BigDecimal maxMethodCrapScore

    - #### String name

    - #### int priority

  - ### Method Detail

    - #### @Override AstVisitor getAstVisitor()

    - #### @Override boolean isReady()