My question is continuation of the question posted here on New code coverage metrics not returning values from SonarQube 5.3 API
We recently rolled out Sonar 5.3 to take advantage of new_coverage and other new metrics. However after some days worth of code analysis of several we are finding that Sonar is not correctly instrumenting new_coverage metric. It is however able to instrument new_violations, etc.
This situation is fairly regular and happening for several java based projects. After running the analysis, Sonar will report change in ncloc, new_violations, etc but will not report value for var2 and fvar2 for new_coverage. Here is a sample response for one application on url https://internal.sonar.server.com/api/resources?resource=prj_key&format=json&metrics=ncloc,new_coverage&includealerts=true&includetrends=true
[
{
"creationDate": "2016-04-06T15:51:29-0400",
"date": "2016-06-20T21:48:27-0400",
"description": "",
"id": 6610,
"key": "<PRJ_KEY>",
"lname": "<PRJ_LNAME>",
"name": "<PRJ_LNAME>",
"p1": "previous_version",
"p1d": "2016-06-06T02:21:39-0400",
"p1p": "16.06.00-SNAPSHOT",
"p2": "previous_analysis",
"p2d": "2016-06-20T16:42:38-0400",
"p2p": "2016-06-20",
"p3": "days",
"p3d": "2016-05-22T02:22:57-0400",
"p3p": "30",
"qualifier": "TRK",
"scope": "PRJ",
"uuid": "AVPtITChBmbOnKmhsXJi",
"version": "16.06.01-SNAPSHOT",
"msr": [
{
"alert": null,
"alert_text": null,
"frmt_val": "41,589",
"fvar1": "483",
"fvar2": "9",
"fvar3": "743",
"key": "ncloc",
"val": 41589.0,
"var1": 483.0,
"var2": 9.0,
"var3": 743.0
},
{
"alert": null,
"alert_text": null,
"frmt_val": "47.9%",
"fvar1": "-0.4%",
"fvar2": "0.0%",
"fvar3": "-0.3%",
"key": "coverage",
"val": 47.9,
"var1": -0.399999999999999,
"var2": 0.0,
"var3": -0.300000000000004
},
{
"alert": "OK",
"alert_text": null,
"fvar1": "15.2%",
"fvar3": "28.1%",
"key": "new_coverage",
"var1": 15.2317880794702,
"var3": 28.1407035175879
}
]
}
]
As you see in the above response, we have lines of code changed since previous analysis (and all those lines are in the functional code not being ignored. However, there is no value for var2 for new_coverage field despite the fact there was an analysis just done yesterday. The issue is not just in API but even on the UI Side. We are not seeing "value since prev analysis" for new coverage metric for several metrics but other new code metrics and total coverage come just fine.