What is the exact definition of "New code" based on "reference branch"?

What is the exact definition of “New code” based on “reference branch” ?

If current branch is based on “reference branch”, is the New code from start of current branch to end of current branch ?

Or is the HEAD of the current branch compared to the HEAD of “reference branch” ? So the start of current branch is only the reference in case of “fast-forward”, but when features get merged on the “reference branch”, they become the new reference for “New code” ?

Hey there.

The scanner uses git tries to find the fork date between the analyzed branch and the reference branch. Lines and Issues are classified as new if they come after this date.

1 Like

This is a very interesting discussion. I have tried to troubleshooting an issue where the new code does not behave as expected when comparing branches and its hard to troubleshoot without knowing the details as to how the scanner identifies where the fork is and how to identifies the new code. Whether it is using git log commands to track or git diff with some flags. I recently also realized that our setup with Bitbucket was only pulling the active branch and not all branches and that is obviously a problem when comparing branches. Despite that issue, I still want to be able to validate that the new code that SonarQube identifies is what it should be, so to do that I need to understand what the scanner is doing on git level. Anyone have more details?