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

Xpath-Suppression is not working for Indentation #8039

Closed
Abhishek-kumar09 opened this issue Apr 5, 2020 · 3 comments
Closed

Xpath-Suppression is not working for Indentation #8039

Abhishek-kumar09 opened this issue Apr 5, 2020 · 3 comments

Comments

@Abhishek-kumar09
Copy link
Contributor

generate-xpath-suppression is not working for Indentation.

$ cat config.xml
<?xml version="1.0"?>
<!DOCTYPE module PUBLIC
          "-//Puppy Crawl//DTD Check Configuration 1.3//EN"
          "http://checkstyle.sourceforge.net/dtds/configuration_1_3.dtd">

<module name = "Checker">
    <module name="TreeWalker">
        <module name="Indentation">               
        </module>
    </module>
</module>
$ cat Test.java
class Test {
    void indentationTest() {
    int indent = 0;

    }
}
$ java -jar checkstyle-8.30-all.jar -g -c config.xml Test.java
Checkstyle ends with 1 errors.

All modules except Indentation can generate their xpath-suppression as usual.
A correctly generated XPath-suppression looks like :

$ cat config.xml
<?xml version="1.0"?>
<!DOCTYPE module PUBLIC
          "-//Puppy Crawl//DTD Check Configuration 1.3//EN"
          "http://checkstyle.sourceforge.net/dtds/configuration_1_3.dtd">

<module name = "Checker">
    <module name="TreeWalker">
        <module name="NoWhitespaceBefore">               
        </module>
    </module>
</module>
$ Test.java
class Test {
  void otherTestIsWorking() {
    int whitespace = 0  ;
  }
}
$ java -jar checkstyle-8.30-all.jar -g -c config.xml Test.java
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suppressions PUBLIC
    "-//Checkstyle//DTD SuppressionXpathFilter Experimental Configuration 1.2//EN"
    "https://checkstyle.org/dtds/suppressions_1_2_xpath_experimental.dtd">
<suppressions>
<suppress-xpath
       files="Test.java"
       checks="NoWhitespaceBeforeCheck"
       query="/CLASS_DEF[./IDENT[@text='Test']]/OBJBLOCK/METHOD_DEF[./IDENT[@text='otherTestIsWorking']]/SLIST/SEMI"/>
</suppressions>
Checkstyle ends with 1 errors.
@wltan
Copy link
Contributor

wltan commented Apr 10, 2020

I would generally expect this to be within the scope of #7734. We update to log DetailAST so that we can generate XPath suppression, not the other way around.

Your PR #8038 is still logging by line + column numbers and not DetailAST nodes, so there will of course be no XPath suppression. If you are having other difficulties, maybe you could elaborate a bit more on why it doesn't work?

@Abhishek-kumar09
Copy link
Contributor Author

Thanks for your review @wltan, I am currently busy with another issue. I will definitely look to your valuable advice in #8038 ., till then I have changed it to draft. Thanks once again.

@Abhishek-kumar09
Copy link
Contributor Author

I have updated the code to give the correct suppression results, I think the issue is worthless now and can be closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants