- install jdk12 or above
- add
JAVA_HOME
variable path to environment variables with value C:\Program Files\Java\jdk-<version-number>\
- download sonarqube community edition from
https://www.sonarqube.org/downloads/
- extract zip folder and run the
StartSonar.bat
from sonarqube\bin\windows-x86–64
- navigate to
http://localhost:9000
to see sonar dashboard.
- navigate to angular project and create
sonar-project.properties
file
- add below content to analyze sonar results in local machine:
sonar.projectKey=<your-project-key>
sonar.projectName=<your-project-name>
sonar.sourceEncoding=UTF-8
sonar.sources=src
sonar.host.url=http://localhost:9000
sonar.login=admin
sonar.password=admin
sonar.typescript.lcov.reportPaths=build/coverage/lcov.info
sonar.exclusions=**/node_modules/**,**/*.spec.ts, **/*.test.ts
sonar.inclusions = **/*.component.ts, **/*.service.ts, **/*.component.html, **/*.pipe.ts
sonar.tests=src
sonar.test.inclusions=**/*.spec.ts
sonar.ts.tslintconfigpath=tslint.json
sonar.testExecutionReportPaths=test-report.xml
- run
npm i -D sonarqube-scanner jest-sonar-reporter
- add script
"sonar": "sonar-scanner"
to scripts
in package.json
- to
jest.config.js
add "testResultsProcessor": "jest-sonar-reporter"
- run
npm run sonar
and wait for completion.
- navigate to
http://localhost:9000/dashboard?id=<your-project-key-in-sonar-properties-file>