Friday, February 27, 2015

Getting Started with SonarQube

What is SonarQube?
SonarQube is an open platform to manage code quality. It covers following aspects of a project
  1. Architecture and Design
  2. Duplication
  3. Unit Testing
  4. Complexity
  5. Potential Bugs
  6. Coding Rules
  7. Comments
There are about 20 plugins available for SonarCube to analyze most of the common programming languages such as Java, C#, C++ etc..

Analyzing a Project with SonarQube Runner
Prerequisites
  • Java should be installed on your machine
First go to the SonarQube official site and download the SonarQube and SonarQube Runner
Extract both SonarQube and SonarQube runner to desired locations. In my machine I've extracted SonarQube to 
/home/thusitha/Training/sonarqube-5.0
and SonarQube Runner to
/home/thusitha/Training/sonar-runner-2.4

Inside the SonarQube you can find there are many directories for each platform. Find the matching platform based on your OS. 
e.g.
If you are using ubuntu x64 bit OS then you must go to linux-x86-64 directoty

Go to the particular directory through the console and run the Sonar script to start the Sonar sever
To start the server run the sonar script in the directory
In Linux
sh sonar.sh console

In Windows
StartSonar.bat

Then open your browser and type following URL there. If Sonar server started successfully you will direct to Sonar dashboard.
Sonar Dashboard http://localhost:9000/

Now go to the project root folder that you want to analyze and create a file and name it as 
sonar-project.properties and have following content to that file In the file you can provide details relate to your project.
Then we can run SonarQube Runner to analyze the project using this file. To do that run the following command from the location where the created file resides.
On Linux
sonar-runner

On Windows
sonar-runner.bat


After a successful execution you can see the project and its' status on the Sonar Dashboard. In the dashboard you can go through the issues etc...

No comments:

Post a Comment