Sonar Quality Gate Status for my Java project fails on “Duplicated Lines (%) on New Code”.
The duplication warning is valid, but the code is not meant to be refactored because it is a legacy code.
Sonar does not show code resolution options for Code Duplication (Resolve as Fixed, Resolve as won’t fix, etc.). I see those resolution options for code issues, but not for Code Duplication.
Is there a way to mark a specific instance of Code Duplication in Sonar as Won’t Fix?
Alternatively, is there a way to mark a block of Java code so that Sonar ignores it?
Thank you.
Handling duplicated code is not as straight forward as regular findings.
What I usually do in your case is that I add the file(s) to the ignore list, but be aware you need to be an administrator to do this.
It is quite annoying regular developers have no way of handling this themselves besides of course refactoring the code which is not always possible.
I think every few months I hear rumblings internally about making it possible to “accept” duplication and coverage issues similar how you can accept issues… but nothing materializes, unfortunately.
I’d suggest you also add your voice to this roadmap card.
Thanks everyone for your responses.
I came across another thread that talks about ignoring a Duplication warning:
Suppressing Duplicate Code Blocks in SonarQube - SonarQube Server / Community Build - Sonar Community
I wish someone makes a sticky thread on ignoring a Duplication since people keep asking about this and creating new threads.