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