How To - SonarQube

SonarQube.png

SonarQube

Static Code Scanner & Analyzer for multiple languages

Website: sonarqube.org

SonarQube Documentation: docs.sonarqube.org/latest

Install SonarQube Launcher

brew install sonar-scanner

Verify Installed Sonar Scanner Version

sonar-scanner --version

Sonar Scanner Help

sonar-scanner --help

Start SonarQube Reporter as a Container

docker run -d --name sonarqube -p 9000:9000 sonarqube

Analyzing a Project Code

Once your instance is up and running, Log in to localhost:9000 using System Administrator credentials:

login: admin

password: admin

open -a "Google Chrome" http://localhost:9000

Screen Shot 2021-01-06 at 12.40.32 AM.png

  • Click the Create new project button.

Screen Shot 2021-01-06 at 12.41.12 AM.png

  • Give project a Project key and a Display name and click the Set Up button.

Screen Shot 2021-01-06 at 12.41.42 AM.png

  • Under Provide a token, select Generate a token. Give token a name, click the Generate button, and click Continue.

Screen Shot 2021-01-06 at 12.42.09 AM.png

  • Execute Sonar Scanner on project code using below command, replace "key name" with the key set in previous step and replace "token" with generated token value.
sonar-scanner -Dsonar.projectKey=<key name> -Dsonar.sources=. -Dsonar.host.url=http://localhost:9000 -Dsonar.login=<token>
  • Now you can view the code quality report in the browser

Did you find this article valuable?

Support Ashutosh Kumar Sinha by becoming a sponsor. Any amount is appreciated!