How to read pull request decoration statistics from SonarQube 8.3 using the API

We started using the Pull Request Decoration integration from GitLab lately.
At the moment we don’t enforce quality gate as we want to tune them based on statistics.

We are focusing on coverage for pull request, new issues, bugs, vulnerabilities

For example:

  • We want to identify areas where it’s harder to enforce coverage e.g. areas in our code that are very hard to test, and we may want to enforce different set of rules.
  • We want to identify patterns where developers are keener to write tests test (e.g. Bugs vs New code vs refactoring).
  • Identify developers which avoid the sonar analyses and commit with issues.

I want to create weekly report around those topics based on Pull Request Decorations in Sonar on closed Pull Requests.

Looking at the Sonar API I have to say I got lost
Tried to explore
https://sonar.com/api/project_pull_requests/list
https://sonar.com /api/measures/search_history
https://sonar.com/api/measures/component_tree

But still cannot figure out, I am also can’t find any documentation (apart from the https://sonar.com/api/webservices/list endpoint)

Any recommendations references or sample projects

Hi @haimra,

A good way to “cheat” at learning the APIs to use for a particular case is to watch what the SonarQube UI itself does. Our UI is written on top of the web API. So simply load your browser developer tools, make sure you’re watching the network traffic, and then load/reload a page that has the kind of data you’d like to extract: in your case, likely the overview page for a Pull Request branch.

Hope this helps!

It looks like a good approach.
Thanks :smiley:

@haimra i am looking for the samething, did you find api to get coverage details for pull request ?