RSS Feed for This PostCurrent Article

Java: Ensure Code Quality with Open Source Tools

There are many tools available for Java to check and ensure different aspects of your code, e.g. code coverage, coding standard, duplicate code, etc.

However, each of these tools, e.g. FindBugs, PMD, Simian, JavaNCSS, Cobertura, etc are only checking certain aspects of your code.

Below are some open source tools that integrate all these tools together to give you a unified view on different aspects of your code.


QA Tools like checkstyle, pmd, pmd-cpd, findbugs, cobertura (cobertura-branch and cobertura-line) and simian are great build tools but they only take a snapshot of the state of your project. You do not get a sense of the trend of your project.

QALab collects and consolidates data from several QA tools and keeps track of them overtime. This allows developers, architects and project managers alike to be presented with a trend of the QA statistics of their project.

The following tools are currently supported:

  • Checkstyle: code style validation and design checks. QALab keeps track of number of violations per file and overall.
  • PMD: Code checks (possible bugs, dead code, sub-optimal code, etc). QALab keeps track of number of violations per file and overall.
  • PMD CPD: Duplicate code (always a bad idea) detection. QALab keeps track of number of the overall number of duplicated lines.
  • FindBugs: fantastic tool to detect potential bugs (really!). QALab keeps track of number of violations per file and overall.
  • Cobertura: Coverage tool. QALab keeps track of percentage of branch and line coverage.
  • Simian: excellent duplicate code detection (non-open source). QALab keeps track of number of the overall number of duplicated lines.

QALab can be used via ant or Maven. There are three main steps to using QALab:

  1. Collect Data from QA Tools into a generic qalab.xml format. This is a necessary step to consolidate data. Refer to the documentation from Checkstyle, PMD, PMD CPD (Copy Paste Detector), FindBugs, Cobertura and Simian in order to generate the xml reports.
  2. Generate Charts from qalab.xml for each file; these will show the trends over time for each file and the overall project.
  3. Generate a summary xml and html pages with the files that have seen a change in their QA statistics over the last n days. This is particularly useful for developers who can see the impact of the latest code checked in.


SONAR is a code quality management platform, dedicated to continuously analyze and measure technical quality, from the projects portfolio to the class method.

It leverages well-known tools such as Checkstyle, PMD, Findbugs, Cobertura, Clover and JavaNCSS to provide an integrated and easy to use quality management platform.


Panotipcode is a project dedicated to making code metrics so widely understood, valuable, and simple that their use becomes ubiquitous, thus raising the quality of software across the industry. It provides a set of open source tools for gathering, correlating, and displaying code metrics.

It packages

  • Emma – Unit test code coverage. By changing one line in your build file this can be switched to Cobertura.
  • CheckStyle – Validates that your code follows Sun’s standards for Java. If you want to use a different set of rules you only need to change one parameter in your build file.
  • JDepend – Sophisticated OO quality metrics and package dependency checking.
  • JavaNCSS – Cyclomatic Complexity and size (NCSS) metrics.
  • Volatility – Measure change within your projects. Currently this only works with Subversion, but support for other SCM repositories is planned.
  • Duplicate Code – Using Simian.
  • Panopticode Aggregator – Generates an XML file that integrates ALL of the information gathered above
  • Panopticode Reports
    • Powerful visualizations, such as TreeMaps, that allow you to see the overall picture and an amazing amount of detail in a single view.
    • Metric Correlation
    • Historic Data

Trackback URL

Sorry, comments for this entry are closed at this time.