SonarQube - onwardpath/demo-repo GitHub Wiki
What is Sonarqube?
Sonarqube is a continuous inspection of code quality to perform automatic reviews with static analysis of code.it will detect bugs, code smells (bad code), offer duplicated code, coding standard and security vulnerabilities in our source code.
It is open source platform which will be used more than 20+ programming languages.
Install Sonarqube:
- Download sonarqube from the below URL. https://www.sonarqube.org/downloads/
- After downloaded, you will get the zip file, unzip the sonarqube file and place in the respected directory where we want to have sonarqube installation.
- Now Start the server by clicking StartSonar.bat under SONARINSTALLDIRECTORY/bin/windows-x86-64 Note: Sonarqube 8 require Java 11 version. So make sure you are using java 11 to run the sonaqube8 version.
- Once the sonarqube get started in the console. You can check the below URL to verify in user interface. Default URL: http://localhost:9000/
- Default username/password: admin/admin
Configure Sonarqube in maven project:
- Go to the Eclipse Maven project and open the pom.xml for the project. In the pom.xml add the below profile into it.
Note: Change sonar.host.url value to your server address or keep localhost
- Now run the maven project using the below maven command. Command to execute: mvn clean verify sonar:sonar => In some situations you may want to run the sonar:sonar goal as a dedicated step. Be sure to use install as first step for multi-module projects Now command to execute as: mvn clean install mvn sonar:sonar
- Once build successful we should be able to see the below output in console.
Run the highlighted URL to verify the analysis for our code.
4.In the generated URL,report will be displayed in the below format.