Getting full metrics from branch / pullrequest analysis

Hi,
We have sonrqube 7.7 that’s linked to GitHub Enterprise. We’ve found PullRequest decoration working fine for integrating new features, but for maintenance work it lacks some visibility.

For the instance I have a file that contains 100 smells (where entire project is 1000smells).
Then when I create a Pull Request that fixes 100 smells from that file, but introduces 1 new smell. My Pull Request gets decorates as failure - because new code contains 1 smell. Logic of PullRequest analysis ignores the fact that my change has removed other problems - it just focuses on introduced issues.
That logic is streamlined what API offers me at the moment - when calling api/measures/component of my PR/Branch (internal api) - I’m getting only number of introduced smells.

What I would expect is that:

  • There is a way to configure PullRequest plugin to either report newly introduced issues. Or difference between base-branch and pull request branch
  • There is an API that reduces full metrics of PR/branch - not just newly introduced issues.

Cheers,
Piotr

Hi Piotr,

A few responses:

  • SonarQube 7.7 is rather old and no longer supported. You should consider upgrading at least to the 7.9 LTS release.
  • In general, our PR analysis has always focused its results on the new/changed code only. While it’s great that you’re choosing to fix some legacy code smells on the PR branch, if the Quality Gate fails on something new, it indeed fails. You’ll get “credit” for fixing the 100 code smells when you merge the PR into its target branch and then re-scan the target branch following the merge. At that point in time the 100 code smells should be closed out and your maintainability metrics adjusted accordingly.

Hope this helps!