SuppressionFilter is not working
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.
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.
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>
精彩评论