com.puppycrawl.tools.checkstyle.checks.coding

Class HiddenFieldCheck

public class HiddenFieldCheck extends Check

Checks that a local variable or a parameter does not shadow a field that is defined in the same class.

An example of how to configure the check is:

 <module name="HiddenField"/>
 

An example of how to configure the check so that it checks variables but not parameters is:

 <module name="HiddenField">
    <property name="tokens" value="VARIABLE_DEF"/>
 </module>
 

An example of how to configure the check so that it ignores the parameter of a setter method is:

 <module name="HiddenField">
    <property name="ignoreSetter" value="true"/>
 </module>
 

An example of how to configure the check so that it ignores constructor parameters is:

 <module name="HiddenField">
    <property name="ignoreConstructorParameter" value="true"/>
 </module>
 

Version: 1.0

Author: Rick Giles

Method Summary
voidbeginTree(DetailAST aRootAST)
{@inheritDoc}
int[]getAcceptableTokens()
{@inheritDoc}
int[]getDefaultTokens()
{@inheritDoc}
PatterngetRegexp()
int[]getRequiredTokens()
{@inheritDoc}
voidleaveToken(DetailAST aAST)
{@inheritDoc}
voidsetIgnoreAbstractMethods(boolean aIgnoreAbstractMethods)
Set whether to ignore parameters of abstract methods.
voidsetIgnoreConstructorParameter(boolean aIgnoreConstructorParameter)
Set whether to ignore constructor parameters.
voidsetIgnoreFormat(String aFormat)
Set the ignore format to the specified regular expression.
voidsetIgnoreSetter(boolean aIgnoreSetter)
Set whether to ignore the parameter of a property setter method.
voidvisitToken(DetailAST aAST)
{@inheritDoc}

Method Detail

beginTree

public void beginTree(DetailAST aRootAST)
{@inheritDoc}

getAcceptableTokens

public int[] getAcceptableTokens()
{@inheritDoc}

getDefaultTokens

public int[] getDefaultTokens()
{@inheritDoc}

getRegexp

public Pattern getRegexp()

Returns: the regexp to match against

getRequiredTokens

public int[] getRequiredTokens()
{@inheritDoc}

leaveToken

public void leaveToken(DetailAST aAST)
{@inheritDoc}

setIgnoreAbstractMethods

public void setIgnoreAbstractMethods(boolean aIgnoreAbstractMethods)
Set whether to ignore parameters of abstract methods.

Parameters: aIgnoreAbstractMethods decide whether to ignore parameters of abstract methods.

setIgnoreConstructorParameter

public void setIgnoreConstructorParameter(boolean aIgnoreConstructorParameter)
Set whether to ignore constructor parameters.

Parameters: aIgnoreConstructorParameter decide whether to ignore constructor parameters.

setIgnoreFormat

public void setIgnoreFormat(String aFormat)
Set the ignore format to the specified regular expression.

Parameters: aFormat a String value

Throws: ConversionException unable to parse aFormat

setIgnoreSetter

public void setIgnoreSetter(boolean aIgnoreSetter)
Set whether to ignore the parameter of a property setter method.

Parameters: aIgnoreSetter decide whether to ignore the parameter of a property setter method.

visitToken

public void visitToken(DetailAST aAST)
{@inheritDoc}