diff --git a/src/main/java/com/puppycrawl/tools/checkstyle/checks/javadoc/MissingJavadocTypeCheck.java b/src/main/java/com/puppycrawl/tools/checkstyle/checks/javadoc/MissingJavadocTypeCheck.java index 6381efcac63..5fec9b076bb 100644 --- a/src/main/java/com/puppycrawl/tools/checkstyle/checks/javadoc/MissingJavadocTypeCheck.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/checks/javadoc/MissingJavadocTypeCheck.java @@ -53,7 +53,8 @@ * *
  • * Property {@code skipAnnotations} - specify annotations that allow missed - * documentation. Only short names are allowed, e.g. {@code Generated}. + * documentation. If annotation is present in target sources in multiple forms of qualified + * name, all forms should be listed in this property. * Type is {@code java.lang.String[]}. * Default value is {@code Generated}. *
  • @@ -145,6 +146,28 @@ * </module> * *

    + * Example that allows missing comments for classes annotated with {@code @Annotation} + * and {@code @MyClass.Annotation}: + *

    + *
    + * @Annotation // ok
    + * class Class1 {}
    + *
    + * @MyClass.Annotation // ok
    + * class Class2 {}
    + *
    + * @com.mycompany.MyClass.Annotation // violation, as this form is missed in config
    + * class Class3 {}
    + * 
    + *

    + * Use following configuration: + *

    + *
    + * <module name="MissingJavadocType">
    + *   <property name="skipAnnotations" value="Annotation,MyClass.Annotation"/>
    + * </module>
    + * 
    + *

    * Parent is {@code com.puppycrawl.tools.checkstyle.TreeWalker} *

    *

    @@ -174,7 +197,8 @@ public class MissingJavadocTypeCheck extends AbstractCheck { /** * Specify annotations that allow missed documentation. - * Only short names are allowed, e.g. {@code Generated}. + * If annotation is present in target sources in multiple forms of qualified + * name, all forms should be listed in this property. */ private Set skipAnnotations = Set.of("Generated"); @@ -198,7 +222,8 @@ public void setExcludeScope(Scope excludeScope) { /** * Setter to specify annotations that allow missed documentation. - * Only short names are allowed, e.g. {@code Generated}. + * If annotation is present in target sources in multiple forms of qualified + * name, all forms should be listed in this property. * * @param userAnnotations user's value. */ diff --git a/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/javadoc/MissingJavadocTypeCheck.xml b/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/javadoc/MissingJavadocTypeCheck.xml index 44fc5f0f128..1989ce49353 100644 --- a/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/javadoc/MissingJavadocTypeCheck.xml +++ b/src/main/resources/com/puppycrawl/tools/checkstyle/meta/checks/javadoc/MissingJavadocTypeCheck.xml @@ -24,7 +24,8 @@ name="skipAnnotations" type="java.lang.String[]"> specify annotations that allow missed - documentation. Only short names are allowed, e.g. {@code Generated}. + documentation. If annotation is present in target sources in multiple forms of qualified + name, all forms should be listed in this property. skipAnnotations specify annotations that allow missed documentation. - Only short names are allowed, e.g. Generated. + If annotation is present in target sources in multiple forms of qualified + name, all forms should be listed in this property. String[] Generated @@ -2994,6 +2995,27 @@ class DatabaseConfiguration {} <module name="MissingJavadocType"> <property name="skipAnnotations" value="SpringBootApplication,Configuration"/> +</module> + + +

    + Example that allows missing comments for classes annotated with + @Annotation and @MyClass.Annotation: +

    + +@Annotation // ok +class Class1 {} + +@MyClass.Annotation // ok +class Class2 {} + +@com.mycompany.MyClass.Annotation // violation, as this form is missed in config +class Class3 {} + +

    Use following configuration:

    + +<module name="MissingJavadocType"> + <property name="skipAnnotations" value="Annotation,MyClass.Annotation"/> </module>