Checkstyle 3.4

I am readying the 1.0 release of [ehcache](http://ehcache.sf.net), a popular cache for Java.
I received a patch which I was not happy with, which led me to wonder about tightening my [checkstyle](http://checkstyle.sf.net) rules. Until recently I thought the use of tools such as checkstyle to be near universal on well-engineered projects. After all, it promotes *Shared Code Ownership* and *Coding Standards*, two Agile practices. Some excellent coders from the UK I know don’t use it. They say “Oh, thats that thing you use in Australia. How annoying”.
On my current project, I have the leading Agilist also arguing for fewer rules. So what should you do when your team gets larger? Remove rules that new members find annoying? What about when you find consistent coding errors?
I think the right answer is to start with tight checkstyle rules and then add to them when you find problems. This has always been hard after the event because of all the code that fails. However Checkstyle 3.4 includes a new suppresions.xml file where you can suppress rules in specific lines of a file, a whole file or a set of files, using a regular expression. In the rest of this article I suggest the process of doing just that on the ehcache project.


My review of my checkstyle rules has yielded the following new additions to be added to checkstyle.xml:
















































I have removed the following:

The rationale is that some developer find these hard to understand. This seems similar to the justification not to use the *this* keyword in method setters. I don’t think that is sufficient justification to remove a useful language feature.
These changes generated 880 errors. Adding the following suppressions reduced it to 110. These remaining check failures should be fixed.






I made further changes to my code, suppressions.xml and checkstyle.xml.
Here are my full [checkstyle.xml](http://cvs.sourceforge.net/viewcvs.py/ehcache/ehcache/config/checkstyle.xml?view=markup) and my [suppressions.xml](http://cvs.sourceforge.net/viewcvs.py/ehcache/ehcache/config/suppressions.xml?view=markup) files.

By Greg Luck

As Terracotta’s CTO, Greg (@gregrluck) is entrusted with understanding market and technology forces and the business drivers that impact Terracotta’s product innovation and customer success. He helps shape company and technology strategy and designs many of the features in Terracotta’s products. Greg came to Terracotta on the acquisition of the popular caching project Ehcache which he founded in 2003. Prior to joining Terracotta, Greg served as Chief Architect at Australian online travel giant Wotif.com. He also served as a lead consultant for ThoughtWorks on accounts in the United States and Australia, was CIO at Virgin Blue, Tempo Services, Stamford Hotels and Resorts and Australian Resorts and spent seven years as a Chartered Accountant in KPMG’s small business and insolvency divisions. He is a regular speaker at conferences and contributor of articles to the technical press.