Sharing Our Passion For Technology
& continuous learning
〈  Back to Blog

Sonar - Code Quality Analysis Tool

By Sanjay Shrestha | February 09, 2010 | Testing

What is Sonar?

Sonar is a web based code quality analysis tool for Maven based Java projects. It covers a wide area of code quality check points which include: Architecture & Design, Complexity, Duplications, Coding Rules, Potential Bugs, Unit Test etc. Sonar has a rich set of features like what you would get with different tools such as Covertura, PMD, FindBugs, Check Styles combined.

http://sonar.codehaus.org/

Setting up Sonar

  • Download the latest release of Sonar from http://sonar.codehaus.org/downloads/.
  • Unzip it to a folder, e.g. C:\Sonar
  • Run C:\Sonar\bin\windows-x86-32\StartSonar.bat for Windows. There are several options available for other operating system such as Linux, Solaris.
  • Browse to http://localhost:9000 . The browser will display a "No projects have been analyzed" message. This is a sanity check to see if Sonar is running properly.
  • From within your project, run the following maven command: mvn clean install sonar:sonar
  • Refresh the browser. The code quality related reports such as Complexity, Duplication, Violation, Rules of Compliance etc will be displayed.
  • To customize the features using the admin console, login/password isĀ admin/admin.
〈  Back to Blog