
com.puppycrawl.tools.checkstyle.meta.checks.coding.HiddenFieldCheck.xml Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of checkstyle Show documentation
Show all versions of checkstyle Show documentation
Checkstyle is a development tool to help programmers write Java code
that adheres to a coding standard
<?xml version="1.0" encoding="UTF-8"?> <checkstyle-metadata> <module> <check fully-qualified-name="com.puppycrawl.tools.checkstyle.checks.coding.HiddenFieldCheck" name="HiddenField" parent="com.puppycrawl.tools.checkstyle.TreeWalker"> <description><div> Checks that a local variable or a parameter does not shadow a field that is defined in the same class. </div> <p> It is possible to configure the check to ignore all property setter methods. </p> <p> A method is recognized as a setter if it is in the following form </p> <pre> ${returnType} set${Name}(${anyType} ${name}) { ... } </pre> <p> where ${anyType} is any primitive type, class or interface name; ${name} is name of the variable that is being set and ${Name} its capitalized form that appears in the method name. By default, it is expected that setter returns void, i.e. ${returnType} is 'void'. For example </p> <pre> void setTime(long time) { ... } </pre> <p> Any other return types will not let method match a setter pattern. However, by setting <em>setterCanReturnItsClass</em> property to <em>true</em> definition of a setter is expanded, so that setter return type can also be a class in which setter is declared. For example </p> <pre> class PageBuilder { PageBuilder setName(String name) { ... } } </pre> <p> Such methods are known as chain-setters and a common when Builder-pattern is used. Property <em>setterCanReturnItsClass</em> has effect only if <em>ignoreSetter</em> is set to true. </p></description> <properties> <property default-value="false" name="ignoreAbstractMethods" type="boolean"> <description>Control whether to ignore parameters of abstract methods.</description> </property> <property default-value="false" name="ignoreConstructorParameter" type="boolean"> <description>Control whether to ignore constructor parameters.</description> </property> <property name="ignoreFormat" type="java.util.regex.Pattern"> <description>Define the RegExp for names of variables and parameters to ignore.</description> </property> <property default-value="false" name="ignoreSetter" type="boolean"> <description>Allow to ignore the parameter of a property setter method.</description> </property> <property default-value="false" name="setterCanReturnItsClass" type="boolean"> <description>Allow to expand the definition of a setter method to include methods that return the class' instance.</description> </property> <property default-value="VARIABLE_DEF,PARAMETER_DEF,PATTERN_VARIABLE_DEF,LAMBDA,RECORD_COMPONENT_DEF" name="tokens" type="java.lang.String[]" validation-type="tokenSet"> <description>tokens to check</description> </property> </properties> <message-keys> <message-key key="hidden.field"/> </message-keys> </check> </module> </checkstyle-metadata>
© 2015 - 2025 Weber Informatics LLC | Privacy Policy