Monday, May 26, 2008

Checkstyle

Checkstyle is a development tool to help programmers write Java code that adheres to a coding standard. It automates the process of checking Java code to spare humans of this boring (but important) task. This makes it ideal for projects that want to enforce a coding standard.

Checkstyle is highly configurable and can be made to support almost any coding standard. An example configuration file is supplied supporting the Sun Code Conventions. As well, other sample configuration files are supplied for other well known conventions.

Checkstyle can check many aspects of your source code. Historically it's main functionality has been to check code layout issues, but since the internal architecture was changed in version 3, more and more checks for other purposes have been added. Now Checkstyle provides checks that find class design problems, duplicate code, or bug patterns like double checked locking.

The latest release of Checkstyle can be downloaded from the SourceForge download page.

If you want to live on the bleeding edge, you can checkout the current development code from Subversion and compile yourself.

PMD

PMD scans Java source code and looks for potential problems like:

  • Possible bugs - empty try/catch/finally/switch statements
  • Dead code - unused local variables, parameters and private methods
  • Suboptimal code - wasteful String/StringBuffer usage
  • Overcomplicated expressions - unnecessary if statements, for loops that could be while loops
  • Duplicate code - copied/pasted code means copied/pasted bugs
PMD is integrated with JDeveloper, Eclipse, JEdit, JBuilder, BlueJ, CodeGuide, NetBeans/Sun Java Studio Enterprise/Creator, IntelliJ IDEA, TextPad, Maven, Ant, Gel, JCreator, and Emacs.

You can download everything from here, and you can get an overview of all the rules at the rulesets index page.

Recent releases


  • 2008-05-20 PMD 4.2.2: more bug fixes on the 4.2 branch (Changelog)
  • 2008-04-11 PMD 4.2.1: bug fixes (Changelog)

Future releases

The refactoring effort that will lead to PMD 5.0 has been started on the main trunk (5.0 will not be backward compatible with PMD 4.x). We may release other 4.2.x versions with minor fixes if needed until 5.0 is released.

Doc Check

The Sun Doc Check Doclet is an extension to the Javadoc tool It runs on source code and reviews documentation comments, generating an HTML report that identifies empty comments and other ommissions and irregularities in the documentation comments. The report displays the number of doc errors, categorizes problems according to severity, and suggests text to include. It can be instructed to ignore packages and classes using wildcard patterns. An included utility package contains functionality that scans a directory tree to generate a list of packages, as well as pattern-matching classes for filenames.

Support Note - DocCheck is experimental code developed originally for internal use at Sun and released to the developer community for use as-is. It is not a supported product. Use at your own risk. While we have worked to make it useful, bugs might not be fixed and features might not be added. It might not be updated, or might be re-released with a different implementation or options or page design that is incompatible with the current design.