Class MissingDeprecatedCheck
- java.lang.Object
-
- com.puppycrawl.tools.checkstyle.api.AutomaticBean
-
- com.puppycrawl.tools.checkstyle.api.AbstractViolationReporter
-
- com.puppycrawl.tools.checkstyle.api.AbstractCheck
-
- com.puppycrawl.tools.checkstyle.checks.annotation.MissingDeprecatedCheck
-
- All Implemented Interfaces:
Configurable
,Contextualizable
public final class MissingDeprecatedCheck extends AbstractCheck
This class is used to verify that both the
Deprecated
annotation and the deprecated javadoc tag are present when either one is present.Both ways of flagging deprecation serve their own purpose. The
Deprecated
annotation is used for compilers and development tools. The deprecated javadoc tag is used to document why something is deprecated and what, if any, alternatives exist.In order to properly mark something as deprecated both forms of deprecation should be present.
Package deprecation is a exception to the rule of always using the javadoc tag and annotation to deprecate. Only the package-info.java file can contain a Deprecated annotation and it CANNOT contain a deprecated javadoc tag. This is the case with Sun's javadoc tool released with JDK 1.6.0_11. As a result, this check does not deal with Deprecated packages in any way. No official documentation was found confirming this behavior is correct (of the javadoc tool).
To configure this check do the following:
<module name="JavadocDeprecated"/>
In addition you can configure this check with skipNoJavadoc option to allow it to ignore cases when JavaDoc is missing, but still warns when JavaDoc is present but either
Deprecated
is missing from JavaDoc orDeprecated
is missing from the element. To configure this check to allow it use:<property name="skipNoJavadoc" value="true" />
Examples of validating source code with skipNoJavadoc:
@deprecated public static final int MY_CONST = 123456; // no violation /** This javadoc is missing deprecated tag. */ @deprecated public static final int COUNTER = 10; // violation as javadoc exists
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.puppycrawl.tools.checkstyle.api.AutomaticBean
AutomaticBean.OutputStreamOptions
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
MSG_KEY_ANNOTATION_MISSING_DEPRECATED
A key is pointing to the warning message text in "messages.properties" file.static java.lang.String
MSG_KEY_JAVADOC_DUPLICATE_TAG
A key is pointing to the warning message text in "messages.properties" file.static java.lang.String
MSG_KEY_JAVADOC_MISSING
A key is pointing to the warning message text in "messages.properties" file.
-
Constructor Summary
Constructors Constructor Description MissingDeprecatedCheck()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method 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
setSkipNoJavadoc(boolean skipNoJavadoc)
Set skipJavadoc value.void
visitToken(DetailAST ast)
Called to process a token.-
Methods inherited from class com.puppycrawl.tools.checkstyle.api.AbstractCheck
beginTree, clearMessages, destroy, finishTree, getClassLoader, getFileContents, getLine, getLines, getMessages, getTabWidth, getTokenNames, init, isCommentNodesRequired, leaveToken, log, log, log, setClassLoader, setFileContents, setTabWidth, setTokens
-
Methods inherited from class com.puppycrawl.tools.checkstyle.api.AbstractViolationReporter
finishLocalSetup, getCustomMessages, getId, getMessageBundle, getSeverity, getSeverityLevel, setId, setSeverity
-
Methods inherited from class com.puppycrawl.tools.checkstyle.api.AutomaticBean
configure, contextualize, getConfiguration, setupChild
-
-
-
-
Field Detail
-
MSG_KEY_ANNOTATION_MISSING_DEPRECATED
public static final java.lang.String MSG_KEY_ANNOTATION_MISSING_DEPRECATED
A key is pointing to the warning message text in "messages.properties" file.- See Also:
- Constant Field Values
-
MSG_KEY_JAVADOC_DUPLICATE_TAG
public static final java.lang.String MSG_KEY_JAVADOC_DUPLICATE_TAG
A key is pointing to the warning message text in "messages.properties" file.- See Also:
- Constant Field Values
-
MSG_KEY_JAVADOC_MISSING
public static final java.lang.String MSG_KEY_JAVADOC_MISSING
A key is pointing to the warning message text in "messages.properties" file.- See Also:
- Constant Field Values
-
-
Method Detail
-
setSkipNoJavadoc
public void setSkipNoJavadoc(boolean skipNoJavadoc)
Set skipJavadoc value.- Parameters:
skipNoJavadoc
- user's value of skipJavadoc
-
getDefaultTokens
public int[] getDefaultTokens()
Description copied from class:AbstractCheck
Returns the default token a check is interested in. Only used if the configuration for a check does not define the tokens.- Specified by:
getDefaultTokens
in classAbstractCheck
- Returns:
- the default tokens
- See Also:
TokenTypes
-
getAcceptableTokens
public int[] getAcceptableTokens()
Description copied from class:AbstractCheck
The configurable token set. Used to protect Checks against malicious users who specify an unacceptable token set in the configuration file. The default implementation returns the check's default tokens.- Specified by:
getAcceptableTokens
in classAbstractCheck
- Returns:
- the token set this check is designed for.
- See Also:
TokenTypes
-
getRequiredTokens
public int[] getRequiredTokens()
Description copied from class:AbstractCheck
The tokens that this check must be registered for.- Specified by:
getRequiredTokens
in classAbstractCheck
- Returns:
- the token set this must be registered for.
- See Also:
TokenTypes
-
visitToken
public void visitToken(DetailAST ast)
Description copied from class:AbstractCheck
Called to process a token.- Overrides:
visitToken
in classAbstractCheck
- Parameters:
ast
- the token to process
-
-