Even if we know everything about code quality, the human error factor will still persist. There is always a chance of making some error, as we are human after all.

Some, if not all such errors can be brought to notice using some quality management tool. There are several such tools/plugin which can be integrated into eclipse. All such tools can assist a developer with a code review, just like a peer code review. e.g.

  1. PMD
  2. Findbugs
  3. Java Analyzer
  4. HammurAPI

To know more read this..



Taking a big leap forward in learning code quality. I researched a bit and found about sonar. This is a standalone service which acts as a source quality management analyzer. Instead of being a single tool for code quality analysis. It has various components integrated in it. For details on sonar which is hosted at ‘codehaus’ visit
sonar’s offcial website.

Setting up sonar to analyze maven projects.


  1. Download sonar from here. (I downloaded v3.4)
  2. Extract it to some folder.
  3. Open ‘sonar.properties’ situated in /conf folder and update the following properties –
    – sonar.web.host: // default host
    – sonar.web.port: 9000 // default port where you can access sonar interface using a browser
    – sonar.web.context: /
    – sonar.jdbc.username: sonar // the admin username
    – sonar.jdbc.password: sonar // the admin password
  4. By default the sonar service uses an in memory db H2. Default port is 9092 with URL ‘jdbc:h2:tcp://localhost:9092/sonar’.
    However, a custom db should be used when using professionally for obvious reasons. One the following db can be used-
    –  MySQL
    – Oracle
    – PostgreSQL
    – MSSQLPlease note that for educational purposes, you may conveniently skip Step 4.
  5. Now, you’ll have to run the standalone service situated in bin folder.
    e.g.  if using windows (64bit) just run StartSonar.bat situated in binwindows-x86-64.
  6. To view the interface, open http://localhost:9000 in a browser.
  7. I’m sure you loved what you saw.
  8. Lets start analyzing
    Now, to hit the nail on the head, simple run mvn sonar:sonar to analyze the code.
  9. Once you’ve run the analysis, view the results @ http://localhost:9000.

Voila, now you know a lot more about the code you’ve run the analysis for.

Hudson Integration

For those who are familiar with hudson and jenkins, just go ahead and integrate sonar into your hudson. You simply have to follow the given steps-

  1. Install sonar plugin into hudson.
  2. Restart hudson.
  3. In manage hudson/jenkins page, you’ll find a sonar section. Add provide your sonar setup info.
  4. To configure a sonar step in your jobs, add a post-build action to jobs. ‘Stand Alone Sonar’.
  5. And its done. 🙂