public final class MutableExceptionCheck extends AbstractFormatCheck
Ensures that exceptions (defined as any class name conforming to some regular expression) are immutable. That is, have only final fields.
Rationale: Exception instances should represent an error condition. Having non final fields not only allows the state to be modified by accident and therefore mask the original condition but also allows developers to accidentally forget to initialise state thereby leading to code catching the exception to draw incorrect conclusions based on the state.
Constructor and Description |
---|
MutableExceptionCheck()
Creates new instance of the check.
|
Modifier and Type | Method and Description |
---|---|
int[] |
getDefaultTokens()
Returns the default token a check is interested in.
|
int[] |
getRequiredTokens()
The tokens that this check must be registered for.
|
void |
leaveToken(DetailAST aAST)
Called after all the child nodes have been process.
|
void |
visitToken(DetailAST aAST)
Called to process a token.
|
getFormat, getRegexp, setCompileFlags, setFormat
beginTree, destroy, finishTree, getAcceptableTokens, getClassLoader, getFileContents, getLines, getTabWidth, getTokenNames, init, log, log, setClassLoader, setFileContents, setMessages, setTabWidth, setTokens
getCustomMessages, getId, getMessageBundle, getSeverity, getSeverityLevel, log, setId, setSeverity
configure, contextualize, finishLocalSetup, getConfiguration, setupChild
public MutableExceptionCheck()
public int[] getDefaultTokens()
Check
getDefaultTokens
in class Check
TokenTypes
public int[] getRequiredTokens()
Check
getRequiredTokens
in class Check
TokenTypes
public void visitToken(DetailAST aAST)
Check
visitToken
in class Check
aAST
- the token to processpublic void leaveToken(DetailAST aAST)
Check
leaveToken
in class Check
aAST
- the token leavingCopyright © 2001-2013. All Rights Reserved.