sergio quezada
sergio quezada

Reputation: 37

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

I´m trying to get the component line (line of code), from issues list, i´m using /api/issues/search?ps=500&p=1&statuses=OPEN

but, the issues array have a few object that don´t have the "line" propertie.

in this example, the second object have "line" propertie but the first one doesn´t:

{
  "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"
}

how can i display "line" propertie in these objects of the issues array?

thanks.

Upvotes: 1

Views: 697

Answers (2)

Apul
Apul

Reputation: 11

If you mean the line number, instead of the the line itself

it's "textRange": {(...)},

it has two members

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

Upvotes: 0

In SonarQube, issues can be attached at file level - in which case no "line" property is returned by the web service.

In your example, the rule which detects that some tabs are used in a file is exactly in this case. It just says "In this file, you are using tabs that should be replaced by white-spaces". This is done on purpose to not "pollute" your project with too many issues of the same type.

Upvotes: 1

Related Questions