How to ignore a complete Java package in Checkstyle

One of my Java projects contains generated code which produces quite a few Checkstyle warnings. To ignore all files in this package, I needed to configure Checkstyle’s module SuppressionFilter as described in Checkstyle’s documentation:

File checkstyle.xml (Checkstyle config):

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

File suppressions.xml:

<?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="[\\/]PACKAGENAME[\\/].*\.java$"/>
</suppressions>

This ignores all files whose path contains /PACKAGENAME/.

Über Stefan

Polyglot Clean Code Developer

Ein Kommentar

  1. Thank you for your short but precise post.

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert

To create code blocks or other preformatted text, indent by four spaces:

    This will be displayed in a monospaced font. The first four 
    spaces will be stripped off, but all other whitespace
    will be preserved.
    
    Markdown is turned off in code blocks:
     [This is not a link](http://example.com)

To create not a block, but an inline code span, use backticks:

Here is some inline `code`.

For more help see http://daringfireball.net/projects/markdown/syntax