I am using SonarQube SonarQube v7.9.1 (Bulid 27448) Enterprise edition and Sonar Scanner v184.108.40.2068. And C++ Build wrapper v4.7
I have noticed that on our short-lived branch (SLB) called “integration”, when I look at the analysis (which I believe is an analysis of the delta between this branch and branch “master”) I see some issues on lines of code that were written 5 years ago. Sonar tells me it is 5 years ago.
For example, “Split this 171 characters long line… [See Rule] 5 years ago L167”
Why is it showing me a line of code written 5 years ago?
The master branch is no more than 4 weeks older than the integration branch, since integration is merged to master roughly once a month.
Q1. Please can you explain why Sonar is including a line from 5 years ago?
Q2. Please can you explain what Sonar is trying to tell me here?
Surely Sonar just sees the lines of code in branch integration that are new/changed compared with master, and analyses those lines. So this long line, which was written 5 years ago, should surely not appear in the analysis. Or should it? If so, why?
Finally, our definition of “New code” is set to “previous_version” for our project.
SonarQube appears to tell me that the analysis for branch “integration” is “From master” - that’s printed at the top of the web page - so I assume it is a delta of branch integration compared with branch master.
In fact, according to the docs (Overview | SonarQube Docs) for a short-lived branch, “…there is no way to set the New Code period; everything that has been changed in the branch is new code.”
So I really am not sure why Sonar is analysing lines of code that were last changed 5 years ago.
Update: I see that under the tab “Issues”, on the left-hand pane there is a twistie called “Creation Date” with a bar graph showing me dates and the option to click on All or New Code. This gives me control over the range.
So now I realise that I was misinterpreting the information I was told here that a SLB is a delta scan from master. What it actually is is a delta from when the branch was branched off of master, not the current state of the branch versus the current state of the master branch.
From what I can see, for a given SLB, we are looking just at the lifetime of that branch perhaps, and the analysis shown is nothing to do with master? Ah, I think the issue is that our integration branch was branched off of master 5 years ago, so it’s not really supposed to be a SLB. So we see ALL issues in our integration branch - it’s not a delta as I’d imagined but just a delta between what happened in the last 5 years since the branch was branched off of master.
Please can someone confirm?
Thanks in advance.