Duplicated Lines on New Code checks whole file


I am using SonarQube Version 7.4 (build 18908). I created a Quality Gate which should check new code since leak period for Duplicated Lines on New Code.

The odd thing here is, when I have a file and change one line in it since leak period started, SonarQube points to part of code within this file, which are older when there are duplicated lines.

Why is that?


A screenshot of what you’re seeing would have been helpful. In the absence of that, I’ll provide my own screenshot of what I think you’re seeing:

This duplication issue is raised at file level to tell you that somewhere in the file are some number (2 in my example) of duplicated blocks. If you scroll down through the file, you’ll see marginal markers that indicate which blocks are duplicated. E.G.:


The interesting thing here is that you’re apparently seeing a newly-raised duplication issue after changing only one line. The docs outline how duplication detection works. At a guess, I’d say your one line, pushed some block of code over the threshold.

Of course, this is all guess-work based on an intuitive reading of your report. Feel free to come back and tell me I’m wrong.


A post was split to a new topic: Adding one line to an old duplicated block marks it new