Bugs, Vulnerabilities and Code Smells not coming as API response for some of the projects

Team,

When I invoke GET api/project_branches/list, we are not getting “bugs” , “vulnerabilities” and “codeSmells” in response.
API documentation says we will get the above parameters also. What changes we need to do to get the expected output.

Actual output:

{
    "branches": [
        {
            "name": "main",
            "isMain": true,
            "type": "LONG",
            "status": {
                "qualityGateStatus": "OK"
            },
            "analysisDate": "2021-10-28T15:50:44+0200",
            "commit": {
                "sha": "289dc4943d2ec5eab4853fb89f974a1506394ebc",
                "author": {
                    "name": "Ravindra Induri"
                },
                "date": "2021-10-28T15:42:37+0200",
                "message": "Update azure-pipelines-3.yml for Azure Pipelines"
            }
        }
    ]
}

Expected output:

{
  "branches": [
    {
      "name": "feature/foo2",
      "isMain": false,
      "type": "SHORT",
      "mergeBranch": "master",
      "status": {
        "qualityGateStatus": "OK",
        "bugs": 1,
        "vulnerabilities": 0,
        "codeSmells": 0
      },
      "analysisDate": "2017-09-02T13:37:00+0100",
      "commit": {
        "sha": "P1A5AxmsWdy1WPk0YRk48lVPDuYcy4EgUjtm2oGXt6LKdM6YS9"
      }
    }
}

Hi @Vinodh_Bharathi ,

You are correct that bugs, vulnerabilities, and code smells information is not returned for long living branches (it is for short living branches). I will initiate changes to have the documentation reflecting this.

@AlxO

Hi @Vinodh_Bharathi and @AlxO,

I have also noticed this change of behaviour in the this API. Previously, the API example response looked like this:

{
“branches”: [
{
“name”: “feature/foo”,
“isMain”: false,
“type”: “SHORT”,
“mergeBranch”: “master”,
“status”: {
“qualityGateStatus”: “OK”,
“bugs”: 1,
“vulnerabilities”: 0,
“codeSmells”: 0
},
“analysisDate”: “2017-04-03T13:37:00+0100”
},
{
“name”: “master”,
“isMain”: true,
“type”: “LONG”,
“status”: {
“qualityGateStatus”: “ERROR”
},
“analysisDate”: “2017-04-01T01:15:42+0100”
}
]
}

But now the example response looks like this:

{
“branches”: [
{
“name”: “feature/foo”,
“isMain”: false,
“type”: “BRANCH”,
“status”: {
“qualityGateStatus”: “OK”
},
“analysisDate”: “2017-04-03T13:37:00+0100”,
“excludedFromPurge”: false
},
{
“name”: “master”,
“isMain”: true,
“type”: “BRANCH”,
“status”: {
“qualityGateStatus”: “ERROR”
},
“analysisDate”: “2017-04-01T01:15:42+0100”,
“excludedFromPurge”: true
}
]
}

The “type” field now always has the value of “BRANCH”, whereas previously it was either “SHORT” or “LONG”, and the “bugs”, “vulnerabilities”, and “codeSmells” fields have disappeared, regardless of whether or not the branch short-lived.

Is there any other API available that can provide the “bugs”, “vulnerabilities”, and “codeSmells” fields?

Thanks,

Pete

Hey @pbarrack – are you a SonarQube or a SonarCloud user? This thread was about SonarCloud.

Hi @Colin,

Aah, I am a SonarQube user:

SonarQube™ technology is powered by SonarSource SA
Enterprise Edition Version 8.9.2 (build 46101) LGPL v3

It seems that the project_branches/list API has changed behaviour in both SonarQube and SonarCloud?

Thanks,

Pete