History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: QUARTZ-374
Type: Task Task
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: James House
Reporter: Jasper Rosenberg
Votes: 0
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
Quartz Scheduler

Add checkstyle support

Created: 20/Mar/06 09:53 AM   Updated: 24/Dec/07 01:30 AM
Component/s: Core
Affects Version/s: 1.6, 1.5.2
Fix Version/s: 1.6


 Description  « Hide
Add new "checkstyle" target to the Quartz build.xml.

It will be run as a dependency of the "compile" target unless "skip.checkstyle" is defined, or the checkstyle.jar is not on the classpath. Checkstyle uses the "GNU LESSER GENERAL PUBLIC LICENSE Version 2.1" so for now it won't be added to the lib/build directory.

Below is the proposed checkstyle file. I think a lot more checks could be added without much debate, but I tried to keep it to just very basic formatting for the first cut. Perhaps the only one that is a bit of a stretch is that I enabled the "NeedBraces" check. This basically requires that single line control blocks are enclosed in braces:

if (doit)
   doit();

becomes:

if (doit) {
    doit();
}

Though this does add an extra line, my experience has been that about 1 in a hundred times this saves you from are a really hard to track down bug, and, in fact, I believe Quartz actually has at least one such bug (QUARTZ-340).

I'm also supporting a suppressions.xml file (which should hopefully be empty for now), so that when we do add more interesting checks we can exclude files that should be allowed to break the rules (I feel pretty strongly that checkstyle should never be allowed to force one to write hard to read code, better to turn it off in such cases. It should be a helper, not a dictator :)

PROPOSED CHECKS:

<!-- Checks for blocks. -->
<!-- See http://checkstyle.sourceforge.net/config_blocks.html -->
<module name="NeedBraces"/>
<module name="LeftCurly">
<property name="option" value="eol"/>
</module>
<module name="RightCurly">
<property name="option" value="same"/>
</module>

<!-- Checks for imports. -->
<!-- http://checkstyle.sourceforge.net/config_import.html -->
<module name="IllegalImport"/>
<module name="AvoidStarImport"/>
<module name="UnusedImports"/>

<!-- Checks for whitespace. -->
<!-- http://checkstyle.sourceforge.net/config_whitespace.html -->
<module name="TabCharacter"/>

<!-- Checks for Modifiers -->
<!-- See http://checkstyle.sf.net/config_modifiers.html -->
<module name="RedundantModifier"/>
<module name="ModifierOrder"/>

<!-- Misc. Checks -->
<!-- See http://checkstyle.sourceforge.net/config_misc.html -->
<module name="Indentation"/>

<!-- Class Design Checks -->
<!-- See http://checkstyle.sourceforge.net/config_design.html -->
<module name="HideUtilityClassConstructor"/>

 All   Comments   Change History      Sort Order:
Jasper Rosenberg - [20/Mar/06 04:00 PM ]
Okay, my eyes are officially crossing. There were aroung 7000 checkstyle warnings when I started. Luckily at least half of those were tabs which could be handled with a search replace. The rest were carpal tunnel-ville though :)

The main source, the three plugins, and the examples are all now being checkstyled as part of the compilation step as long as checkstyle (v 4.1) is on the path and "skip.checkstyle" is not defined. (I just put the checkstyle-all-4.1.jar into lib/build, but one could instead add the antlr.jar and checkstyle-4.1.jar)

I did not setup the webapp to be checkstyled since I didn't want to delve into unfamiliar code right now.

I am also getting this warning from checkstyle:

checkstyle:
[checkstyle] log4j:WARN No appenders could be found for logger (org.apache.commons.beanutils.BeanUtils).
[checkstyle] log4j:WARN Please initialize the log4j system properly.
[checkstyle] Running Checkstyle 4.1 on 32 files

Presumably this is just because there is no log4j.xml file on the classpath. I didn't want to add one without further consultation, but it is an easy thing to rectify if we want to...