Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #11736: Update doc for MissingJavadocTypeCheck #11886

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -53,7 +53,8 @@
* </li>
* <li>
* 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}.
* </li>
Expand Down Expand Up @@ -126,8 +127,16 @@
* class PackagePrivateClass {}
* </pre>
* <p>
* Example that allows missing comments for classes annotated with {@code @SpringBootApplication}
* and {@code @Configuration}:
* To configure a check that allows missing comments for classes annotated
* with {@code @SpringBootApplication} and {@code @Configuration}:
* </p>
* <pre>
* &lt;module name="MissingJavadocType"&gt;
* &lt;property name="skipAnnotations" value="SpringBootApplication,Configuration"/&gt;
* &lt;/module&gt;
* </pre>
* <p>
* Example:
* </p>
* <pre>
* &#64;SpringBootApplication // no violations about missing comment on class
Expand All @@ -137,14 +146,28 @@
* class DatabaseConfiguration {}
* </pre>
* <p>
* Use following configuration:
* To configure a check that allows missing comments for classes annotated with {@code @Annotation}
* and {@code @MyClass.Annotation}:
* </p>
* <pre>
* &lt;module name="MissingJavadocType"&gt;
* &lt;property name="skipAnnotations" value="SpringBootApplication,Configuration"/&gt;
* &lt;property name="skipAnnotations" value="Annotation,MyClass.Annotation"/&gt;
* &lt;/module&gt;
* </pre>
* <p>
* Example:
* </p>
* <pre>
* &#64;Annotation // ok
* class Class1 {}
*
* &#64;MyClass.Annotation // ok
* class Class2 {}
*
* &#64;com.mycompany.MyClass.Annotation // violation, as this form is missed in config
* class Class3 {}
* </pre>
* <p>
* Parent is {@code com.puppycrawl.tools.checkstyle.TreeWalker}
* </p>
* <p>
Expand Down Expand Up @@ -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<String> skipAnnotations = Set.of("Generated");

Expand All @@ -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.
*/
Expand Down
Expand Up @@ -24,7 +24,8 @@
name="skipAnnotations"
type="java.lang.String[]">
<description>specify annotations that allow missed
documentation. Only short names are allowed, e.g. {@code Generated}.</description>
documentation. If annotation is present in target sources in multiple forms of qualified
name, all forms should be listed in this property.</description>
</property>
<property default-value="INTERFACE_DEF,CLASS_DEF,ENUM_DEF,ANNOTATION_DEF,RECORD_DEF"
name="tokens"
Expand Down
32 changes: 27 additions & 5 deletions src/xdocs/config_javadoc.xml
Expand Up @@ -2885,7 +2885,8 @@ package com.checkstyle.api; // violation
<td>skipAnnotations</td>
<td>
specify annotations that allow missed documentation.
Only short names are allowed, e.g. <code>Generated</code>.
If annotation is present in target sources in multiple forms of qualified
name, all forms should be listed in this property.
</td>
<td><a href="property_types.html#String.5B.5D">String[]</a></td>
<td><code>Generated</code></td>
Expand Down Expand Up @@ -2979,23 +2980,44 @@ protected class PublicClass {}
class PackagePrivateClass {}
</source>

<p>
Example that allows missing comments for classes annotated with
<p>To configure a check that allows missing comments for classes annotated with
<code>@SpringBootApplication</code> and <code>@Configuration</code>:
</p>
<source>
&lt;module name="MissingJavadocType"&gt;
&lt;property name="skipAnnotations" value="SpringBootApplication,Configuration"/&gt;
&lt;/module&gt;
</source>
<p>Example:</p>
<source>
@SpringBootApplication // no violations about missing comment on class
public class Application {}

@Configuration // no violations about missing comment on class
class DatabaseConfiguration {}
</source>
<p>Use following configuration:</p>

<p>To configure a check that allows missing comments for classes annotated with
<code>@Annotation</code> and <code>@MyClass.Annotation</code>:
</p>
<source>
&lt;module name="MissingJavadocType"&gt;
&lt;property name="skipAnnotations" value="SpringBootApplication,Configuration"/&gt;
&lt;property name="skipAnnotations" value="Annotation,MyClass.Annotation"/&gt;
&lt;/module&gt;
</source>
<p>
Example:
</p>
<source>
@Annotation // ok
class Class1 {}

@MyClass.Annotation // ok
class Class2 {}

@com.mycompany.MyClass.Annotation // violation, as this form is missed in config
class Class3 {}
</source>
</subsection>

<subsection name="Example of Usage" id="MissingJavadocType_Example_of_Usage">
Expand Down