Learn how to configure your rules directly from the ruleset XML.
Table of Contents Message and priority overridingYou can change a ruleâs message by specifying a message
attribute on the rule element. This will override the previous value and change the message the rule will print on the report.
Similarly, the priority of a rule can be changed via a nested element. Using priority, you can deactivate some rules based on a minimum priority threshold (set using the --minimum-priority
CLI option). Priority in the ruleset is an integer ranging from 1 to 5, with 1 being the highest priority. On the command line, you can either use the integer or the following values:
Putting things together, the following rule reference lowers the priority of EmptyCatchBlock to 5 (âLowâ), such that e.g. using the --minimum-priority=Medium_Low
CLI parameters will cause the rule to be ignored.
<rule ref="category/java/errorprone.xml/EmptyCatchBlock"
message="Empty catch blocks should be avoided" >
<priority>5</priority>
</rule>
Rule properties
Properties make it easy to customise the behaviour of a rule directly from the xml. They come in several types, which correspond to the type of their values. For example, NPathComplexity declares a property âreportLevelâ, with an integer value type, and which corresponds to the threshold above which a method will be reported. If you believe that its default value of 200 is too high, you could lower it to e.g. 150 in the following way:
<rule ref="category/java/design.xml/NPathComplexity">
<properties>
<property name="reportLevel">
<value>150</value>
</property>
</properties>
</rule>
Properties are assigned a value with a property
element, which should mention the name of a property as an attribute. The value of the property can be specified either in the content of the element, like above, or in the value
attribute, e.g.
<property name="reportLevel" value="150"/>
All property assignments must be enclosed in a properties
element, which is itself inside a rule
element.
The properties of a rule are documented with the rule, e.g.
herefor NPathComplexity. Note that
assigning a value to a property that does not exist throws an error!Some properties take multiple values (a list), in which case you can provide them all by delimiting them with a comma (â,â), e.g.
<property name="legalCollectionTypes"
value="java.util.ArrayList,java.util.Vector,java.util.HashMap"/>
These properties are referred to as multivalued properties in this documentation.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4