How to retrieve the file specific sonar issues from sonarcloud api for opendaylight project

Hi,

When I tried to fetch the file specific sonar issues using this API for opendaylight project https://sonarcloud.io/api/issues/search?componentKeys=opendaylight_netconf&files=opendaylight_netconf/apps%2Fnetconf-topology-singleton%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fnetconf%2Ftopology%2Fsingleton%2Fimpl%2Factors%2FNetconfNodeActor.java

it provides the all sonar issues which is relevant to the opendaylight_netconf project instead of specific file sonar issues. But the same api is working well with the organization hosted sonar cloud which returns only file specific sonar issues.

ex response specific to the file:

{
  "total": 9,
  "p": 1,
  "ps": 100,
  "paging": {
    "pageIndex": 1,
    "pageSize": 100,
    "total": 9
  },
  "effortTotal": 74,
  "issues": [
    {
      "key": "AY2Ol",
      "rule": "java:S604",
      "severity": "MAJOR",
      "component": "coFunction.java",
      "project": "corator",
      "line": 48,
      "hash": "7fb4ca3816973e258a",
      "textRange": {
        "startLine": 48,
        "endLine": 48,
        "startOffset": 33,
        "endOffset": 52
      },
      "flows": [],
      "status": "OPEN",
      "message": "Replace this usage of 'Stream.collect(Collectors.toList())' with 'Stream.toList()'",
      "effort": "5min",
      "debt": "5min",
      "assignee": "gjam",
      "author": "gaw.com",
      "tags": [
        "java16"
      ],
      "creationDate": "2024-02-13T03:13:18-0600",
      "updateDate": "2024-02-13T03:13:18-0600",
      "type": "CODE_SMELL",
      "scope": "MAIN",
      "quickFixAvailable": false,
      "messageFormattings": []
    },
    {
      "key": "AbXFUCkxVeqQOk",
      "rule": "java:S112",
      "severity": "MAJOR",
      "component": "coFunction.java",
      "project": "coor",
      "line": 57,
      "hash": "e44d9044828ce92ee356",
      "textRange": {
        "startLine": 57,
        "endLine": 57,
        "startOffset": 26,
        "endOffset": 42
      },
      "flows": [],
      "status": "OPEN",
      "message": "Define and throw a dedicated exception instead of using a generic one.",
      "effort": "20min",
      "debt": "20min",
      "assignee": "akum",
      "author": "gawas.com",
      "tags": [
        "cert",
        "cwe",
        "error-handling"
      ],
      "creationDate": "2024-02-13T03:13:18-0600",
      "updateDate": "2024-02-13T03:13:18-0600",
      "type": "CODE_SMELL",
      "scope": "MAIN",
      "quickFixAvailable": false,
      "messageFormattings": []
    },

My doubts:
- Why the same api is working in organization based sonar cloud and its not working with public sonarcloud.io for opendaylight project.

  • Is there any different api’s are available for public sonarcloud to fetch the file specific issues
  • Is there any way to fetch the fileUUID’s where we can retrieve the sonar issues w.r.t the file

Thanks,
Sathish J

Hi Sathish,

Have you tried this via the UI? The best way to master the API is to perform the desired action via the UI and eavesdrop to see which calls the UI made to accomplish the action.

You may also find this guide helpful.

 
Ann