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()
Pattern
getRegexp()
int[]
getRequiredTokens()
void
leaveToken(DetailAST aAST)
void
setIgnoreAbstractMethods(boolean aIgnoreAbstractMethods)
Set whether to ignore parameters of abstract methods.
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

getId, getMessageBundle, getSeverity, getSeverityLevel, log, log, log, log, log, log, log, log, log, log, log, setId, 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

getAcceptableTokens

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

getDefaultTokens

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

getRegexp

public Pattern getRegexp()
Returns:
the regexp to match against

getRequiredTokens

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

leaveToken

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

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)
            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