I'm trying to use suppression filter but an unexpected error occurs.
Following is an error message.
"cannot initialize module SuppressionFilter - Cannot set property 'file' in module SuppressionFilter to 'checkstyle-suppressions.xml': unable to find checkstyle-suppressions.xml - Document root element "suppressions", must match DOCTYPE root "module"."
Could you let me know how can I resolve this error?
Followings are a configuration file and a suppression file contents which I used. I configured the suppression filter through eclipse menu(windows > preferences > checkstyle > configure > known modules Filter > Suppression Filter > add)
======================================
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE module PUBLIC "-//Puppy Crawl//DTD Check Configuration 1.3//EN" "http://www.puppycrawl.com/dtds/configuration_1_3.dtd">
<module name="Checker">
<property name="severity" value="warning"/>
<module name="TreeWalker">
<module name="MagicNumber">
<property name="ignoreNumbers" value="-1, 0, 1"/>
</module>
</module>
</module>
===================================
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE module PUBLIC "-//Puppy Crawl//DTD Check Configuration 1.3//EN" "http://www.puppycrawl.com/dtds/configuration_1_3.dtd">
<suppressions>
<suppress checks="MagicNumberCheck"
files="Home.java"
lines="350-370"/>
</suppressions>
Then to disable Checkstyle, you use //CHECKSTYLE:OFF and //CHECKSTYLE:ON (default values) in your code.
Show activity on this post. In latest eclipse version(9/2014) we have to visit Help -> Eclipse Market and go to installed tab. Then select uninstall. After uninstallation this will ask for a eclipse restart.
Right-click on the project. Click on Checkstyle and Activate Checkstyle . (Or, if there is no Checkstyle entry, click on Properties and then select “Checkstyle”, check “Checkstyle active…” and click on OK .)
Your suppression filter file uses the 1.1 syntax, but claims to be using the newer 1.3 syntax. Exchange the header like so:
<!DOCTYPE suppressions PUBLIC "-//Puppy Crawl//DTD Suppressions 1.1//EN"
"http://www.puppycrawl.com/dtds/suppressions_1_1.dtd">
Also, your configuration file must reference the suppression filter. Add a module definition like this (add it before the last closing </module>
tag, not under Treewalker
):
<module name="SuppressionFilter">
<property name="file" value="${workspace_loc}/MyProject/suppressions.xml"/>
</module>
Using the ${workspace_loc}
variable makes sure that this works even when you copy or rename the workspace.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With