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.
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.