我的问题是此处发布的关于新代码覆盖率指标未从 SonarQube 5.3 API 返回值的问题的延续
我们最近推出了 Sonar 5.3 以利用 new_coverage 和其他新指标。然而,经过几天对几个代码的分析,我们发现 Sonar 没有正确检测 new_coverage 指标。然而,它能够检测 new_violations 等。
这种情况相当普遍,并且发生在几个基于 Java 的项目中。运行分析后,Sonar 将报告 ncloc、new_violations 等的变化,但不会报告 new_coverage 的 var2 和 fvar2 的值。这是 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
}
]
}
]
正如您在上面的响应中看到的,自之前的分析以来,我们已经更改了代码行(并且所有这些行都在未被忽略的功能代码中。但是,尽管事实上只是进行了分析,但 new_coverage 字段的 var2 没有值昨天完成。问题不仅在 API 中,甚至在 UI 端。我们没有看到几个指标的新覆盖率指标的“自上次分析以来的价值”,但其他新代码指标和总覆盖率都很好。