Adding package suppressions in Checkstyle and Spotbugs


I was recently trying to add a package level suppression in both checkstyle / spotbugs and found it to be having weird syntax.

For checkstyle,

First add a module in your checkstyle configuration file

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

And then in the suppressions.xml , specify the package as follows:

<?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 files="[\\/]com[\\/]domain[\\/]package" checks="."/>
</suppressions>

For, Spotbugs, you specify the package level suppression in the exclude file as follows

<FindBugsFilter>
    <Match>
        <Package name="~com\.domain\.package.*"/>
    </Match>
</FindBugsFilter>