com.puppycrawl.tools.checkstyle.checks.coding

Class HiddenFieldCheck

Implemented Interfaces:
Configurable, Contextualizable

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

void
beginTree(DetailAST aRootAST)
int[]
getAcceptableTokens()
int[]
getDefaultTokens()
RE
getRegexp()
int[]
getRequiredTokens()
void
leaveToken(DetailAST aAST)
void
setIgnoreConstructorParameter(boolean aIgnoreConstructorParameter)
Set whether to ignore constructor parameters.
void
setIgnoreFormat(String aFormat)
Set the ignore format to the specified regular expression.
void
setIgnoreSetter(boolean aIgnoreSetter)
Set whether to ignore the parameter of a property setter method.
void
visitToken(DetailAST aAST)

Methods inherited from class com.puppycrawl.tools.checkstyle.api.Check

beginTree, destroy, finishTree, getAcceptableTokens, getClassLoader, getDefaultTokens, getFileContents, getLines, getRequiredTokens, getTabWidth, getTokenNames, init, leaveToken, log, log, setClassLoader, setFileContents, setMessages, setTabWidth, setTokens, visitToken

Methods inherited from class com.puppycrawl.tools.checkstyle.api.AbstractViolationReporter

getMessageBundle, getSeverity, getSeverityLevel, log, log, log, log, log, log, log, log, log, log, log, setSeverity

Methods inherited from class com.puppycrawl.tools.checkstyle.api.AutomaticBean

configure, contextualize, finishLocalSetup, getConfiguration, setupChild

Method Details

beginTree

public void beginTree(DetailAST aRootAST)
Overrides:
beginTree in interface Check

See Also:
Check


getAcceptableTokens

public int[] getAcceptableTokens()
Overrides:
getAcceptableTokens in interface Check

See Also:
Check


getDefaultTokens

public int[] getDefaultTokens()
Overrides:
getDefaultTokens in interface Check

See Also:
Check


getRegexp

public RE getRegexp()

Returns:
the regexp to match against


getRequiredTokens

public int[] getRequiredTokens()
Overrides:
getRequiredTokens in interface Check

See Also:
Check


leaveToken

public void leaveToken(DetailAST aAST)
Overrides:
leaveToken in interface Check

See Also:
Check


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)
            throws ConversionException
Set the ignore format to the specified regular expression.

Parameters:
aFormat - a String value


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)
Overrides:
visitToken in interface Check

See Also:
Check