Since Checkstyle 8.20
Checks for missing Javadoc comments for class, enum, interface, and annotation
interface definitions. The scope to verify is specified using the Scope
class and defaults to Scope.PUBLIC. To verify
another scope, set property scope to one of the
Scope constants.
| name | description | type | default value | since |
|---|---|---|---|---|
| excludeScope | Specify the visibility scope where Javadoc comments are not checked. | Scope | null |
8.20 |
| scope | Specify the visibility scope where Javadoc comments are checked. | Scope | public |
8.20 |
| skipAnnotations | Specify annotations that allow missed documentation. If annotation is present in target sources in multiple forms of qualified name, all forms should be listed in this property. | String[] | Generated |
8.20 |
| tokens | tokens to check | subset of tokens INTERFACE_DEF , CLASS_DEF , ENUM_DEF , ANNOTATION_DEF , RECORD_DEF . | INTERFACE_DEF , CLASS_DEF , ENUM_DEF , ANNOTATION_DEF , RECORD_DEF . | 8.20 |
To configure the default check to make sure all public class, enum, interface, and annotation interface, definitions have javadocs:
<module name="Checker">
<module name="TreeWalker">
<module name="MissingJavadocType"/>
</module>
</module>
Example:
public class PublicClass {} // violation
private class PublicClass {}
protected class PublicClass {}
class PackagePrivateClass {}
To configure the check for private scope:
<module name="Checker">
<module name="TreeWalker">
<module name="MissingJavadocType">
<property name="scope" value="private"/>
</module>
</module>
</module>
Example:
public class PublicClass {} // violation
private class PublicClass {} // violation
protected class PublicClass {} // violation
class PackagePrivateClass {} // violation
To configure the check for private classes only:
<module name="Checker">
<module name="TreeWalker">
<module name="MissingJavadocType">
<property name="scope" value="private"/>
<property name="excludeScope" value="package"/>
</module>
</module>
</module>
Example:
public class PublicClass {}
private class PublicClass {} // violation
protected class PublicClass {}
class PackagePrivateClass {}
To configure a check that allows missing comments for classes annotated with
@SpringBootApplication and @Configuration:
<module name="Checker">
<module name="TreeWalker">
<module name="MissingJavadocType">
<property name="skipAnnotations" value="SpringBootApplication,Configuration"/>
</module>
</module>
</module>
Example:
@SpringBootApplication // no violations about missing comment on class
public class Application {}
@Configuration // no violations about missing comment on class
class DatabaseConfiguration {}
To configure a check that allows missing comments for classes annotated with
@Annotation and @MyClass.Annotation:
<module name="Checker">
<module name="TreeWalker">
<module name="MissingJavadocType">
<property name="skipAnnotations" value="Annotation,MyClass.Annotation"/>
</module>
</module>
</module>
Example:
@Annotation // ok
class Class1 {}
@MyClass.Annotation // ok
class Class2 {}
@com.mycompany.MyClass.Annotation // violation, as this form is missed in config
class Class3 {}
All messages can be customized if the default message doesn't suit you. Please see the documentation to learn how to.
com.puppycrawl.tools.checkstyle.checks.javadoc