Detecting code duplication in Salesforce

Duplicated code impacts the quality of your Salesforce org. Every block of duplicated code detected across Apex Classes and Apex Triggers generates an issue in instance scans.

The severity of the issue depends on the total number of code lines which are repeated in the Org (size of repeated block x number of lines in the block x number of repetitions).

The minimum token length which should be reported as a duplicate is set to 100

You can find the code duplication issues on the Duplicated Code dashboard. 



Best PracticeConfiguration Element TypeIssue SeverityImpact Area
Code DuplicationApex ClassHIGH (if total number of duplicated lines is over 1000)Manageability
Code DuplicationApex ClassMEDIUM (if total number of duplicated lines is between 100 and 1000)Manageability
Code DuplicationApex ClassLOW (if total number of duplicated lines is between 10 and 100)Manageability
Code DuplicationApex TriggerHIGH (if total number of duplicated lines is over 1000)Manageability
Code DuplicationApex TriggerMEDIUM (if total number of duplicated lines is between 100 and 1000)Manageability
Code DuplicationApex TriggerLOW (if total number of duplicated lines is between 10 and 100)Manageability




Last modified on Nov 3, 2020