Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow SuppressWarningHolder to suppress the violation with NameCheck #11885

Closed
Kevin222004 opened this issue Jul 11, 2022 · 3 comments · Fixed by #11889
Closed

Allow SuppressWarningHolder to suppress the violation with NameCheck #11885

Kevin222004 opened this issue Jul 11, 2022 · 3 comments · Fixed by #11889

Comments

@Kevin222004
Copy link
Contributor

Kevin222004 commented Jul 11, 2022

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).

@romani romani changed the title Allow SuppressWarningHolders to suppress the violation with NameCheck Allow SuppressWarningHolder to suppress the violation with NameCheck Jul 12, 2022
@stoyanK7
Copy link
Contributor

stoyanK7 commented Jul 12, 2022

I am on it.

stoyanK7 added a commit to stoyanK7/checkstyle that referenced this issue Jul 13, 2022
stoyanK7 added a commit to stoyanK7/checkstyle that referenced this issue Jul 13, 2022
stoyanK7 added a commit to stoyanK7/checkstyle that referenced this issue Jul 13, 2022
stoyanK7 added a commit to stoyanK7/checkstyle that referenced this issue Jul 15, 2022
stoyanK7 added a commit to stoyanK7/checkstyle that referenced this issue Jul 15, 2022
stoyanK7 added a commit to stoyanK7/checkstyle that referenced this issue Jul 16, 2022
stoyanK7 added a commit to stoyanK7/checkstyle that referenced this issue Jul 17, 2022
@romani romani added this to the 10.4 milestone Jul 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
@romani @stoyanK7 @Kevin222004 and others