SonarQube&SonarScanner for beginners

What is sonarqube ?

SonarQube is an open source platform developed by SonarSource for continuous inspection of code quality to perform automatic reviews with static analysis of code to detect bugs, code smells, and security vulnerabilities on 20+ programming languages.

Installation:

  • Step1: Download the updated sonarqube software: https://www.sonarqube.org/downloads/
  • Step2: Extract the zip folder and go to bin folder and run the StartSonar.bat file.
  • Step3: Before running the StartSonar.bat file set the path of the sonar in system environment variables.
  • Step4: By Default, sonarqube is running on http:localhost:9000
  • Step5: If you want to change the port, Go to the Conf folder change the port in sonar.properties file.
  • Step6: hit the http://localhost:9000sonarqube dashboard will open enter the username as admin and password as admin.

What is sonarqube scanner?

Sonarqube Sanner is basically used for project scanning using the sonarproject.properties file.

Installation:
What is SonarProject.properties?

It's basic information about your project (language, source files, binary files, utf conversion, libraries).

Below is the basic sonarproject.properties file.
sonar.projectName=Janardhan Randhi (your project name)
sonar.projectKey=Migration (Enter you desired key)
sonar.language=java (used language in your project)
sonar.sources=src (source files)
sonar.java.binaries=ImportedClasses (complied classes)
sonar.sourceEncoding=UTF-8 (character encoding )
sonar.projectVersion=1.0 (version of your project)
sonar.java.coveragePlugin=jacoco (For Code coverage ,unit test cases must and should )
How to apply the sonarqube integration for the web application?
  • Step1: Place the sonarproject.properties file in your project root folder.
  • Step2: Start the sonarqube .
  • Step3: Go to project location and open the command prompt run the below command -sonar-scanner
  • Step4: Your project is analyzing with predefined rules provided by sonarqube.
  • Step5: After analyzing the project dashboard will appear with bugs, code smells and duplications.

Applying SonarQube integration to the Sample application.

Step1: Start the sonarQube.

Applying SonarQube integration to the Sample application.
After run the StartSonar.bat file sonarqube is running up

Applying SonarQube integration to the Sample application.

Step2: hit the sonarqube URL: http://localhost:9000


Step3: Enter the username as admin and password as admin.

After successfully login dashboard should be like this.


Step4: Place the sonar-project.properties file in your application root folder.
With Sonar-project.properties file.


Sonar-project.propertie file.
Step5: Go to the project folder open the command prompt and type the below command.
sonar-scanner


After Analyzing the project source files compiler will show build success.

After successful build application data will process into the sonarque dashboard.

Code smells, Bugs, Duplication's, Code Coverage


SUBSCRIBE TO OUR NEWSLETTER

I’m the Founder of quickdevops.com. I am a Professional Blogger, Application developer, YouTuber. I’ve been blogging since 2015.I spend a lot of time learning new techniques and actively help other people learn web development through a variety of help groups and writing web development tutorials for my website and blog about advancements in web design and development.Besides programming I love spending time with friends and family and can often be found together going out catching the latest movie or planning a trip to someplace I've never been before.

1 Response to "SonarQube&SonarScanner for beginners"