id attribute of suppress element not working
"Armstrong, Conrad" <[email protected]>
| Newsgroups | gmane.comp.java.audit.checkstyle.user |
|---|---|
| Message-ID | <033033C13EDBB4408C12EC073083B9F709301E4C@INCG2004A.corp.statestr.com> |
It seems like the "id" attribute of the "suppress" element in a
SuppressionFilter file does not work in Checkstyle 4.4.
I have a few GenericIllegalRegexp modules to check for certain method
calls (printStackTrace(), System.exit(), etc.). Using a
SuppressionFilter file, I want to suppress only certain ones for certain
files, so I can't just say:
<suppress checks="GenericIllegalRegexp"
files=".*\\batchprograms\\.*"/>
because that will suppress all my GenericIllegalRegexp modules for those
classes, which I don't want. The documentation says I can use an "id"
attribute instead of "checks". So, I do this in my confiuguration:
<module name="GenericIllegalRegexp">
<property name="id" value="systemexit"/>
<property name="format" value="System\.exit"/>
<property name="message" value="Don''t use System.exit()
unless in a batch program."/>
</module>
and then use this in my SuppressionFilter file:
<suppress id="systemexit" files=".*\\batchprograms\\.*"/>
But Checkstyle fails to parse the SupporessionFilter file, giving this
message:
Unable to create a Checker: cannot initialize module SuppressionFilter -
Cannot set property 'file' in module SuppressionFilter to
'/path_to_my_SuppressionsFilter.xml': unable to parse /
path_to_my_SuppressionsFilter.xml - Attribute "checks" is required and
must be specified for element type "suppress".
I then noticed that the example SuppressionFilter file in the
documentation (http://checkstyle.sourceforge.net/config.html#filters)
references http://www.puppycrawl.com/dtds/suppressions_1_0.dtd, which
indeed says that "checks" attribute is required and doesn't mention an
"id" attribute. So I guessed and found
http://www.puppycrawl.com/dtds/suppressions_1_1.dtd, which does exist
and declares "id" and "checks" to be optional. But if I specify the 1_1
dtd in my SuppressionFilter xml file, the exact same error occurs.
Is this because the knowledge of the 1.0 dtd is built into the
checkstyle jar? Is there something I can do to get around this, or
should I file a bug?
Thanks,
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/