Checkstyle is a tool to run a set of checks over Java source code. Traditionally it has been used to enforce a coding standard, but release 3.x architecture changes all that - it's not just about layout anymore.
The 3.x architecture is based around pluggable modules. This means that users can now write their own checks without changing the sourcecode of Checkstyle itself. A detailed tutorial is provided on how to write a check at http://checkstyle.sourceforge.net/writingchecks.html.
Using the new pluggable modules it is possible to developed sophisticated checks for J2EE projects. For example, Checkstyle now comes with checks to detect:
* Usage of the flawed double checked locking pattern
* Instantiation of illegal objects. Great for finding where people are violating J2EE container requirements by creating sockets or threads
Great care was taken in designing the new architecture to not sacrifice the excellent performance of Checkstyle. The configuration has been completely revamped and it is now possible to configure down to the token level. So for example, whitespace checking can be configured to only look at the "==" token.
The 3.1 release of Checkstyle provides standard checks in many areas including:
* Javadoc Comments
* Naming Conventions
* Headers
* Imports
* Size Violations
* Whitespace
* Modifiers
* Blocks
* Coding Problems
* Class Design
* Miscellaneous Checks
Plenty of documentation is available at http://checkstyle.sourceforge.net.
Third-party plug-ins are available for Maven, jEdit, NetBeans, Centipede, JBuilder, Eclipse/WSAD, Emacs JDE, BlueJ.
Regards,
Oliver
Weblog: http://freeroller.net/page/oburn
-
Checkstyle 3.1 Released - it's not just about layout (13 messages)
- Posted by: Oliver Burn
- Posted on: June 16 2003 07:47 EDT
Threaded Messages (13)
- Checkstyle 3.1 Released - it's not just about layout by Cameron Purdy on June 16 2003 14:32 EDT
- Checkstyle 3.1 Released - it's not just about layout by Cedric Beust on June 16 2003 15:19 EDT
- It does do that.... and more by Dion Almaer on June 16 2003 07:01 EDT
- Checkstyle 3.1 Released - it's not just about layout by Cedric Beust on June 16 2003 15:19 EDT
- Checkstyle 3.1 Released - it's not just about layout by Malcolm Edgar on June 16 2003 19:00 EDT
- Checkstyle 3.1 Released - it's not just about layout by Nick Minutello on June 16 2003 21:41 EDT
- IDEA Code Inspections by Oliver Burn on June 17 2003 12:29 EDT
- Checkstyle 3.1 Released - it's not just about layout by Nick Minutello on June 16 2003 21:41 EDT
- Keep up the good work Oliver by Brendan Humphreys on June 16 2003 19:04 EDT
- PMD? by Tim McCune on June 17 2003 00:35 EDT
- Writing plugins is easy by Simon Harris on June 17 2003 00:48 EDT
- Duplicate Code Analyser by Simon Harris on June 22 2003 23:31 EDT
- "May your bits rot in hell" by Peter den Haan on June 17 2003 04:10 EDT
- Lint? (EOM) by Vic Cekvenich on June 17 2003 07:37 EDT
- I'm sold by Gavin King on June 17 2003 10:42 EDT
-
Checkstyle 3.1 Released - it's not just about layout[ Go to top ]
- Posted by: Cameron Purdy
- Posted on: June 16 2003 14:32 EDT
- in response to Oliver Burn
The real question is: Does it give a beauty quotient? You know, the one where Cedric's code examples always score lower than mine? ;-)
Peace,
Cameron Purdy
Tangosol, Inc.
Coherence: Easily share live data across a cluster! -
Checkstyle 3.1 Released - it's not just about layout[ Go to top ]
- Posted by: Cedric Beust
- Posted on: June 16 2003 15:19 EDT
- in response to Cameron Purdy
The real question is: Does it give a beauty quotient? You know, the one where Cedric's code examples always score lower than mine? ;-)
If such a plug-in exists, I don't believe is is written in a Turing-complete language.
--
Cedric
http://beust.com/weblog -
It does do that.... and more[ Go to top ]
- Posted by: Dion Almaer
- Posted on: June 16 2003 19:01 EDT
- in response to Cedric Beust
The author just wrote to me to tell me that it does the following:
if [code belongs to cedric or cameron] {
1. laugh
2. Generate Ruby code from it (the 100 line example turns into 3)
3. laugh again
} -
Checkstyle 3.1 Released - it's not just about layout[ Go to top ]
- Posted by: Malcolm Edgar
- Posted on: June 16 2003 19:00 EDT
- in response to Oliver Burn
Great to see the development of this tool continuing. What interesting with the Checkstyle 3+ releases it the move anway from just style checking, to include more complex code analysis check. This is more akin to what you would do in a formal code review.
I think to tool is now best use with 2 different configuration's one for your daily grind style checks (best used in one of the Eclipse checkstyle plugins) and confirguration for a more comprehensive code review. -
Checkstyle 3.1 Released - it's not just about layout[ Go to top ]
- Posted by: Nick Minutello
- Posted on: June 16 2003 21:41 EDT
- in response to Malcolm Edgar
to include more complex code analysis check
Has anyone looked at the IntelliJ Code Inspection reports?
Simply amazing.
Also worthwhile noting that the checkstyle plugin in the imminent RC1 release of Maven (yay! Finally!) supports this release of checkstyle.
-Nick -
IDEA Code Inspections[ Go to top ]
- Posted by: Oliver Burn
- Posted on: June 17 2003 00:29 EDT
- in response to Nick Minutello
Yes, the Code Inspection functionality in IDEA is very impressive. Since IDEA has a "deep understanding" of the code in a project, it can produce these reports. At the moment Checkstyle focuses on checking each file seperately. this is a feature and a limitation. -
Keep up the good work Oliver[ Go to top ]
- Posted by: Brendan Humphreys
- Posted on: June 16 2003 19:04 EDT
- in response to Oliver Burn
We've been using Checkstyle on a 300K+ line codebase for over a year now. All files must pass Checkstyle before being committed to the base. I think its fair to say that its prevented many a broken window.
Cheers,
-Brendan -
PMD?[ Go to top ]
- Posted by: Tim McCune
- Posted on: June 17 2003 00:35 EDT
- in response to Oliver Burn
Anyone know how this compares to PMD? We use that and it sounds like Checkstyle does some similar stuff. One thing I really like about PMD is how easy it is to write new rules (uses XSL) and that it can also detect copy-paste code.
http://pmd.sourceforge.net -
Writing plugins is easy[ Go to top ]
- Posted by: Simon Harris
- Posted on: June 17 2003 00:48 EDT
- in response to Tim McCune
Oliver and the group have a done a fantastic job with the new architecture. It can literally take as little as a couple of hours for your first simple custom check and it just gets easier. I've recently written a whole load of them to codify "best practices" we use. It was a breeze. Makes most manual code reviews that I've been involved in seem like a joke. :-)
Checkstyle is not just for formatting anymore. It goes way beyond that.
As for duplicate code checking, watch this space. There will be something coming within days. It will be licensed similarly to clover/jcoverage so free for open source/free/non-commercial software and minimal cost per project for commercial use. Criticall it will have a checkstyle plugin. I'm just getting the download and packaging sorted out now.
Cheers,
Simon -
Duplicate Code Analyser[ Go to top ]
- Posted by: Simon Harris
- Posted on: June 22 2003 23:31 EDT
- in response to Tim McCune
As requested, here is a link to Simian http://www.redhillconsulting.com.au/products/simian
It has a plugin for checkstyle (as well as ant and command line interface).
Cheers,
Simon -
"May your bits rot in hell"[ Go to top ]
- Posted by: Peter den Haan
- Posted on: June 17 2003 04:10 EDT
- in response to Oliver Burn
We first started to use checkstyle over a year ago on a pretty high profile project, integrated into a continuous integration set-up so that we'd all get an hourly e-mail listing everyone's sins in painful detail :) Despite the fact that the half the team consisted of contractors, the end result was some of the best-commented, most consistent and, yes, bug free code we've ever produced.
It wasn't a hit with everyone, though. One of the contractors' last commit message was (approximately) "Goodbye checkstyle. I shall not miss you. May your bits rot in hell."
Needless to say, I love checkstyle, and we've been using it ever since. I'm looking forward to using the new release.
- Peter -
Lint? (EOM)[ Go to top ]
- Posted by: Vic Cekvenich
- Posted on: June 17 2003 07:37 EDT
- in response to Peter den Haan
Lint?
(EOM)
.V -
I'm sold[ Go to top ]
- Posted by: Gavin King
- Posted on: June 17 2003 10:42 EDT
- in response to Oliver Burn
I added checkstyle 3.1 to the Hibernate core (approx 46k LOC) Ant build two days ago. I'm very impressed, especially in comparison to code formatters.
I did notice that the array [] position checker has a bug which causes checkstyle to NPE on a couple of classes. But I can live without that check ;)