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 * <module name="TreeWalker"> 43 * ... 44 * <module name="SuppressWarningsHolder" /> 45 * ... 46 * </module> 47 * </pre> 48 * <p> 49 * To configure filter to suppress audit events for annotations add: 50 * </p> 51 * <pre> 52 * <module name="SuppressWarningsFilter" /> 53 * </pre> 54 * <pre> 55 * @SuppressWarnings({"memberName"}) 56 * private int J; // should NOT fail MemberNameCheck 57 * 58 * @SuppressWarnings({"MemberName"}) 59 * @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:<ID>")} 66 * or just {@code @SuppressWarnings("<ID>")} 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 * <module name="RegexpSinglelineJava"> 74 * <property name="id" value="systemout"/> 75 * <property name="format" value="^.*System\.(out|err).*$"/> 76 * <property name="message" 77 * value="Don't use System.out/err, use SLF4J instead."/> 78 * </module> 79 * </pre> 80 * <p> 81 * To make the annotations available to the filter. 82 * </p> 83 * <pre> 84 * <module name="TreeWalker"> 85 * ... 86 * <module name="SuppressWarningsHolder" /> 87 * ... 88 * </module> 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 }