Git - Stale Branch Analysis


We are using Git, hosted on Azure Devops, that has CI pipelines with SonarQube analysis integrated. I am seeing that on stale branches, there seems to be some issues. Our setup is simple enough, with master being a Main branch and feature branches being short-lived branches in SonarQube.

The scenario:

  • A feature branch is created off commit 12345 on master, call the feature feature/myFeature
  • master has 10 commits done on it from other PR’s. feature/myFeature has no commits during this time.
  • feature/myFeature becomes active again and has a couple commits, and a subsequent pull request created.

I am seeing that on analysis of feature/myFeature, issues are raised on code that is different compared to the current state of master. However, it’s my understanding that only new code in the commits of feature/myFeature should be analyzed. It is like SonarQube is comparing the branch to the current master, instead of the branch point, commit 12345. Am I thinking about this the right way?

We are using SonarQube 7.9 LTS installed on an on-prem server. The analysis occurs on a different server, which talks to Azure Devops, which talks SonarQube.

When it comes to issues, the feature branch (feature/myFeature) will always be compared to the latest known version of the target branch (master).

Is there any way I can change this for my instance? It does not seem right, as other commits on master can introduce Sonar issues that have nothing to do with the feature branch’s code.

Sorry, you can’t change that.
The best would be to rebase your branch on master. That way if some issues were fixed in master, those issues will no longer appear in the feature branch.

Ok, thanks for the information.