'Sonar Web Service - Code Coverage Metrics

I'm trying to extract sonar code coverage metrics via the Sonar Web Service documentation.

The Sonarqube API single class test coverage recommends that i should use this pattern for my target class name

https://[hostname]/api/resources?resource=com.a.b.c.d.om:[module-name]:com.a.b.c.d.e.mobile.XYZActionHandler&metrics=coverage,branch_coverage

but i've found that only using the java source path in the resource name works

https://[hostname]/api/resources?resource=com.a.b.c.d.om:[module-name]:src/main/java/com/a/b/c/d/e/actions/mobile/XYZActionHandler.java&metrics=coverage,branch_coverage

Can someone explain why the first URL fails but the second one works?



Solution 1:[1]

It depends on the version of SonarQube that you use.

In recent versions (at least since the last LTS, probably as far as 4.2), a Java component's key is indeed its path, whereas in older versions it was its fully qualified name (package.Class).

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Mithfindel