Hey there.
Seeing such a large number of bugs and vulnerabilities while receiving a passing Quality Gate might be initially confusing, but everything is actually functioning as designed! This scenario is a common experience when performing a first analysis on an existing codebase.
To clarify, when you run an initial scan on your codebase, SonarQube uncovers and reports on all the existing issues - hence the thousands of issues youâre seeing. Now, you might ask, âShould we fix all these issues?â
Well, you could, but fixing all of them immediately isnât necessarily the best strategy. Attending to each one would take a significant amount of time and resources, especially considering that much of this code may have been untouched for a long time and is potentially functioning well despite the identified issues. Dedicating resources to correct these issues could divert your teamâs attention from more pressing tasks, such as developing new features or enhancing existing ones.
This is where the concept of âClean As You Codeâ comes into play. SonarQube promotes this approach, which primarily focuses on maintaining high quality in the new code thatâs being written. This doesnât mean you should completely ignore existing issues, but it prioritizes dealing with issues in the code thatâs currently being worked on and modified.
As the name suggests, âClean As You Codeâ encourages developers to take ownership and ensure the cleanliness of their new code, making sure any new work is free from issues As you continue developing and modifying your codebase, sections of the older, existing code will naturally get touched, refactored, and cleaned. In this way, âNew Codeâ can also encompass updated old code.
So, in the face of thousands of identified issues, donât panic. Your Quality Gate is passing because the new code youâve written meets the quality standards. SonarQube is doing its job, helping you focus on maintaining and improving code quality incrementally, rather than getting overwhelmed by the prospect of fixing all the existing issues at once.
As you add code to your codebase and continue to scan your code, youâll see better the separation between âNew Codeâ and âOverall Codeâ.
I hope this helps explain the situation better.