Using Checkstyle’s suppression filters on Windows and Linux

I have already shown the usage of Checkstyle’s suppression filters in Eclipse and Maven in [1]. But after switching from Linux to Windows (please no comments on that…) I wondered about occurring Checkstyle rule violations I actually had excluded in my checkstyle-suppressions.xml. Those rules were mainly simple exclusions of all files within a certain package:

<suppress checks="[a-zA-Z0-9]*" files="src/main/java/de/foo/bar" />

After searching around, I realized that this was an issue with the given regex in the files-attribute [2]. The simple slash was correctly interpreted on Linux, but didn’t work on Windows. So to make the rules work on both operation systems I replaced the path separator with “[/\\]”:

<suppress checks="[a-zA-Z0-9]*" files="src[/\\]main[/\\]java[/\\]de[/\\]foo[/\\]bar" />

Reference

  1. [1] http://rolf-engelhard.de/?p=46
  2. [2] http://checkstyle.2069334.n4.nabble.com/suppression-filter-regex-td2070198.html

Clearing Checkstyle’s Cache in Eclipse

First of all please notice the nice alliteration in the headline.

A little problem which bugged me while searching the solution for [1] was that I had to change my checkstyle.xml and checkstyle-suppression.xml for several times. Unfortunately Eclipse-CS never noticed these modifications. So I restarted Eclipse every time to make the changes apply.

Then I stumbled by chance on an entry in Eclipse-CS’s bug tracker [2]:

“Alternatively to touching the Checkstyle configuration file you can clear the plugin’s caches by clicking the little yellow refresh button on the Checkstyle preferences page.”

And hey—after putting on my glasses and lowering the nose-screen-distance to “way to near”—there it was: a little yellow button on the preference page!

The little yellow checkstyle refresh button.

The little yellow checkstyle refresh button.

Reference

  1. [1] http://rolf-engelhard.de/?p=239
  2. [2] http://sourceforge.net/tracker/?func=detail&aid=1752586&group_id=80344&atid=559497