Checkstyle SuppressionCommentFilter不忽略指定的规则 [英] Checkstyle SuppressionCommentFilter not ignoring specified rule

查看:1074
本文介绍了Checkstyle SuppressionCommentFilter不忽略指定的规则的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个看起来像这样的checkstyle.xml:

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>

在我的一个班级中,我有一个超过200个字符的行,并在其周围添加以下内容:

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

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

然而,有问题的行不会作为checkstyle的一部分被忽略。

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

我在pom.xml中指定了以下内容:

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>

并执行此操作:

mvn checkstyle:checkstyle


推荐答案

您是否已将FileContentsHolder配置为记录

Have you configured FileContentsHolder as documented?

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

这篇关于Checkstyle SuppressionCommentFilter不忽略指定的规则的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆