Getting number of issues fixed in a branch

which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension)

SonarQube Version 8.1 (build 31237) – Developer Edition Trial

Scanning done with sonar-scanner-cli-4.2.0.1873-linux

what are you trying to achieve

I’m trying to know how many issues have been fixed by a pull request branch

what have you tried so far to achieve this

After scanning a branch with “pull request” analysis enabled (setting the sonar.pullrequest.key,sonar.pullrequest.branch, and sonar.pullrequest.base options), I get some great features: A very clean UI that shows the number of new issues, a listing of those new issues, and a overall go/nogo on the quality gate.

However, the goal on my team is to drive down issues, not simply prevent new ones. So it’s important to be able to see at least the number of fixed issues (seeing the exact list of issues fixed would be neat, but not required. Just overall numbers would be fine for me).

This is not a new request, as I recently found this tracking issue: https://jira.sonarsource.com/browse/MMF-1474

However, it was recently closed. So I’m wondering if the community knows of any workarounds.

Since I only care about the numbers right now, I thought maybe I could do this calculation myself.

In the web UI, when I browse issues, I can clearly see the number of issues for my base branch. However, for my pull request branch, I can only see the number of new issues. I figure sonar somehow knows the number of total issues for this branch, but this data doesn’t appear to be exposed in the web UI.

Next I tried looking at the web API. Using the /api/issues I can easily get a list of all issues for my project (even sorted and filtered). If I set the ps (pagesize) parameter to 1, I can easily get the total issue count. But these results seem to be for the whole project. I don’t see anyway to limit my query to a specific branch. Even in the returned data, the issue object doesn’t seem to include any branch info.

My only other idea is to create a new project for each branch, use the web API to get the data, and manually calculate myself the difference in issues. This would be prohibitively expensive with the developer edition, but might work in the Community Edition.

I’d be eager to hear any other ideas.

Thanks!