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">150</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 assignements must be enclosed in a
properties element, which is itself inside a
Some properties take multiple values (a list), in which case you can provide them all by delimiting them with a delimiter character. It is usually a pipe (‘|’), or a comma (‘,’) for numeric properties, 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.