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

SuppressionXpathSingleFilter suppresses all violations when used with the default configuration #11460

Closed
Vyom-Yadav opened this issue Mar 24, 2022 · 4 comments
Milestone

Comments

@Vyom-Yadav
Copy link
Member

Vyom-Yadav commented Mar 24, 2022

I have read check documentation: https://checkstyle.sourceforge.io/config_filters.html#SuppressionXpathSingleFilter
I have downloaded the latest checkstyle from: https://checkstyle.org/cmdline.html#Download_and_Run
I have executed the cli and showed it below, as cli describes the problem better than 1,000 words

/var/tmp $ javac Test.java

/var/tmp $ cat config.xml
<?xml version="1.0"?>
<!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="SuppressionXpathSingleFilter"/>
    <module name="MissingJavadocTypeCheck">
    </module>
  </module>
</module>

/var/tmp $ cat Test.java
public class Test { // expected violation as all properties of filter are null.
}

/var/tmp $ RUN_LOCALE="-Duser.language=en -Duser.country=US"
/var/tmp $ java $RUN_LOCALE -jar checkstyle-10.0-all.jar -c config.xml Test.java
Starting audit...
Audit done.

Describe what you expect in detail.

The default configuration has all the properties set to null but still the violation is suppressed, if I remove or comment the filter then a violation is thrown-

<?xml version="1.0"?>
<!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="SuppressionXpathSingleFilter"/>-->
    <module name="MissingJavadocTypeCheck">
    </module>
  </module>
</module>
/var/tmp $ RUN_LOCALE="-Duser.language=en -Duser.country=US"
/var/tmp $ java $RUN_LOCALE -jar checkstyle-10.0-all.jar -c config.xml Test.java
Starting audit...
[ERROR] /var/tmp/Test.java:1:1: Missing a Javadoc comment. [MissingJavadocType]
Audit done.
Checkstyle ends with 1 errors.
as23415672 added a commit to cs304-2022/checkstyle that referenced this issue Apr 23, 2022
as23415672 added a commit to cs304-2022/checkstyle that referenced this issue Apr 23, 2022
as23415672 added a commit to cs304-2022/checkstyle that referenced this issue Apr 23, 2022
as23415672 added a commit to cs304-2022/checkstyle that referenced this issue Apr 23, 2022
as23415672 added a commit to cs304-2022/checkstyle that referenced this issue Apr 23, 2022
as23415672 added a commit to cs304-2022/checkstyle that referenced this issue Apr 23, 2022
as23415672 added a commit to cs304-2022/checkstyle that referenced this issue Apr 23, 2022
as23415672 added a commit to cs304-2022/checkstyle that referenced this issue Apr 23, 2022
as23415672 added a commit to cs304-2022/checkstyle that referenced this issue Apr 23, 2022
as23415672 added a commit to cs304-2022/checkstyle that referenced this issue Apr 24, 2022
as23415672 added a commit to cs304-2022/checkstyle that referenced this issue Apr 24, 2022
as23415672 added a commit to cs304-2022/checkstyle that referenced this issue Apr 24, 2022
as23415672 added a commit to cs304-2022/checkstyle that referenced this issue Apr 24, 2022
as23415672 added a commit to cs304-2022/checkstyle that referenced this issue Apr 24, 2022
@pbludov
Copy link
Member

pbludov commented Apr 24, 2022

This case is strange. SuppressionXpathSingleFilter with all properties set to `null' is useless.
It is better to throw a configuration error than silently do nothing if the filter is misconfigured.

@pbludov
Copy link
Member

pbludov commented Apr 24, 2022

At least, this behaviour should be documented, similar to this.

as23415672 added a commit to cs304-2022/checkstyle that referenced this issue Apr 24, 2022
as23415672 added a commit to cs304-2022/checkstyle that referenced this issue Apr 24, 2022
@romani
Copy link
Member

romani commented Apr 24, 2022

It is better to throw a configuration error than silently do nothing if the filter is misconfigured.

There are a lot of modules that do nothing useful or match nothing by default.

as23415672 added a commit to cs304-2022/checkstyle that referenced this issue Apr 24, 2022
as23415672 added a commit to cs304-2022/checkstyle that referenced this issue May 24, 2022
as23415672 added a commit to cs304-2022/checkstyle that referenced this issue May 24, 2022
as23415672 added a commit to cs304-2022/checkstyle that referenced this issue May 24, 2022
as23415672 added a commit to cs304-2022/checkstyle that referenced this issue May 24, 2022
as23415672 added a commit to cs304-2022/checkstyle that referenced this issue May 24, 2022
as23415672 added a commit to cs304-2022/checkstyle that referenced this issue May 24, 2022
as23415672 added a commit to cs304-2022/checkstyle that referenced this issue May 24, 2022
as23415672 added a commit to cs304-2022/checkstyle that referenced this issue May 24, 2022
as23415672 added a commit to cs304-2022/checkstyle that referenced this issue May 24, 2022
as23415672 added a commit to cs304-2022/checkstyle that referenced this issue May 25, 2022
as23415672 added a commit to cs304-2022/checkstyle that referenced this issue May 25, 2022
as23415672 added a commit to cs304-2022/checkstyle that referenced this issue May 25, 2022
as23415672 added a commit to cs304-2022/checkstyle that referenced this issue May 25, 2022
@strkkk
Copy link
Member

strkkk commented May 27, 2022

Fix is merged

@strkkk strkkk closed this as completed May 27, 2022
@strkkk strkkk added the bug label May 27, 2022
@strkkk strkkk added this to the 10.3 milestone May 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants