我有一个看起来像这样的 checkstyle.xml:
<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 个字符,并在其周围放置以下内容:
// CSOFF: LineLength
...
// CSON: LineLength
然而,作为 checkstyle 的一部分,有问题的行不会被忽略。
我在 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