Closed
Description
https://checkstyle.org/config_annotation.html#SuppressWarningsHolder
From the issue #11542 (comment)
$ cat Test.java
class Test {
private static final int i = 0;
@SuppressWarnings("checkstyle:constantnamecheck")
private static final int m = 0;
}
$ cat config.xml
<?xml version="1.0"?>
<!DOCTYPE module PUBLIC "-//Puppy Crawl//DTD Check Configuration 1.3//EN" "https://checkstyle.org/dtds/configuration_1_3.dtd">
<module name="Checker">
<property name="charset" value="UTF-8" />
<module name="TreeWalker">
<module name="ConstantName">
</module>
<module name="SuppressWarningsHolder">
</module>
</module>
<module name="SuppressWarningsFilter" />
</module>
$ java -jar /home/kevin/Downloads/checkstyle-10.3-all.jar -c config.xml Test.java
Starting audit...
[ERROR] /home/kevin/Desktop/C_Style/Test.java:3:28: Name 'i' must match pattern '^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$'. [ConstantName]
[ERROR] /home/kevin/Desktop/C_Style/Test.java:6:28: Name 'm' must match pattern '^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$'. [ConstantName]
Audit done.
Checkstyle ends with 2 errors.
Expected no violation at line no:-6 as we are using @SuppressWarnings("checkstyle:constantnamecheck")
Attention: documentation must be updated to mention in words that this is possible, not example is reqired (as it is rarely used names, in all docs all names are without Check).
Activity
[-]Allow SuppressWarningHolders to suppress the violation with NameCheck[/-][+]Allow SuppressWarningHolder to suppress the violation with NameCheck[/+]stoyanK7 commentedon Jul 12, 2022
I am on it.
Issue #11885: Allow SuppressWarningHolder to suppress the violation w…