New code definition for C++ projects reports smell for untouched code in a PR

The SonarCloud project is not public, so I cannot publish the URL of the project, but I can describe in detail the problem we are facing.

Setup
We created a GitHub action, following the example and the explanation in Sonarcloud analysis of C++ in GitHub Actions - #4 by acgetchell . We want to run the action for every pull request.The action works fine and is executed correctly (all the sources are analyzed, and the result is reported as a Github comment in the Pull Request.

Problem
The analyzer reports a code smell, which is coming from an untouched line. When clicking on the details, we have this report:

As you can see, the edited line (49) has no problems, but the analyzer indicates line 46 as a code smell. While this may be true, we want only modified code to be analyzed (line 49). If line 46 has a problem, it should not be reported while scanning the pull request (which, again, touches only line 49).

Tentative solution
We tried to change the project setting to “New code” but we still have the same problem. Probably, as this is the first time we are setting up the scanning, it considers everything it sees in the patch (from line 46 to line 52, as we have a configuration for git diff to show 3 lines before and after the changed line) as a new code. There is something we can do to correct this behaviour?

If any additional information is needed, I’ll be happy to provide it. Thanks

Hi,

Welcome to the community!

This new/old issue is being raised on a PR. Could you check the target branch and see if the issue is also raised there?

 
Thx,
Ann

Hello! Sorry for the late response.

We noticed that we didn’t submit the scan for some days, and SonarCloud was seeing as new some code that was not scanned before. Definitely a problem on our side. Thanks anyway!