Duplicate SonarCloud issues

We are aving a problem with duplicate issues in our SonarCloud project and would like your guidance.

Environment:

  • CI system: AzureDevops
  • Version control: TFVC
  • Language: C++

We have a pipeline which includes a sonarcloud analysis step. I observed that some issues were created a few times. For example, a particular issue in a .cpp file appears four times, each with a different key, creationDate, updateDate, and closeDate, while all other fields are identical.

Our hypothesis is that it may be because the file is big, there were some changes in its other parts and when new scan was performed the existing issue was marked as new (and the old one as closed).

Hey there.

Could you share a screenshot where you see duplicate issues?

Screenshot included :slight_smile:

Hi Jakub,

Thank you for clarifying. To make sure I understand:

  • You’re saying there is still one open issue in the file for Remove this redundant cast, and each issue in your screenshot is a previous occurrence of this same underlying issue?
  • Your hypothesis is that, because the file is large and has undergone changes in other areas, SonarQube may have marked the issue as new on the latest scan (while closing the previous one).

How many lines does this file have?

I checked the project, where these issues occurred and I no longer see any duplicate issues in the SonarCloud GUI.

However, when I query the issues via the API, the four duplicated entries are still present, marked as FIXED and CLOSED (in the past they had to be “OPEN”, because I’m filtering for this status).

One of the duplicated entries:

{
  "key": "[REDACTED]",
  "rule": "cpp:S1905",
  "severity": "MINOR",
  "component": "[REDACTED]",
  "project": "[REDACTED]",
  "hash": "[REDACTED]",
  "textRange": {
    "startLine": 951,
    "endLine": 951,
    "startOffset": 34,
    "endOffset": 73
  },
  "flows": [],
  "resolution": "FIXED",
  "status": "CLOSED",
  "message": "Remove this redundant cast.",
  "effort": "5min",
  "debt": "5min",
  "author": "",
  "tags": ["clumsy", "redundant"],
  "creationDate": "2025-08-19T14:23:31+0000",
  "updateDate": "2025-08-19T17:39:34+0000",
  "closeDate": "2025-08-19T17:39:34+0000",
  "type": "CODE_SMELL",
  "organization": "[REDACTED]",
  "branch": "[REDACTED]",
  "cleanCodeAttribute": "CLEAR",
  "cleanCodeAttributeCategory": "INTENTIONAL",
  "impacts": [
    {
      "softwareQuality": "MAINTAINABILITY",
      "severity": "LOW"
    }
  ],
  "issueStatus": "FIXED",
  "projectName": "[REDACTED]"
}

The files are pretty large - the largest are up to a few thousand lines of code. And also it is TFVC so it may cause trouble. But nevertheless. I belive that the issue is solved for now. If it returns, then I will investigate further what’s the cause.

Actually I noticed that the issue still persists. The file has 6k lines of code.

The issues with the same name are from the same line.

image

There are seven issues to the analyzed file. Then, when I click “See all issues in this file” only one issue is visible:

I’ve reached out to you via PM for some private details.

Hi @jakub.d.dobosz . Sorry for the delay

What do you mean by when I click “See all issues in this file”
Is it when you are on the “Issues” page and then you click on an issue, or any other action?

Regarding the issue matching between two scans, if I’m not mistaken we try to match old/new code lines using VCS information. When you compare 2 versions of your file, do you see big differences with code added/removed instead of simply being changed?

Thank you very much for your response. The “See all issues in this file” link is highlighted below in the screenshot. This view appears, when I check issues for the whole file.

I believe you’re correct. I checked how Azure DevOps handles Changesets (TFVC pushes), and it appears that even when only part of a line is modified, Azure treats it as if the line was removed and then added again. So that’s probably the reason for SonarCloud’s behavior.

Thanks for your answer

Long time ago, when I had that kind of issues with big differences between 2 versions of a file, the issue was due to line ending, which was different on local and on VCS. Not sure if you maybe have the same issue

I’m not sure we can do anything more here.

Thank you. I think we can live with it :). And maybe we won’t get many such issues in he future. I think you can close the thread and mark the issue as resolved/inactive.