public class EmptyBlockCheck extends AbstractCheck
BlockOption
class and defaults to BlockOption.STATEMENT
.
By default the check will check the following blocks:
LITERAL_WHILE
,
LITERAL_TRY
,
LITERAL_FINALLY
,
LITERAL_DO
,
LITERAL_IF
,
LITERAL_ELSE
,
LITERAL_FOR
,
STATIC_INIT
,
LITERAL_SWITCH
.
LITERAL_SYNCHRONIZED
.
An example of how to configure the check is:
<module name="EmptyBlock"/>
An example of how to configure the check for the BlockOption.TEXT
policy and only try blocks is:
<module name="EmptyBlock"> <property name="tokens" value="LITERAL_TRY"/> <property name="option" value="text"/> </module>
AutomaticBean.OutputStreamOptions
Modifier and Type | Field and Description |
---|---|
static String |
MSG_KEY_BLOCK_EMPTY
A key is pointing to the warning message text in "messages.properties"
file.
|
static String |
MSG_KEY_BLOCK_NO_STATEMENT
A key is pointing to the warning message text in "messages.properties"
file.
|
Constructor and Description |
---|
EmptyBlockCheck() |
Modifier and Type | Method and Description |
---|---|
int[] |
getAcceptableTokens()
The configurable token set.
|
int[] |
getDefaultTokens()
Returns the default token a check is interested in.
|
int[] |
getRequiredTokens()
The tokens that this check must be registered for.
|
void |
setOption(String optionStr)
Set the option to enforce.
|
void |
visitToken(DetailAST ast)
Called to process a token.
|
beginTree, clearMessages, destroy, finishTree, getClassLoader, getFileContents, getLine, getLines, getMessages, getTabWidth, getTokenNames, init, isCommentNodesRequired, leaveToken, log, log, log, setClassLoader, setFileContents, setTabWidth, setTokens
finishLocalSetup, getCustomMessages, getId, getMessageBundle, getSeverity, getSeverityLevel, setId, setSeverity
configure, contextualize, getConfiguration, setupChild
public static final String MSG_KEY_BLOCK_NO_STATEMENT
public static final String MSG_KEY_BLOCK_EMPTY
public EmptyBlockCheck()
public void setOption(String optionStr)
optionStr
- string to decode option fromIllegalArgumentException
- if unable to decodepublic int[] getDefaultTokens()
AbstractCheck
getDefaultTokens
in class AbstractCheck
TokenTypes
public int[] getAcceptableTokens()
AbstractCheck
getAcceptableTokens
in class AbstractCheck
TokenTypes
public int[] getRequiredTokens()
AbstractCheck
getRequiredTokens
in class AbstractCheck
TokenTypes
public void visitToken(DetailAST ast)
AbstractCheck
visitToken
in class AbstractCheck
ast
- the token to processCopyright © 2001–2018. All rights reserved.