View Javadoc
1   /*
2   com.puppycrawl.tools.checkstyle.meta.JavadocMetadataScraper
3   writeXmlOutput = false
4   
5   
6   */
7   
8   package com.puppycrawl.tools.checkstyle.meta.javadocmetadatascraper;
9   
10  import com.puppycrawl.tools.checkstyle.AbstractAutomaticBean;
11  import com.puppycrawl.tools.checkstyle.api.Filter;
12  
13  /**
14   * <p>
15   * Filter {@code SuppressWarningsFilter} uses annotation
16   * {@code SuppressWarnings} to suppress audit events.
17   * </p>
18   * <p>
19   * Rationale: Same as for {@code SuppressionCommentFilter}. In the contrary to it here,
20   * comments are not used comments but the builtin syntax of {@code @SuppressWarnings}.
21   * This can be perceived as a more elegant solution than using comments.
22   * Also, this approach maybe supported by various IDE.
23   * </p>
24   * <p>
25   * Usage: This filter only works in conjunction with a
26   * <a href="https://checkstyle.org/config_annotation.html#SuppressWarningsHolder">
27   * SuppressWarningsHolder</a>,
28   * since that check finds the annotations in the Java files and makes them available for the filter.
29   * Because of that, a configuration that includes this filter must also include
30   * {@code SuppressWarningsHolder} as a child module of the {@code TreeWalker}.
31   * Name of check in annotation is case-insensitive and should be written with
32   * any dotted prefix or "Check" suffix removed.
33   * </p>
34   * <p>
35   * SuppressWarningsFilter can suppress Checks that have Treewalker or
36   * Checker as parent module.
37   * </p>
38   * <p>
39   * To configure the check that makes tha annotations available to the filter.
40   * </p>
41   * <pre>
42   * &lt;module name=&quot;TreeWalker&quot;&gt;
43   *               ...
44   * &lt;module name=&quot;SuppressWarningsHolder&quot; /&gt;
45   *               ...
46   * &lt;/module&gt;
47   * </pre>
48   * <p>
49   * To configure filter to suppress audit events for annotations add:
50   * </p>
51   * <pre>
52   * &lt;module name=&quot;SuppressWarningsFilter&quot; /&gt;
53   * </pre>
54   * <pre>
55   * &#64;SuppressWarnings({"memberName"})
56   * private int J; // should NOT fail MemberNameCheck
57   *
58   * &#64;SuppressWarnings({"MemberName"})
59   * &#64;SuppressWarnings({"NoWhitespaceAfter"})
60   * private int [] ARRAY; // should NOT fail MemberNameCheck and NoWhitespaceAfterCheck
61   * </pre>
62   * <p>
63   * It is possible to specify an ID of checks, so that it can be leveraged by
64   * the SuppressWarningsFilter to skip validations. The following examples show how to
65   * skip validations near code that has {@code @SuppressWarnings("checkstyle:&lt;ID&gt;")}
66   * or just {@code @SuppressWarnings("&lt;ID&gt;")} annotation, where ID is the ID
67   * of checks you want to suppress.
68   * </p>
69   * <p>
70   * Example of Checkstyle check configuration:
71   * </p>
72   * <pre>
73   * &lt;module name=&quot;RegexpSinglelineJava&quot;&gt;
74   *   &lt;property name=&quot;id&quot; value=&quot;systemout&quot;/&gt;
75   *   &lt;property name=&quot;format&quot; value=&quot;^.*System\.(out|err).*$&quot;/&gt;
76   *   &lt;property name=&quot;message&quot;
77   *     value=&quot;Don't use System.out/err, use SLF4J instead.&quot;/&gt;
78   * &lt;/module&gt;
79   * </pre>
80   * <p>
81   * To make the annotations available to the filter.
82   * </p>
83   * <pre>
84   * &lt;module name=&quot;TreeWalker&quot;&gt;
85   *   ...
86   *   &lt;module name=&quot;SuppressWarningsHolder&quot; /&gt;
87   *   ...
88   * &lt;/module&gt;
89   * </pre>
90   * <p>
91   * To configure filter to suppress audit events for annotations add:
92   * </p>
93   * <pre>
94   * skipped as not relevant for UTs
95   * </pre>
96   * <p>
97   * Parent is {@code com.puppycrawl.tools.checkstyle.Checker}
98   * </p>
99   *
100  * @since 5.7
101  */
102 public abstract class InputJavadocMetadataScraperSuppressWarningsFilter
103     extends AbstractAutomaticBean
104     implements Filter {
105 
106 }