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] https://rolf-engelhard.de/?p=46
  2. [2] http://checkstyle.2069334.n4.nabble.com/suppression-filter-regex-td2070198.html

Rolf Engelhard

 

Comments (2) Write a comment

Leave a Reply to Oops Cancel reply

Required fields are marked *.