获取 api/measures/组件
自 5.4 起
返回具有指定度量的组件。
需要以下权限:“浏览”指定组件的项目。
参数
| Parameter |
Required? |
Since |
Description |
Example value |
| additionalFields |
optional |
|
Comma-separated list of additional fields that can be returned in the response. |
Possible values: metrics, period, periods Example value: period,metrics |
| branch |
optional |
6.6 |
Branch key. Not available in the community edition. |
Example value: feature/my_branch |
| component |
required |
|
Component key |
Example value: my_project |
| metricKeys |
required |
|
Comma-separated list of metric keys |
Example value: ncloc,complexity,violations |
| pullRequest |
optional |
7.1 |
Pull request id. Not available in the community edition. |
Example value: 5461 |
响应示例
{
"component": {
"key": "MY_PROJECT:ElementImpl.java",
"name": "ElementImpl.java",
"qualifier": "FIL",
"language": "java",
"path": "src/main/java/com/sonarsource/markdown/impl/ElementImpl.java",
"measures": [
{
"metric": "complexity",
"value": "12",
"period": {
"value": "2",
"bestValue": false
}
},
{
"metric": "new_violations",
"period": {
"value": "25",
"bestValue": false
}
},
{
"metric": "ncloc",
"value": "114",
"period": {
"value": "3",
"bestValue": false
}
}
]
},
"metrics": [
{
"key": "complexity",
"name": "Complexity",
"description": "Cyclomatic complexity",
"domain": "Complexity",
"type": "INT",
"higherValuesAreBetter": false,
"qualitative": false,
"hidden": false,
"custom": false
},
{
"key": "ncloc",
"name": "Lines of code",
"description": "Non Commenting Lines of Code",
"domain": "Size",
"type": "INT",
"higherValuesAreBetter": false,
"qualitative": false,
"hidden": false,
"custom": false
},
{
"key": "new_violations",
"name": "New issues",
"description": "New Issues",
"domain": "Issues",
"type": "INT",
"higherValuesAreBetter": false,
"qualitative": true,
"hidden": false,
"custom": false
}
],
"period": {
"mode": "previous_version",
"date": "2016-01-11T10:49:50+0100",
"parameter": "1.0-SNAPSHOT"
}
}
更新日志
| Version |
Change |
| 8.8 |
deprecated response field 'id' has been removed. |
| 8.8 |
deprecated response field 'refId' has been removed. |
| 8.1 |
the response field periods under measures field is deprecated. Use period instead. |
| 8.1 |
the response field periods is deprecated. Use period instead. |
| 7.6 |
The use of module keys in parameter 'component' is deprecated |
| 6.6 |
the response field 'id' is deprecated. Use 'key' instead. |
| 6.6 |
the response field 'refId' is deprecated. Use 'refKey' instead. |