Shallow clones and duplicated lines being falsely detected on new code

I have a PR that SonarCloud is not passing the Quality Gate for due to duplication of new code.

However, there isn’t any such duplication. It is picking up files as having changed that haven’t. Indeed, I can check that with git diffing between master and the PR’s branch.

Does shallow clone cause this problem? The repository in question is large, a full clone is not fast by any stretch of the imagination and GitHub actions doesn’t yet support a treeless clone (which I’m not sure would even resolve the issue).

Is the assumption that the shallow clone is the problem correct?
Are there any other workarounds?

Hi @bencromwell

You are right, the shallow clone is probably to cause of the issue. Without the history of both the analyzed branch and its target branch, the Scanner can’t properly detect which files has changed in the branch, and filter the issues to keep only the issues and duplications detected on the changed files.

Unfortunately, I am not aware of any workaround.