Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SuppressionFilter is not working

Tags:

checkstyle

SuppressionFilter is not ignoring the files which are given in suppressions.xml

In checkstyle.xml,

<module name="Checker">
    <module name="SuppressionFilter">
      <property name="file" value="/home/svn/testrepo/scripts/suppressions.xml"/>
    </module>
    <module name="TreeWalker">
....
</module>

In suppressions.xml (which is in /home/svn/testrepo/scripts),

<?xml version="1.0"?>
<!DOCTYPE suppressions PUBLIC
    "-//Puppy Crawl//DTD Suppressions 1.0//EN"
    "http://www.puppycrawl.com/dtds/suppressions_1_0.dtd">
<suppressions>
    <suppress checks="."
              files="Constants.java" />
</suppressions>

Also, tried with the below one:

<suppressions>
    <suppress files="Constants\.java" checks="[a-zA-Z0-9]*"/>
</suppressions>

Also, tried with:

<suppressions>
    <suppress checks=".*"
              files="Constants.java" />
</suppressions>

None of the options are working. Can anybody have answers on this? Please help me out.

like image 833
Kavitha Avatar asked Oct 28 '25 15:10

Kavitha


2 Answers

Assuming you configure the filter using:

    <module name="SuppressionFilter">
      <property name="file" value="suppressions.xml"/>
    </module>

Then an example content of suppressions.xml could be:

<?xml version="1.0"?>
<!DOCTYPE suppressions PUBLIC
    "-//Puppy Crawl//DTD Suppressions 1.1//EN"
    "http://www.puppycrawl.com/dtds/suppressions_1_1.dtd">
<suppressions>
    <suppress checks="."  files="[\\/]SoapAdapter\.java$"/>
</suppressions>

This will then suppress all checks for the files named SoapAdapter.java. Note that [\\/] is just a regular expression to handle file names under Unix (which use /) and Windows (which use \).

Also recommend reading the Checkstyle documenation on the subject at http://checkstyle.sourceforge.net/config.html.

like image 55
Oliver Avatar answered Oct 31 '25 12:10

Oliver


just add ${config_loc} in front of value as described in the official documentation

<module name="SuppressionFilter">
    <property name="file" value="${config_loc}/suppressions.xml"/>
</module>
like image 31
qoomon Avatar answered Oct 31 '25 13:10

qoomon



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!