Class MissingDeprecatedCheck
- All Implemented Interfaces:
Configurable,Contextualizable
@Deprecated and the Javadoc tag
@deprecated are both present when either of them 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 an exception to the rule of always using the javadoc tag and annotation to deprecate. It is not clear if the javadoc tool will support it or not as newer versions keep flip-flopping on if it is supported or will cause an error. See JDK-8160601. The deprecated javadoc tag is currently the only way to say why the package is deprecated and what to use instead. Until this is resolved, if you don't want to print violations on package-info, you can use a filter to ignore these files until the javadoc tool faithfully supports it. An example config using SuppressionSingleFilter is:
<!-- required till https://bugs.openjdk.org/browse/JDK-8160601 -->
<module name="SuppressionSingleFilter">
<property name="checks" value="MissingDeprecatedCheck"/>
<property name="files" value="package-info\.java"/>
</module>
- Since:
- 5.0
-
Nested Class Summary
Nested classes/interfaces inherited from class com.puppycrawl.tools.checkstyle.AbstractAutomaticBean
AbstractAutomaticBean.OutputStreamOptions -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final StringDeprecatedannotation name.private static final StringFully-qualifiedDeprecatedannotation name.static final StringA key is pointing to the warning message text in "messages.properties" file.static final StringA key is pointing to the warning message text in "messages.properties" file.private static final BitSetToken types to find parent of.Fields inherited from class com.puppycrawl.tools.checkstyle.checks.javadoc.AbstractJavadocCheck
MSG_JAVADOC_MISSED_HTML_CLOSE, MSG_JAVADOC_PARSE_RULE_ERROR, MSG_JAVADOC_WRONG_SINGLETON_TAG, MSG_KEY_UNCLOSED_HTML_TAG -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate booleancontainsDeprecatedTag(DetailNode javadoc) Checks to see if the javadoc contains a deprecated tag.int[]Returns the default javadoc token types a check is interested in.private static DetailASTReturns the parent node of the comment.int[]The javadoc tokens that this check must be registered for.voidsetViolateExecutionOnNonTightHtml(boolean shouldReportViolation) Setter to control when to print violations if the Javadoc being examined by this check violates the tight html rules defined at Tight-HTML Rules.voidCalled to process a Javadoc token.Methods inherited from class com.puppycrawl.tools.checkstyle.checks.javadoc.AbstractJavadocCheck
acceptJavadocWithNonTightHtml, beginJavadocTree, beginTree, destroy, finishJavadocTree, finishTree, getAcceptableJavadocTokens, getAcceptableTokens, getBlockCommentAst, getDefaultTokens, getRequiredTokens, init, isCommentNodesRequired, leaveJavadocToken, setJavadocTokens, visitTokenMethods inherited from class com.puppycrawl.tools.checkstyle.api.AbstractCheck
clearViolations, getFileContents, getFilePath, getLine, getLineCodePoints, getLines, getTabWidth, getTokenNames, getViolations, leaveToken, log, log, log, setFileContents, setTabWidth, setTokensMethods inherited from class com.puppycrawl.tools.checkstyle.api.AbstractViolationReporter
finishLocalSetup, getCustomMessages, getId, getMessageBundle, getSeverity, getSeverityLevel, setId, setSeverityMethods inherited from class com.puppycrawl.tools.checkstyle.AbstractAutomaticBean
configure, contextualize, getConfiguration, setupChild
-
Field Details
-
MSG_KEY_ANNOTATION_MISSING_DEPRECATED
A key is pointing to the warning message text in "messages.properties" file.- See Also:
-
MSG_KEY_JAVADOC_DUPLICATE_TAG
A key is pointing to the warning message text in "messages.properties" file.- See Also:
-
DEPRECATED
Deprecatedannotation name.- See Also:
-
FQ_DEPRECATED
Fully-qualifiedDeprecatedannotation name.- See Also:
-
TYPES_HASH_SET
Token types to find parent of.
-
-
Constructor Details
-
MissingDeprecatedCheck
public MissingDeprecatedCheck()
-
-
Method Details
-
getDefaultJavadocTokens
Description copied from class:AbstractJavadocCheckReturns the default javadoc token types a check is interested in.- Specified by:
getDefaultJavadocTokensin classAbstractJavadocCheck- Returns:
- the default javadoc token types
- See Also:
-
getRequiredJavadocTokens
Description copied from class:AbstractJavadocCheckThe javadoc tokens that this check must be registered for.- Overrides:
getRequiredJavadocTokensin classAbstractJavadocCheck- Returns:
- the javadoc token set this must be registered for.
- See Also:
-
setViolateExecutionOnNonTightHtml
Setter to control when to print violations if the Javadoc being examined by this check violates the tight html rules defined at Tight-HTML Rules.- Overrides:
setViolateExecutionOnNonTightHtmlin classAbstractJavadocCheck- Parameters:
shouldReportViolation- value to which the field shall be set to- Since:
- 8.3
-
visitJavadocToken
Description copied from class:AbstractJavadocCheckCalled to process a Javadoc token.- Specified by:
visitJavadocTokenin classAbstractJavadocCheck- Parameters:
ast- the token to process
-
containsDeprecatedTag
Checks to see if the javadoc contains a deprecated tag.- Parameters:
javadoc- the javadoc of the AST- Returns:
- true if contains the tag
-
getParent
Returns the parent node of the comment.- Parameters:
commentBlock- child node.- Returns:
- parent node.
-