Step 1: Install SonarQube
For installing SonarQube first download the Sonarqube from https://www.sonarqube.org/downloads/
The latest version of sonarqube requires JDK 11.0 & above. Download & install JDK
Extract the zip
Start the SonarQube Server:
On Windows, execute:
C:\sonarqube\bin\windows-x86-xx\StartSonar.bat
On other operating systems, as a non-root user execute:
/opt/sonarqube/bin/[OS]/sonar.sh console
eg: On My Mac I execute below command
/usr/local/opt/sonarqube/bin/macosx-universal-64/sonar.sh console
Step 2: Configuring SonarQube for your project
npm install sonar-scanner --save-dev
After successful install of the dependency, create a file named
sonar-project.properties
Open the file & add following
sonar.host.url=http://localhost:9000
sonar.login=admin
sonar.password=admin
sonar.projectKey=app-name
sonar.projectName=app-name
sonar.projectVersion=1.0
sonar.sourceEncoding=UTF-8
sonar.sources=src
sonar.exclusions=/node_modules/
sonar.tests=src
sonar.test.inclusions=*/.spec.ts
sonar.typescript.lcov.reportPaths=coverage/lcov.info
Open package.json & add below line in the scripts property
"sonar":"sonar-scanner"
Step 3 : SonarQube console
In the terminal type: npm run sonar to execute sonar for the selected project.
Open browser & type url http://localhost:9000.
Use the default credentials i.e admin and admin as the Login name and password respectively.
Check the issues tab for Sonar Issues
Top comments (0)