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:
- Step1: Download the updated sonarqube scanner software: https://docs.sonarqube.org/display/SCAN/Analyzing+with+SonarQube+Scanner.
- Step2: Set the Sonarqube Scanner path in system variables in environment variables.
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.
After run the StartSonar.bat file sonarqube is running up
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
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
Code smells, Bugs, Duplication's, Code Coverage
google 954
ReplyDeletegoogle 955
google 956
google 957
google 958