[FIXED] Disable Sonar duplications on Entity, DTO packages

Issue

Is there any way to disable certain metrics from selected packages in Sonar? I use Sonar to analyze my project and in Entity and DTO packages I have some code that is equal – the same field ID with annotations, etc is being reported as a duplication by Sonar. It has absolutely no sense to me so I’d like to disable it. How can I achieve this? Using the global exclusions option disables all metrics on selected package but how to do it just for code duplications?

Solution

You can exclude resources using the standard “sonar.exclusions” parameter or use the Switch Off violation plugin to exclude “Duplicated code” violations.

Note that the 2nd option (use of the switch off plugin) works only if you’re using the SQALE plugin, which embeds the “sqale-java:DuplicatedBlocksCheck” rule.

Answered By – Fabrice – SonarSource Team

Answer Checked By – Timothy Miller (Easybugfix Admin)

Leave a Reply

(*) Required, Your email will not be published