Quality analysis using Sonarqube®

Introduction

Sonarqube® is a code quality analyser. It is available here.

This document make the assumption Sonarqube® is installed and operational with the Java, JavaScript, CSS and HTML code plugins. The easiest way to start a Sonarqube® server is to use the official Sonarqube® Docker image.

This document only applies if you export your Simplicité® modules as Git repositories. See this document for details.

In the rest of the document <sonar options> corresponds to the options you use with your Sonarqube® installation and/or your repositories. For instance it can be the server's custom URL and its credential: -Dsonar.host.url=http://localhsot:9191 [-Dsonar.login=<login> -Dsonar.password=<password>]. These common options can also be stored in environment variables and , see bellow.

Modules using Java

In this case the Simplicité® module is considered as a Java module by Sonarqube®. As of Version 4.0.P22 this is straightforward as the Git repository of the Simplicité module is structured as an Apache Maven® project which is directly managed by Sonarqube®.

Prerequisites

You need to have Apache Maven® installed.

Usage

After cloning/pulling your module's Git repository you can launch the analysis by:

mvn clean compile sonar:sonar [<sonar options>]

The common options <sonar options> can be stored in the MAVEN_OPTS environment variable. The other options (exclusions, ...) are generated by the Git export in the pom.xml file's <properties> section.

Note: if you module contains client-side JavaScript and CSS/LESS stylesheets they will also be analysed.

Modules using Rhino scripting

In this case the Simplicité® module is considered as a JavaScript module by Sonarqube®. You need some additionals components (see bellow).

Prerequisite

You need to have Node.js installed, then you need to install the Sonarqube scanner additional NPM module:

sudo su -
npm install -g sonarqube-scanner
exit

Usage

After cloning/pulling your module's Git repository you can launch the analysis by:

sonar-scanner [<sonar options>]

The common options <sonar options> can be stored in the SONAR_SCANNER_OPTS environment variable. The other options (exclusions, ...) are generated by the Git export in the sonar-project.properties file.

Note: if you module contains also client-side JavaScript and CSS/LESS stylesheets they will also be analysed.