Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo


#604 Directory recursion includes non-Java files

Oliver Burn
Bob Tarling

This is actually in Release 5.1 but as there is no group I assume it is also in SVN

I'm trying to use the command line interface to recurse through several projects in one hit. Problem is it picks up non-Java files and tries to analyse .xml, .jar etc.

To reolve this could you ignore a non-java extension or allow a filename pattern to be provided in command line argument


  • Lars Kühne
    Lars Kühne

    This behavior is indeed different from what the docs says for the -r arg ("specify the directory to traverse for Java source files"). I think the docs should be changed to reflect the current implementation.

    Why is the implemented behavior a problem for you? With a configuration that includes only java checks the non-java files should be ignored anyway. Would it be feasible to strip down your config file?

    Another workaround might be not use the -r flag and build the list of files before calling checkstyle. On Unix you can use the 'find' command to achieve this:

    java -jar checkstyle-all-5.1.jar -c sun_checks.xml find -name '*.java'

  • Bob Tarling
    Bob Tarling

    I guess the problem is that we don't use unix in my workplace.

    My task was to take a whole load of projects my company has just taken ownership of and to do a quality review. The command line option appeared to be the quickest way to give me some the stats I needed without any further work.

    In the end I copied the directory structure and then deleted anything that copy wasn't *.java. Even for that Windows is not so helpful.

    It seems a shame to me that checkstyle would not give this OOTB in a future release.

  • Roman Ivanov
    Roman Ivanov

    • status: open --> closed