How to get line-by-line coverage information with REST api?

I’m using SonarQube Version 6.7.3 (build 38370) .

I’ve used the REST api for various simple things in the past. I was considering doing some detailed analysis of unit test code coverage results. To do that, I’d need to be able to get line-by-line coverage details of all the source files in a project. I don’t see any way to do that in the REST api supported by this version. How can I do something like this?

Hi David,

This makes me think of a few other past discussions (e.g. this one) where the use-case was indeed not best covered via SonarQube APIs. Yes SonarQube can process coverage information, however its core capability is about the detection/tracking of bugs/vulnerabilities/code_smells, and that’s where you’ll see APIs’ focus and intent.

If you think about it, SonarQube is already itself importing coverage data from external tool. So when I read your plan:

I’m tempted to ask: why not just query the data/reports from the coverage tool directly ? which is anyhow the raw data that SonarQube leverages.

Because the point of integrating all our static analysis tools into SonarQube is to actually integrate them.

3 Likes