public class SuppressWarningsCheck extends AbstractFormatCheck
This check allows you to specify what warnings that
SuppressWarnings
is not
allowed to suppress. You can also specify a list
of TokenTypes that the configured warning(s) cannot
be suppressed on.
The warnings
property is a
regex pattern. Any warning being suppressed matching
this pattern will be flagged.
By default, any warning specified will be disallowed on
all legal TokenTypes unless otherwise specified via
the
tokens
property.
Also, by default warnings that are empty strings or all
whitespace (regex: ^$|^\s+$) are flagged. By specifying,
the format property these defaults no longer apply.
Limitations: This check does not consider conditionals
inside the SuppressWarnings annotation.
For example:
@SupressWarnings((false) ? (true) ? "unchecked" : "foo" : "unused")
According to the above example, the "unused" warning is being suppressed
not the "unchecked" or "foo" warnings. All of these warnings will be
considered and matched against regardless of what the conditional
evaluates to.
This check can be configured so that the "unchecked" and "unused" warnings cannot be suppressed on anything but variable and parameter declarations. See below of an example.
<module name="SuppressWarnings"> <property name="format" value="^unchecked$|^unused$"/> <property name="tokens" value=" CLASS_DEF,INTERFACE_DEF,ENUM_DEF, ANNOTATION_DEF,ANNOTATION_FIELD_DEF, ENUM_CONSTANT_DEF,METHOD_DEF,CTOR_DEF "/> </module>
DEFAULT_ERROR_SCORE, DEFAULT_INFO_SCORE, DEFAULT_WARNING_SCORE, mScoring, mViolationSize
コンストラクタと説明 |
---|
SuppressWarningsCheck()
Ctor that specifies the default for the format property
as specified in the class javadocs.
|
修飾子とタイプ | メソッドと説明 |
---|---|
int[] |
getAcceptableTokens()
The configurable token set.
|
int[] |
getDefaultTokens()
Returns the default token a check is interested in.
|
void |
visitToken(DetailAST aAST)
Called to process a token.
|
getFormat, getRegexp, setCompileFlags, setFormat
beginTree, destroy, finishTree, getClassLoader, getFileContents, getLines, getRequiredTokens, getTabWidth, getTokenNames, init, leaveToken, log, log, setClassLoader, setFileContents, setMessages, setTabWidth, setTokens
calculateScore, getCustomMessages, getErrorScore, getId, getInfoScore, getMessageBundle, getScore, getScoring, getSeverity, getSeverityLevel, getWarningScore, log, setErrorScore, setId, setInfoScore, setScore, setScoring, setSeverity, setWarningScore
configure, contextualize, finishLocalSetup, getConfiguration, setupChild
public SuppressWarningsCheck()
public final int[] getDefaultTokens()
getDefaultTokens
クラス内 Check
TokenTypes
public final int[] getAcceptableTokens()
getAcceptableTokens
クラス内 Check
TokenTypes
public void visitToken(DetailAST aAST)
visitToken
クラス内 Check
aAST
- the token to processCopyright © 2001-2013. All Rights Reserved.