Gathering detailed insights and metrics for @etnetera/sonarqube-scanner
Gathering detailed insights and metrics for @etnetera/sonarqube-scanner
Gathering detailed insights and metrics for @etnetera/sonarqube-scanner
Gathering detailed insights and metrics for @etnetera/sonarqube-scanner
SonarQube Scanner for the JavaScript world
npm install @etnetera/sonarqube-scanner
53.2
Supply Chain
97.5
Quality
73.4
Maintenance
100
Vulnerability
79.3
License
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
184 Commits
4 Branches
1 Contributors
Updated on 24 Nov 2021
JavaScript (100%)
Cumulative downloads
Total Downloads
Last day
-6.7%
14
Compared to previous day
Last week
-25.6%
29
Compared to previous week
Last month
-7.6%
134
Compared to previous month
Last year
179.6%
2,142
Compared to previous year
sonarqube-scanner
makes it very easy to trigger SonarQube
/ SonarCloud analyses on a JavaScript code base, without needing
to install any specific tool or (Java) runtime.
This module is analyzed on SonarCloud.
This package is available on npm as: sonarqube-scanner
To add code analysis to your build files, simply add the package to your project dev dependencies:
1npm install -D sonarqube-scanner
To install the scanner globally and be able to run analyses on the command line:
1npm install -g sonarqube-scanner
Prerequisite: you've installed the package as a dev dependency.
The following example shows how to run an analysis on a JavaScript project, and pushing the results to a SonarQube instance:
1const scanner = require('sonarqube-scanner'); 2 3scanner( 4 { 5 serverUrl : 'https://sonarqube.mycompany.com', 6 token : "019d1e2e04eefdcd0caee1468f39a45e69d33d3f", 7 options: { 8 'sonar.projectName': 'My App', 9 'sonar.projectDescription': 'Description for "My App" project...', 10 'sonar.sources': 'src', 11 'sonar.tests': 'specs' 12 } 13 }, 14 () => process.exit() 15)
Syntax: sonarqube-scanner ( parameters
, [callback
] )
Arguments
parameters
Map
serverUrl
String (optional) The URL of the SonarQube server. Defaults to http://localhost:9000token
String (optional) The token used to connect to the SonarQube/SonarCloud server. Empty by default.options
Map (optional) Used to pass extra parameters for the analysis. See the official documentation for more details.callback
Function (optional)
Callback (the execution of the analysis is asynchronous).Prerequisite: you've installed the package globally.
If you want to run an analysis without having to configure anything in the first place, simply run the sonar-scanner
command. The following
example assumes that you have installed SonarQube locally:
cd my-project
sonar-scanner
Specifying properties/settings
package.json
file in the folder, it will be read to feed the analysis with basic information (like project name or version)sonar-project.properties
file in the folder, it will behave like the original SonarScanner-Dsonar.xxx=yyy
syntax
Example:
sonar-scanner -Dsonar.host.url=https://myserver.com -Dsonar.login=019d1e2e04e
You can install manually the standard SonarScanner, 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:
1var scanner = require('sonarqube-scanner').customScanner;
You are probably relying on Alpine for your Docker image, and Alpine does not include glibc by default. It needs to be installed manually.
Thanks to Philipp Eschenbach for troubleshooting this on issue #59.
By default, the scanner binaries are downloaded from https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/
.
To use a custom mirror, set $SONAR_SCANNER_MIRROR
. Or download precise version with $SONAR_SCANNER_VERSION
Example:
1export SONAR_SCANNER_MIRROR=https://npm.taobao.org/mirrors/sonar-scanner/ 2export SONAR_SCANNER_VERSION=3.2.0.1227
or alternatively set variable in .npmrc
sonar_scanner_mirror=https://npm.taobao.org/mirrors/sonar-scanner/
sonar_scanner_version=3.2.0.1227
By default, the scanner binaries are cached into $HOME/.sonar/native-sonar-scanner
folder.
To use a custom cache fodler instead of $HOME
, set $SONAR_BINARY_CACHE
.
Example:
1export SONAR_BINARY_CACHE=/Users/myaccount/cache
or alternatively set variable in .npmrc
sonar_binary_cache=/Users/myaccount/cache
By default, the scanner tries to get the target OS from process.platform
. You can override this by specifying the environment variable SONAR_SCANNER_TARGET_OS
. Possible values are 'windows', 'linux', 'macosx', 'universal'
(specifying universal
will download the binary without any OS suffix).
Example:
1export SONAR_SCANNER_TARGET_OS=universal
By default, the scanner tries to download the binaries or use the cached binaries (after downloading). If you want to have complete control of the binaries (version, location on file system, ...), you can download it yourself and then use the environment variable SONAR_SCANNER_BIN
to specify the path to the binaries.
Example:
1export SONAR_SCANNER_BIN=/home/foo/sonar-scanner/bin/sonar-scanner
sonarqube-scanner
is licensed under the LGPL v3 License.
No vulnerabilities found.
No security vulnerabilities found.