Duplicated Lines on New Code checks whole file


(kr.st.je) #1

Hi,

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?


Whole files considered new code in short-lived branch
(G Ann Campbell) #2

Hi,

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.:

%20-%20Google%20Chrome_319

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.

 
:slight_smile:
Ann