
com.puppycrawl.tools.checkstyle.meta.checks.annotation.SuppressWarningsCheck.xml Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of checkstyle Show documentation
Show all versions of checkstyle Show documentation
Checkstyle is a development tool to help programmers write Java code
that adheres to a coding standard
<?xml version="1.0" encoding="UTF-8"?> <checkstyle-metadata> <module> <check fully-qualified-name="com.puppycrawl.tools.checkstyle.checks.annotation.SuppressWarningsCheck" name="SuppressWarnings" parent="com.puppycrawl.tools.checkstyle.TreeWalker"> <description><div> Allows to specify what warnings that {@code @SuppressWarnings} is not allowed to suppress. You can also specify a list of TokenTypes that the configured warning(s) cannot be suppressed on. </div> <p> Limitations: This check does not consider conditionals inside the &#64;SuppressWarnings annotation. </p> <p> For example: {@code @SuppressWarnings((false) ? (true) ? "unchecked" : "foo" : "unused")}. According to the above example, the "unused" warning is being suppressed not the "unchecked" or "foo" warnings. All of these warnings will be considered and matched against regardless of what the conditional evaluates to. The check also does not support code like {@code @SuppressWarnings("un" + "used")}, {@code @SuppressWarnings((String) "unused")} or {@code @SuppressWarnings({('u' + (char)'n') + (""+("used" + (String)"")),})}. </p> <p> By default, any warning specified will be disallowed on all legal TokenTypes unless otherwise specified via the tokens property. </p> <p> Also, by default warnings that are empty strings or all whitespace (regex: ^$|^\s+$) are flagged. By specifying, the format property these defaults no longer apply. </p> <p>This check can be configured so that the "unchecked" and "unused" warnings cannot be suppressed on anything but variable and parameter declarations. See below of an example. </p></description> <properties> <property default-value="^\s*+$" name="format" type="java.util.regex.Pattern"> <description>Specify the RegExp to match against warnings. Any warning being suppressed matching this pattern will be flagged.</description> </property> <property default-value="CLASS_DEF,INTERFACE_DEF,ENUM_DEF,ANNOTATION_DEF,ANNOTATION_FIELD_DEF,ENUM_CONSTANT_DEF,PARAMETER_DEF,VARIABLE_DEF,METHOD_DEF,CTOR_DEF,COMPACT_CTOR_DEF,RECORD_DEF,PATTERN_VARIABLE_DEF" name="tokens" type="java.lang.String[]" validation-type="tokenSet"> <description>tokens to check</description> </property> </properties> <message-keys> <message-key key="suppressed.warning.not.allowed"/> </message-keys> </check> </module> </checkstyle-metadata>
© 2015 - 2025 Weber Informatics LLC | Privacy Policy