Identified at #6807 (comment) ,
XPath was generated for a single check and it suppressed all issues.
$ javac Test1.java
$ cat Test1.java
public class Test1 {
{}
static {}
void method6(int a) {
{}; //ok
}
void method7(int a) {} //ok
void method8(int a) {/*:)*/} //ok, should be violation
class TestClass4 {} //ok
enum Test {}
interface Interface {}
@interface ClassPreamble { } //ok, should be violation, as there is space
}
$ cat config.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE module PUBLIC "-//Checkstyle//DTD Checkstyle Configuration 1.3//EN"
"https://checkstyle.org/dtds/configuration_1_3.dtd">
<module name="Checker">
<module name="TreeWalker">
<module name="RightCurly">
<property name="id" value="RightCurlyAlone"/>
<property name="option" value="alone"/>
<property name="tokens"
value="CLASS_DEF, METHOD_DEF, CTOR_DEF, LITERAL_FOR,
LITERAL_WHILE, STATIC_INIT,
INSTANCE_INIT, ANNOTATION_DEF, ENUM_DEF"/>
</module>
<module name="SuppressionXpathSingleFilter">
<property name="id" value="RightCurlyAlone"/>
<property name="query" value="//RCURLY[parent::SLIST[count(./*)=1]
or parent::OBJBLOCK[count(./*)=2]]"/>
</module>
</module>
</module>
$ java -jar /var/tmp/checkstyle-8.29-all.jar -c config.xml Test1.java
Starting audit...
Audit done.
However, once a comment aware check is added, TodoComment, the suppression fails for one instance, which have comments in the violation path.
$ cat TestClass.java
public class Test1 {
{}
static {}
void method6(int a) {
{}; //ok
}
void method7(int a) {} //ok
void method8(int a) {/*:)*/} //ok, should be violation
class TestClass4 {} //ok
enum Test {}
interface Interface {}
@interface ClassPreamble { } //ok, should be violation, as there is space
}
$ cat TestConfig.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">
<module name="TreeWalker">
<module name="RightCurly">
<property name="id" value="RightCurlyAlone"/>
<property name="option" value="alone"/>
<property name="tokens"
value="CLASS_DEF, METHOD_DEF, CTOR_DEF, LITERAL_FOR,
LITERAL_WHILE, STATIC_INIT,
INSTANCE_INIT, ANNOTATION_DEF, ENUM_DEF"/>
</module>
<module name="TodoComment" />
<module name="SuppressionXpathSingleFilter">
<property name="id" value="RightCurlyAlone"/>
<property name="query" value="//RCURLY[parent::SLIST[count(./*)=1]
or parent::OBJBLOCK[count(./*)=2]]"/>
</module>
</module>
</module>
$ java -jar checkstyle-8.29-all.jar -c TestConfig.xml TestClass.java
Starting audit...
[ERROR] TestClass.java:11:32: '}' at column 32 should be alone on a line. [RightCurlyAlone]
Audit done.
Checkstyle ends with 1 errors.
This shows a direct correlation between xpath suppressions and the type of checks added to a configuration. This is not very user friendly as users are directly aware if a check is comment aware or not. This could cause issues with generating a case that works for everyone.
Identified at #6807 (comment) ,
XPath was generated for a single check and it suppressed all issues.
However, once a comment aware check is added, TodoComment, the suppression fails for one instance, which have comments in the violation path.
This shows a direct correlation between xpath suppressions and the type of checks added to a configuration. This is not very user friendly as users are directly aware if a check is comment aware or not. This could cause issues with generating a case that works for everyone.