Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Checkstyle - Exclude folder

I want to ignore a specific folder (named generated-sources) from my checkstyle reports, because they are generated.

I'm using eclipse-cs for displaying my violations.

i added a suppressionfilter to my xml:

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

my suppressions.xml looks like this:

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

but it is not working. any ideas?

like image 741
Philipp Sander Avatar asked Aug 02 '13 09:08

Philipp Sander


People also ask

How do I exclude files from Checkstyle?

Exclude packages/classes with a configuration file json configuration file, or you can put them into a separate checkstyle-exclude. json file (use -c and -e command line options to change default filenames). Checkstyle will skip files that match an entry under the "all" key.

What is Checkstyle suppression filter?

Checkstyle allows the definition of a list of files and their line ranges that should be suppressed from reporting any violations (known as a suppressions filter ).

What is Checkstyle suppressions XML?

A suppressions XML document contains a set of suppress elements, where each suppress element can have the following attributes: files - a Pattern matched against the file name associated with an audit event. It is optional. checks - a Pattern matched against the name of the check associated with an audit event.


2 Answers

<suppress files="[\\/]generated-sources[\\/]" checks="[a-zA-Z0-9]*"/> 

this works :)

like image 51
Philipp Sander Avatar answered Sep 19 '22 11:09

Philipp Sander


Additionally to the answer from Philipp, I had to use an absolute pathname ( :-( ) for the suppression file:

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

Looks like the Checkstyle plugin is not using the project home directory.

(at least under eclipse luna / Mac OS X)

like image 21
Thomas Welsch Avatar answered Sep 22 '22 11:09

Thomas Welsch