/api/issues/search 中的 sonarqube-web "line" 数据

sonarqube-web "line" data in /api/issues/search

我正在尝试从问题列表中获取组件行(代码行), 我正在使用 /api/issues/search?ps=500&p=1&statuses=OPEN

但是,问题数组有一些对象没有 "line" 属性。

在此示例中,第二个对象具有 "line" 属性,但第一个对象没有:

{
  "key": "353163de-a4df-40e3-82f0-9a39e94bd1db",
  "rule": "squid:S00105",
  "severity": "MINOR",
  "component": "revision_tqc_r5:controlador/cl/ps/io/Word.java",
  "componentId": 374,
  "project": "revision_tqc_r5",
  "flows": [],
  "status": "OPEN",
  "message": "Replace all tab characters in this file by sequences of white-spaces.",
  "effort": "2min",
  "debt": "2min",
  "author": "",
  "tags": [(...)],
  "creationDate": "2016-04-20T22:14:21+0200",
  "updateDate": "2016-04-20T22:14:21+0200",
  "type": "CODE_SMELL"
},
{
  "key": "3535f5e2-622d-42d3-b18c-a555c4b7c182",
  "rule": "css:leading-zeros",
  "severity": "MINOR",
  "component": "revision_tqc_r5:vista/web/defectos/wpscripts/wpstyleslogin.css",
  "componentId": 3037,
  "project": "revision_tqc_r5",
  "line": 100,
  "textRange": {(...)},
  "flows": [],
  "status": "OPEN",
  "message": "Remove this leading zero",
  "effort": "2min",
  "debt": "2min",
  "author": "",
  "tags": [(...)],
  "creationDate": "2016-04-20T22:14:21+0200",
  "updateDate": "2016-04-20T22:14:21+0200",
  "type": "CODE_SMELL"
}

如何在问题数组的这些对象中显示 "line" 属性?

谢谢。

在 SonarQube 中,可以在文件级别附加问题 - 在这种情况下,Web 服务不会返回 "line" 属性。

在您的示例中,检测文件中使用了某些选项卡的规则正是在这种情况下。它只是说 "In this file, you are using tabs that should be replaced by white-spaces"。这样做是为了避免 "pollute" 您的项目有太多相同类型的问题。

如果你指的是行号,而不是行本身

"textRange": {(...)},

它有两个成员

  • issue.textRange.startLine
  • issue.textRange.endLine