Class MissingJavadocMethodCheck
- 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.javadoc.MissingJavadocMethodCheck
 
 
 
 
- 
- All Implemented Interfaces:
- Configurable,- Contextualizable
 
 public class MissingJavadocMethodCheck extends AbstractCheck Checks for missing Javadoc comments for a method or constructor. The scope to verify is specified using the Scopeclass and defaults toScope.PUBLIC. To verify another scope, set property scope to a different scope.Javadoc is not required on a method that is tagged with the @Overrideannotation. However under Java 5 it is not possible to mark a method required for an interface (this was corrected under Java 6). Hence Checkstyle supports using the convention of using a single{@inheritDoc}tag instead of all the other tags.For getters and setters for the property allowMissingPropertyJavadoc, the methods must match exactly the structures below.public void setNumber(final int number) { mNumber = number; } public int getNumber() { return mNumber; } public boolean isSomething() { return false; }- 
 Property minLineCount- Control the minimal amount of lines in method to allow no documentation. Type isint. Default value is-1.
- 
 Property allowedAnnotations- Configure the list of annotations that allow missed documentation. Type isjava.lang.String[]. Default value isOverride.
- 
 Property scope- Specify the visibility scope where Javadoc comments are checked. Type iscom.puppycrawl.tools.checkstyle.api.Scope. Default value ispublic.
- 
 Property excludeScope- Specify the visibility scope where Javadoc comments are not checked. Type iscom.puppycrawl.tools.checkstyle.api.Scope. Default value isnull.
- 
 Property allowMissingPropertyJavadoc- Control whether to allow missing Javadoc on accessor methods for properties (setters and getters). Type isboolean. Default value isfalse.
- 
 Property ignoreMethodNamesRegex- ignore method whose names are matching specified regex. Type isjava.util.regex.Pattern. Default value isnull.
- 
 Property tokens- tokens to check Type isjava.lang.String[]. Validation type istokenSet. Default value is: METHOD_DEF, CTOR_DEF, ANNOTATION_FIELD_DEF, COMPACT_CTOR_DEF.
 To configure the default check: <module name="MissingJavadocMethod"/> Example: public class Test { public Test() {} // violation, missing javadoc for constructor public void test() {} // violation, missing javadoc for method /** * Some description here. */ public void test2() {} // OK @Override public String toString() { // OK return "Some string"; } private void test1() {} // OK protected void test2() {} // OK void test3() {} // OK }To configure the check for privatescope:<module name="MissingJavadocMethod"> <property name="scope" value="private"/> </module> Example: public class Test { private void test1() {} // violation, the private method is missing javadoc }To configure the check for methods which are in private, but not inprotectedscope:<module name="MissingJavadocMethod"> <property name="scope" value="private"/> <property name="excludeScope" value="protected"/> </module> Example: public class Test { private void test1() {} // violation, the private method is missing javadoc /** * Some description here */ private void test1() {} // OK protected void test2() {} // OK }To configure the check for ignoring methods named foo(),foo1(),foo2(), etc.:<module name="MissingJavadocMethod"> <property name="ignoreMethodNamesRegex" value="^foo.*$"/> </module> Example: public class Test { public void test1() {} // violation, method is missing javadoc public void foo() {} // OK public void foobar() {} // OK }To configure the check for ignoring missing javadoc for accessor methods: <module name="MissingJavadocMethod"> <property name="allowMissingPropertyJavadoc" value="true"/> </module> Example: public class Test { private String text; public void test() {} // violation, method is missing javadoc public String getText() { return text; } // OK public void setText(String text) { this.text = text; } // OK }To configure the check with annotations that allow missed documentation: <module name="MissingJavadocMethod"> <property name="allowedAnnotations" value="Override,Deprecated"/> </module> Example: public class Test { public void test() {} // violation, method is missing javadoc @Override public void test1() {} // OK @Deprecated public void test2() {} // OK @SuppressWarnings public void test3() {} // violation, method is missing javadoc /** * Some description here. */ @SuppressWarnings public void test4() {} // OK }Parent is com.puppycrawl.tools.checkstyle.TreeWalkerViolation Message Keys: - 
 javadoc.missing
 - Since:
- 8.21
 
- 
- 
Nested Class Summary- 
Nested classes/interfaces inherited from class com.puppycrawl.tools.checkstyle.api.AutomaticBeanAutomaticBean.OutputStreamOptions
 
- 
 - 
Field SummaryFields Modifier and Type Field Description static java.lang.StringMSG_JAVADOC_MISSINGA key is pointing to the warning message text in "messages.properties" file.
 - 
Constructor SummaryConstructors Constructor Description MissingJavadocMethodCheck()
 - 
Method SummaryAll 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.voidsetAllowedAnnotations(java.lang.String... userAnnotations)Setter to configure the list of annotations that allow missed documentation.voidsetAllowMissingPropertyJavadoc(boolean flag)Setter to control whether to allow missing Javadoc on accessor methods for properties (setters and getters).voidsetExcludeScope(Scope excludeScope)Setter to specify the visibility scope where Javadoc comments are not checked.voidsetIgnoreMethodNamesRegex(java.util.regex.Pattern pattern)Setter to ignore method whose names are matching specified regex.voidsetMinLineCount(int value)Setter to control the minimal amount of lines in method to allow no documentation.voidsetScope(Scope scope)Setter to specify the visibility scope where Javadoc comments are checked.voidvisitToken(DetailAST ast)Called to process a token.- 
Methods inherited from class com.puppycrawl.tools.checkstyle.api.AbstractCheckbeginTree, clearMessages, destroy, finishTree, getFileContents, getLine, getLines, getMessages, getTabWidth, getTokenNames, init, isCommentNodesRequired, leaveToken, log, log, log, setFileContents, setTabWidth, setTokens
 - 
Methods inherited from class com.puppycrawl.tools.checkstyle.api.AbstractViolationReporterfinishLocalSetup, getCustomMessages, getId, getMessageBundle, getSeverity, getSeverityLevel, setId, setSeverity
 - 
Methods inherited from class com.puppycrawl.tools.checkstyle.api.AutomaticBeanconfigure, contextualize, getConfiguration, setupChild
 
- 
 
- 
- 
- 
Field Detail- 
MSG_JAVADOC_MISSINGpublic static final java.lang.String MSG_JAVADOC_MISSING A key is pointing to the warning message text in "messages.properties" file.- See Also:
- Constant Field Values
 
 
- 
 - 
Method Detail- 
setAllowedAnnotationspublic void setAllowedAnnotations(java.lang.String... userAnnotations) Setter to configure the list of annotations that allow missed documentation.- Parameters:
- userAnnotations- user's value.
 
 - 
setIgnoreMethodNamesRegexpublic void setIgnoreMethodNamesRegex(java.util.regex.Pattern pattern) Setter to ignore method whose names are matching specified regex.- Parameters:
- pattern- a pattern.
 
 - 
setMinLineCountpublic void setMinLineCount(int value) Setter to control the minimal amount of lines in method to allow no documentation.- Parameters:
- value- user's value.
 
 - 
setAllowMissingPropertyJavadocpublic void setAllowMissingPropertyJavadoc(boolean flag) Setter to control whether to allow missing Javadoc on accessor methods for properties (setters and getters).- Parameters:
- flag- a- Booleanvalue
 
 - 
setScopepublic void setScope(Scope scope) Setter to specify the visibility scope where Javadoc comments are checked.- Parameters:
- scope- a scope.
 
 - 
setExcludeScopepublic void setExcludeScope(Scope excludeScope) Setter to specify the visibility scope where Javadoc comments are not checked.- Parameters:
- excludeScope- a scope.
 
 - 
getRequiredTokenspublic final int[] getRequiredTokens() Description copied from class:AbstractCheckThe tokens that this check must be registered for.- Specified by:
- getRequiredTokensin class- AbstractCheck
- Returns:
- the token set this must be registered for.
- See Also:
- TokenTypes
 
 - 
getDefaultTokenspublic int[] getDefaultTokens() Description copied from class:AbstractCheckReturns the default token a check is interested in. Only used if the configuration for a check does not define the tokens.- Specified by:
- getDefaultTokensin class- AbstractCheck
- Returns:
- the default tokens
- See Also:
- TokenTypes
 
 - 
getAcceptableTokenspublic int[] getAcceptableTokens() Description copied from class:AbstractCheckThe 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:
- getAcceptableTokensin class- AbstractCheck
- Returns:
- the token set this check is designed for.
- See Also:
- TokenTypes
 
 - 
visitTokenpublic final void visitToken(DetailAST ast) Description copied from class:AbstractCheckCalled to process a token.- Overrides:
- visitTokenin class- AbstractCheck
- Parameters:
- ast- the token to process
 
 
- 
 
-