sonarqube-scanner
makes it very easy to trigger SonarQube
analyses on a JavaScript code base, without needing to install any specific tool
or (Java) runtime.
This module is analyzed on SonarCloud using itself:
- See the Gulp file
- See the analysis results on SonarCloud
This package is available on npm as: sonarqube-scanner
npm install sonarqube-scanner
The following example shows how to run a SonarQube analysis on a JavaScript project using Gulp, and pushing the results to SonarCloud, the online SonarQube service:
var gulp = require('gulp');
var sonarqubeScanner = require('sonarqube-scanner');
gulp.task('default', function(callback) {
sonarqubeScanner({
serverUrl : "https://sonarcloud.io",
token : "019d1e2e04eefdcd0caee1468f39a45e69d33d3f",
options : {}
}, callback);
});
Syntax: sonarqube-scanner ( parameters
, [callback
] )
parameters
MapserverUrl
String (optional) The URL of the SonarQube server. Defaults to http://localhost:9000token
String (optional) The token used to connect to the SonarQube server. Empty by default.options
Map (optional) Used to pass extra parameters for the SonarQube analysis. See the official documentation for more details.
callback
Function (optional) Callback (the execution of the analysis is asynchronous).
I constantly get "Impossible to download and extract binary [...] In such situation, the best solution is to install the standard SonarQube Scanner", what can I do?
You can install manually the standard SonarQube Scanner, which requires to have a Java Runtime Environment available too (Java 8+). Once this is done, you can replace the 2nd line of the example by:
var sonarqubeScanner = require('sonarqube-scanner').customScanner;
sonarqube-scanner
is licensed under the LGPL v3 License.