I want sonar analysis on newly checkin code

in my project we have nearly 100 bugs are there, but project team is asking they dont want to analyse previously existed code, they want sonar analysis on newly chekin code. how can i do that

  • i am using sonar project properties file with sonar scanner.


There are a couple things to be said here.

First, the SonarQube interface and default Quality Gate are designed to help you focus on the New Code Period. You can’t keep analysis from picking up those old issues, but you can decide to only pay attention to issues raised on newly-changed code. That means you would essentially ignore the issues on the left side of the project homepage with a white background and focus instead on the New Code values over the yellow background on the right. We call this Fixing the Leak, or alternately Clean as You Code.

Second, if you have a commercial edition, then branch and PR analysis are available to you. With Short-Lived Branch (SLB) and PR analysis still covers all files, but all that’s reported in the UI is what’s changed in the PR / SLB.

Ideally, you’ll combine both of these things to make sure your new code stays clean.