Let's say you have configured a build job in Jenkins to implement CI and you are performing code scan using SonarQube. Code scan results shown some defects(bugs) in your Java Code.
If you look at Jenkins console output, you can see analysis was successful.
If you look at SonarQube project dashboard, you are seeing defects like shown below. How do fix those defects? Let's see the steps to fix those defects.
Pre-requisites:
- Sonarqube is setup and running
- Jenkins is up and running
- Java WebApp setup in GitHub
- build job configured in Jenkins to perform code scan
Now login to SonarQube
Click on Project name MyWebApp
Click on Overall code, click on 3 Bugs
Click on Why this an issue to learn more about the issue and how you can fix it.
Now code to GitHub where Java WebApp is configured, edit the index.jsp under MyWebApp/src/main/webappFix for bug # 3
<head> <title>My WebApp</title> <meta content="text/html; charset=utf-8" /> </head>
run the build in Jenkins by clicking on Build now.
Login to SonarQube, now you will see no bugs.
This is how you can fix defects found by SonarQube.
No comments:
Post a Comment