digiarnie digiarnie - 6 months ago 61
Java Question

Checkstyle SuppressionCommentFilter not ignoring specified rule

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 name="TreeWalker">
<module name="LineLength">
<property name="max" value="200"/>

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:


and executing this:

mvn checkstyle:checkstyle

Answer Source

Have you configured FileContentsHolder as documented?

<module name="TreeWalker">
    <module name="FileContentsHolder"/>
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download