IllegalTokenTextCheck and IllegalTokenCheck does not work with COMMENT_CONTENT token #3153

Closed
Qix- opened this Issue May 3, 2016 · 3 comments

Comments

Projects
None yet
3 participants
@Qix-

Qix- commented May 3, 2016

The error message says it all.

$ cat TestConfig.xml
<?xml version="1.0"?>
<!DOCTYPE module PUBLIC
          "-//Puppy Crawl//DTD Check Configuration 1.3//EN"
          "http://www.puppycrawl.com/dtds/configuration_1_3.dtd">

<module name="Checker">
    <module name="TreeWalker">
        <module name="IllegalTokenText">
            <property name="tokens" value="COMMENT_CONTENT" />
        </module>
    </module>
</module>
com.puppycrawl.tools.checkstyle.api.CheckstyleException: cannot initialize module TreeWalker - Check 'com.puppycrawl.tools.checkstyle.check
s.coding.IllegalTokenTextCheck' waits for comment type token ('COMMENT_CONTENT') and should override 'isCommentNodesRequired()' method to r
eturn 'true'
        at com.puppycrawl.tools.checkstyle.Checker.setupChild(Checker.java:181)
        at com.puppycrawl.tools.checkstyle.api.AutomaticBean.configure(AutomaticBean.java:138)
        at com.puppycrawl.tools.checkstyle.Main.runCheckstyle(Main.java:326)
        at com.puppycrawl.tools.checkstyle.Main.main(Main.java:159)
Caused by: com.puppycrawl.tools.checkstyle.api.CheckstyleException: Check 'com.puppycrawl.tools.checkstyle.checks.coding.IllegalTokenTextCh
eck' waits for comment type token ('COMMENT_CONTENT') and should override 'isCommentNodesRequired()' method to return 'true'
        at com.puppycrawl.tools.checkstyle.TreeWalker.registerCheck(TreeWalker.java:266)
        at com.puppycrawl.tools.checkstyle.TreeWalker.registerCheck(TreeWalker.java:221)
        at com.puppycrawl.tools.checkstyle.TreeWalker.setupChild(TreeWalker.java:162)
        at com.puppycrawl.tools.checkstyle.api.AutomaticBean.configure(AutomaticBean.java:138)
        at com.puppycrawl.tools.checkstyle.Checker.setupChild(Checker.java:176)
        ... 3 more
Checkstyle ends with 1 errors.

Definitely a bug :) Currently can't check comment contents for potentially insecure content at my company!

@romani

This comment has been minimized.

Show comment
Hide comment
@romani

romani May 3, 2016

Member

we need to update the Check to override this method.

Unrelated discussion is moved to https://groups.google.com/forum/#!topic/checkstyle/D9fcAs40ILM

Member

romani commented May 3, 2016

we need to update the Check to override this method.

Unrelated discussion is moved to https://groups.google.com/forum/#!topic/checkstyle/D9fcAs40ILM

@romani romani self-assigned this May 3, 2016

@romani romani changed the title from IllegalTokenTextCheck doesn't indicate COMMENT_CONTENT is required. to IllegalTokenTextCheck does not work with COMMENT_CONTENT token May 3, 2016

romani added a commit that referenced this issue May 3, 2016

@rnveach

This comment has been minimized.

Show comment
Hide comment
@rnveach

rnveach May 3, 2016

Member

The issue is with any checks that have TokenUtils.getAllTokenIds as acceptable tokens. The issue can be seen with IllegalTokenCheck.

$ cat TestClass.java
public class TestClass {
    void method() {
    }
}

$ cat TestConfig.xml
<?xml version="1.0"?>
<!DOCTYPE module PUBLIC
          "-//Puppy Crawl//DTD Check Configuration 1.3//EN"
          "http://www.puppycrawl.com/dtds/configuration_1_3.dtd">

<module name="Checker">
    <property name="charset" value="UTF-8"/>

    <module name="TreeWalker">
<module name="IllegalTokenCheck">
<property name="tokens" value="COMMENT_CONTENT" />
</module>
    </module>
</module>

$ java -jar checkstyle-6.18-all.jar -c TestConfig.xml TestClass.java
com.puppycrawl.tools.checkstyle.api.CheckstyleException: cannot initialize module TreeWalker - Check 'com.puppycrawl.tools.checkstyle.checks.coding.IllegalTokenCheck' waits for comment type token ('COMMENT_CONTENT') and should override 'isCommentNodesRequired()' method to return 'true'
    at com.puppycrawl.tools.checkstyle.Checker.setupChild(Checker.java:376)
    at com.puppycrawl.tools.checkstyle.api.AutomaticBean.configure(AutomaticBean.java:138)
    at com.puppycrawl.tools.checkstyle.Main.runCheckstyle(Main.java:337)
    at com.puppycrawl.tools.checkstyle.Main.main(Main.java:170)
Caused by: com.puppycrawl.tools.checkstyle.api.CheckstyleException: Check 'com.puppycrawl.tools.checkstyle.checks.coding.IllegalTokenCheck' waits for comment type token ('COMMENT_CONTENT') and should override 'isCommentNodesRequired()' method to return 'true'
    at com.puppycrawl.tools.checkstyle.TreeWalker.registerCheck(TreeWalker.java:266)
    at com.puppycrawl.tools.checkstyle.TreeWalker.registerCheck(TreeWalker.java:221)
    at com.puppycrawl.tools.checkstyle.TreeWalker.setupChild(TreeWalker.java:162)
    at com.puppycrawl.tools.checkstyle.api.AutomaticBean.configure(AutomaticBean.java:138)
    at com.puppycrawl.tools.checkstyle.Checker.setupChild(Checker.java:371)
    ... 3 more
Checkstyle ends with 1 errors.
Member

rnveach commented May 3, 2016

The issue is with any checks that have TokenUtils.getAllTokenIds as acceptable tokens. The issue can be seen with IllegalTokenCheck.

$ cat TestClass.java
public class TestClass {
    void method() {
    }
}

$ cat TestConfig.xml
<?xml version="1.0"?>
<!DOCTYPE module PUBLIC
          "-//Puppy Crawl//DTD Check Configuration 1.3//EN"
          "http://www.puppycrawl.com/dtds/configuration_1_3.dtd">

<module name="Checker">
    <property name="charset" value="UTF-8"/>

    <module name="TreeWalker">
<module name="IllegalTokenCheck">
<property name="tokens" value="COMMENT_CONTENT" />
</module>
    </module>
</module>

$ java -jar checkstyle-6.18-all.jar -c TestConfig.xml TestClass.java
com.puppycrawl.tools.checkstyle.api.CheckstyleException: cannot initialize module TreeWalker - Check 'com.puppycrawl.tools.checkstyle.checks.coding.IllegalTokenCheck' waits for comment type token ('COMMENT_CONTENT') and should override 'isCommentNodesRequired()' method to return 'true'
    at com.puppycrawl.tools.checkstyle.Checker.setupChild(Checker.java:376)
    at com.puppycrawl.tools.checkstyle.api.AutomaticBean.configure(AutomaticBean.java:138)
    at com.puppycrawl.tools.checkstyle.Main.runCheckstyle(Main.java:337)
    at com.puppycrawl.tools.checkstyle.Main.main(Main.java:170)
Caused by: com.puppycrawl.tools.checkstyle.api.CheckstyleException: Check 'com.puppycrawl.tools.checkstyle.checks.coding.IllegalTokenCheck' waits for comment type token ('COMMENT_CONTENT') and should override 'isCommentNodesRequired()' method to return 'true'
    at com.puppycrawl.tools.checkstyle.TreeWalker.registerCheck(TreeWalker.java:266)
    at com.puppycrawl.tools.checkstyle.TreeWalker.registerCheck(TreeWalker.java:221)
    at com.puppycrawl.tools.checkstyle.TreeWalker.setupChild(TreeWalker.java:162)
    at com.puppycrawl.tools.checkstyle.api.AutomaticBean.configure(AutomaticBean.java:138)
    at com.puppycrawl.tools.checkstyle.Checker.setupChild(Checker.java:371)
    ... 3 more
Checkstyle ends with 1 errors.

romani added a commit that referenced this issue May 4, 2016

@romani romani changed the title from IllegalTokenTextCheck does not work with COMMENT_CONTENT token to IllegalTokenTextCheck and IllegalTokenCheck does not work with COMMENT_CONTENT token May 4, 2016

romani added a commit that referenced this issue May 7, 2016

romani added a commit that referenced this issue May 7, 2016

romani added a commit that referenced this issue May 8, 2016

@romani romani added this to the 6.19 milestone May 8, 2016

@romani

This comment has been minimized.

Show comment
Hide comment
@romani

romani May 8, 2016

Member

fix is merged.

Member

romani commented May 8, 2016

fix is merged.

@romani romani closed this May 8, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment