Must-share information (formatted with Markdown):
Sonarqube - 9.9
Plugin - org.sonarsource.scanner.maven:sonar-maven-plugin:3.9.1.2184:sonar
We have setup the main branch as develop
on Sonar and our development involves creating a feature branch out of the develop
branch and then merging it into develop
after development and testing.
For our develop
branch there are a lot of Code smells, bugs, vulnerabilities that are currently in Old Code section (probably marked as not fixable), and now whenever a new feature branch is merged to develop, Sonar runs on the entire develop branch and only shows the new Code smells, bugs, etc that got introduced in the current PR, causing the quality gate to fail. Then we fix the issue and merge it again to develop thus solving the smell, bug, etc whatever came.
Is it possible to do this on the feature branch itself, basically run the Sonar scan on the entire feature branch but only show the code smells, bugs, etc. that are not there on the latest Scan of develop branch, essentially show me the diff in smells, bugs, etc.
For eg.
Let us say the latest code of my develop
(main branch) has 0 bugs, smells in the New Code section but the Old Code section has 100 smells. Then when I run the Sonar scan on my feature env branch and introduce 1 new smell, then it shows me 1 new smell as the diff and not the absolute 101 smells.
Edit.
I did the above using
-Dsonar.branch.name=$CI_MERGE_REQUEST_SOURCE_BRANCH_NAME -Dsonar.newCode.referenceBranch=develop
When I ran the above for first time, it showed me 1 new smell, which is what I wanted.
Then I added another commit to my feature branch in which I introduced 1 new smell, now I ran the Sonar scanner again, this time it showed me 1 new smell (new one which I introduced in second commit), whereas ideally it should have shown me 2 new smells compared to develop. How can I solve this particular problem?