:::: MENU ::::

SonarQube

Installation

Go to https://www.sonarqube.org/#downloads and select LTS Release. Download it and unzip it in c:\.

Start of the server

Start Sonar with C:\sonarqube-6.7.1\bin\windows-x86-64\StartSonar.bat. Enter http://localhost:9000 with admin/admin to check it’s working properly.

Java Maven project example

Here we will use a simple Java project with one class.

Main.java

package com.luisgomezcaballero.sonar_demo;

public class Main {

	public static void main(String[] args) {

		String parameter = "User";

		if (parameter.equals("admin")) {
			System.out.println("Admin user.");
		} else {
			System.out.println("Normal user.");
		}

	}

}

Java Maven project analysis

In SonarQube, create a new Token (myToken) to use it with a new Maven Java project.
Go to C:\Users\GL553V\eclipse-workspace\sonar-demo (or the URI of your project) and execute the command:

C:\apache-maven-3.5.2\bin\mvn sonar:sonar -Dsonar.host.url=http://localhost:9000 -Dsonar.login=232c62b023374a6717020f11a3ced931a1e7fed2.

Once the build is finished, go to http://localhost:9000/projects. Click on sonar-demo and on code smells para to review the results.

Repository

This example project to demonstrate SonarQube can be located at https://github.com/luisgomezcaballero/sonar-demo.


So, what do you think ?