setting up sonarqube

This post will help you to setup a sonarqube project to scan your source code. Follow these steps.

Dependency with JDK Make sure, JDK is downloaded and installed.

  1. Download sonarqube
  2. Unzip – let’s say in “C:\sonarqube” or “/etc/sonarqube”, the SonarQube distribution once it’s downloaded.
  3. Start the SonarQube server:

  1. Download sonarqube scanner
  2. Unzip – let’s say in “C:\sonarscanner” or “/etc/sonarscanner”. Let’s call it as <install_directory>
  3. Update the global settings to point to your SonarQube server by editing <install_directory>/conf/sonar-scanner.properties:

  1. Add the <install_directory>/bin directory to your path.
  2. You can verify your installation by opening a new shell and executing the command sonar-scanner -h (on Windows platform the command is sonar-scanner.bat -h) . You should get output like this:

  1. Create a configuration file in the root directory of the project. Name of the properties file must be sonar-project.properties
  2. Format of sonar-project.properties file is as given below

Run the following command from the project base directory to launch the analysis:

The end result will be something like shown below.

sonar configuration parameters can be found here

Shown above is the result of sonar scanner of our project. It looks awesome, Isn’t it?