java.lang.Object
com.puppycrawl.tools.checkstyle.api.AutomaticBean
com.puppycrawl.tools.checkstyle.api.AbstractViolationReporter
com.puppycrawl.tools.checkstyle.api.Check
com.puppycrawl.tools.checkstyle.checks.usage.AbstractUsageCheck
com.puppycrawl.tools.checkstyle.checks.usage.OneMethodPrivateFieldCheck
- All Implemented Interfaces:
- com.puppycrawl.tools.checkstyle.api.Configurable, com.puppycrawl.tools.checkstyle.api.Contextualizable
- public class OneMethodPrivateFieldCheck
- extends AbstractUsageCheck
Checks that a private field is used in more than one method,
constructor, or initializer.
Rationale: a private field used in only one method, constructor, or
initializer should be replaced by a local variable.
An example of how to configure the check is:
<module name="usage.OneMethodPrivateField"/>
| Fields inherited from class com.puppycrawl.tools.checkstyle.checks.usage.AbstractUsageCheck |
|
| Fields inherited from class com.puppycrawl.tools.checkstyle.api.Check |
|
| Fields inherited from class com.puppycrawl.tools.checkstyle.api.AutomaticBean |
|
| Methods inherited from class com.puppycrawl.tools.checkstyle.api.Check |
destroy, getAcceptableTokens, getClassLoader, getFileContents, getLines, getRequiredTokens, getTabWidth, getTokenNames, init, leaveToken, log, log, setClassLoader, setFileContents, setMessages, setTabWidth, setTokens |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
OneMethodPrivateFieldCheck
public OneMethodPrivateFieldCheck()
getDefaultTokens
public int[] getDefaultTokens()
- Description copied from class:
com.puppycrawl.tools.checkstyle.api.Check
- Returns the default token a check is interested in. Only used if the
configuration for a check does not define the tokens.
getErrorKey
public java.lang.String getErrorKey()
- Description copied from class:
AbstractUsageCheck
- Returns the key for the Checkstyle error message.
- Specified by:
getErrorKey in class AbstractUsageCheck
mustCheckReferenceCount
public boolean mustCheckReferenceCount(com.puppycrawl.tools.checkstyle.api.DetailAST aAST)
- Description copied from class:
AbstractUsageCheck
- Determines whether the reference count of an aAST is required.
- Specified by:
mustCheckReferenceCount in class AbstractUsageCheck
applyTo
public void applyTo(java.util.Set aNodes)
- Description copied from class:
AbstractUsageCheck
- Applies this check to a set of nodes.
- Overrides:
applyTo in class AbstractUsageCheck
getReferences
private java.util.Iterator getReferences(com.puppycrawl.tools.checkstyle.api.DetailAST aAST)
- Returns the references to an AST.