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). ThecoberturaXmlFile
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).
Modifiers | Name | Description |
---|---|---|
protected String |
crapMetricClassName |
Type | Name and description |
---|---|
String |
coberturaXmlFile |
String |
ignoreMethodNames |
BigDecimal |
maxClassAverageMethodCrapScore |
BigDecimal |
maxClassCrapScore |
BigDecimal |
maxMethodCrapScore |
String |
name |
int |
priority |
Type Params | Return Type | Name and description |
---|---|---|
|
AstVisitor |
getAstVisitor() |
|
boolean |
isReady() |