Package com.qulice.checkstyle
Class JavadocThrowsCheck
java.lang.Object
com.puppycrawl.tools.checkstyle.AbstractAutomaticBean
com.puppycrawl.tools.checkstyle.api.AbstractViolationReporter
com.puppycrawl.tools.checkstyle.api.AbstractCheck
com.qulice.checkstyle.JavadocThrowsCheck
- All Implemented Interfaces:
com.puppycrawl.tools.checkstyle.api.Configurable,com.puppycrawl.tools.checkstyle.api.Contextualizable
public final class JavadocThrowsCheck
extends com.puppycrawl.tools.checkstyle.api.AbstractCheck
Checks that every
@throws (or @exception) tag in the
javadoc of a method or constructor refers to an exception actually
declared in the throws clause of that method/constructor.
A javadoc that advertises a thrown exception the signature does
not declare is misleading. The same applies when the tag names a
different type than what the signature throws, for example when the
javadoc says @throws IOException but the signature declares
throws Exception. Both examples below are rejected:
/**
* @throws Exception If something goes wrong.
*/
public void foo() {
// ...
}
/**
* @throws IOException If something goes wrong.
*/
public void foo() throws Exception {
// ...
}
Types are compared by their simple name, so a javadoc that uses a
fully qualified name (e.g. java.io.IOException) still
matches a signature that uses the unqualified form, and vice-versa.
- Since:
- 0.24.1
-
Nested Class Summary
Nested classes/interfaces inherited from class com.puppycrawl.tools.checkstyle.AbstractAutomaticBean
com.puppycrawl.tools.checkstyle.AbstractAutomaticBean.OutputStreamOptions -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionint[]int[]int[]voidvisitToken(com.puppycrawl.tools.checkstyle.api.DetailAST ast) Methods inherited from class com.puppycrawl.tools.checkstyle.api.AbstractCheck
beginTree, clearViolations, destroy, finishTree, getFileContents, getFilePath, getLine, getLineCodePoints, getLines, getTabWidth, getTokenNames, getViolations, init, isCommentNodesRequired, 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
-
Constructor Details
-
JavadocThrowsCheck
public JavadocThrowsCheck()
-
-
Method Details
-
getDefaultTokens
public int[] getDefaultTokens()- Specified by:
getDefaultTokensin classcom.puppycrawl.tools.checkstyle.api.AbstractCheck
-
getAcceptableTokens
public int[] getAcceptableTokens()- Specified by:
getAcceptableTokensin classcom.puppycrawl.tools.checkstyle.api.AbstractCheck
-
getRequiredTokens
public int[] getRequiredTokens()- Specified by:
getRequiredTokensin classcom.puppycrawl.tools.checkstyle.api.AbstractCheck
-
visitToken
public void visitToken(com.puppycrawl.tools.checkstyle.api.DetailAST ast) - Overrides:
visitTokenin classcom.puppycrawl.tools.checkstyle.api.AbstractCheck
-