javacheckstyle

How to suppress all checks for a file in Checkstyle?


I'm doing an override for a third party class and I want to suppress all checks for it (since I'm only keeping it around until the patch is accepted).

Is there a way to suppress all checks for a file?

I tried using "*" but that fails.


Solution

  • Don't know whether you're using command line or in an IDE, but you'll basically need a suppresions file. If you're manually editing the Checkstyle config file, add a new module to it:

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

    Your mysuppression.xml can be something like:

    <?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="TheClassToIgnore\.java" checks="[a-zA-Z0-9]*"/>
    </suppressions>
    

    The value for "files" attribute is basically a regex for your source files, and the value for the "checks" attribute is regex for what checks to skip ("[a-zA-Z0-9]*" basically means skip everything). This is the pattern you're looking for I guess?