Skip to content

Allow SuppressWarningHolder to suppress the violation with NameCheck #11885

Closed
@Kevin222004

Description

@Kevin222004

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

changed the title [-]Allow SuppressWarningHolders to suppress the violation with NameCheck[/-] [+]Allow SuppressWarningHolder to suppress the violation with NameCheck[/+] on Jul 12, 2022
stoyanK7

stoyanK7 commented on Jul 12, 2022

@stoyanK7
Contributor

I am on it.

added a commit that references this issue on Jul 29, 2022

Issue #11885: Allow SuppressWarningHolder to suppress the violation w…

added this to the 10.4 milestone on Jul 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

      Participants

      @romani@stoyanK7@Kevin222004

      Issue actions

        Allow SuppressWarningHolder to suppress the violation with NameCheck · Issue #11885 · checkstyle/checkstyle