Suppressing Duplicate Code Blocks in SonarQube

Dear SonarQube Community,

I hope this message finds you well.

I am currently working on a project where SonarQube has identified several duplicated code blocks. While I understand the importance of addressing these issues, there are certain cases where the duplicates are legitimate and do not require fixing.

Could you please provide guidance on how to mark these duplicated blocks as “False Positive” or “Won’t Fix” so that they are not counted in subsequent scans? Additionally, are there any best practices or annotations that can be used to suppress these warnings effectively?

Thank you for your assistance.

Bentom Binoy

Hi Bentom,

Unfortunately, there’s no way to mark a duplicated block False Positive. The best you can do is exclude the file it’s in from duplication detection. And yes, that will turn off duplication detection for the entire file, not just the block(s) you’re interested in.

 
Ann

Hi Ann

Is there any feature request in the roadmap for suppressing duplicates?

Thanks a lot

Bentom

Hi @Bentom,

We keep track of the related requests in this portal card.
If we move forward with this we will update the card and if you left your email you will receive a notification.

Chris