Checkstyle SuppressionCommentFilter not ignoring specified rule

ぃ、小莉子 提交于 2019-12-21 03:37:18

问题


I have a checkstyle.xml that looks something like this:

<module name="Checker">
    ....

    <module name="SuppressionCommentFilter">
        <property name="offCommentFormat" value="CSOFF\: ([\w\|]+)"/>
        <property name="onCommentFormat" value="CSON\: ([\w\|]+)"/>
        <property name="checkFormat" value="$1"/>
    </module>

    <module name="TreeWalker">
        <module name="LineLength">
            <property name="max" value="200"/>
        </module>
        ....
    </module>
</module>

In one of my classes, I have a line longer than 200 characters and put the following around it:

// CSOFF: LineLength
...
// CSON: LineLength

The line in question however is not ignored as part of checkstyle.

I have specified the following in the pom.xml:

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-checkstyle-plugin</artifactId>
            <version>2.6</version>
            <configuration>
                <configLocation>checkstyle.xml</configLocation>
            </configuration>
        </plugin>
    </plugins>
</build>

and executing this:

mvn checkstyle:checkstyle

回答1:


Have you configured FileContentsHolder as documented?

<module name="TreeWalker">
    ...
    <module name="FileContentsHolder"/>
    ...
</module>


来源:https://stackoverflow.com/questions/5761188/checkstyle-suppressioncommentfilter-not-ignoring-specified-rule

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!