0

'Activating Checkstyle' on a project dishes out two violations for every of the (.wav, .png) resource file in my project :

1. File does not end with a newline.
2. File contains tab characters (this is the first instance).

Normally, both of those violations are easily fixable if they were in the source code, however, shouldn't the format of the resource files not be tampered with just to appease Checkstyle?

The only solutions I see are to either

  1. simply ignore 1000+ resource-related violations
  2. periodically 'Check Code with Checkstyle' on the src folder rather than activate on the entire project. ---> will not dynamically check code.

Both of the solutions are not desirable, any tips?

1 Answers1

1

In Eclipse, you can configure this behavior.

  1. Right-Click on Project --> Properties --> Checkstyle --> Main
  2. Uncheck Use simple configuration
  3. Select the file set and click Edit
  4. Give it a name, let's say Java & Props
  5. Give it a regex for the files to include

One possible regex would be (?i)(?:\.java$|\.properties$), which matches .java and .properties files, but not audio and image files. In the dialog window, it shows you the files that currently match your regex, so you can immediately see if it works.

A drawback of this solution is that this must be done once for every project. I do not know of a central location at which to configure this. Other solutions I could think of is to wrote your own filter, but that requires programming. Earlier versions of Checkstyle restricted themselves to certain file types I think. At least this problem seems to be fairly recent.

barfuin
  • 16,865
  • 10
  • 85
  • 132
  • Thanks for the detailed solution. This worked perfectly and is quick enough to implement that the drawback isn't that big of an issue. Cheers! – Dave Vender Jun 17 '13 at 23:45