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 Salesforce Code Duplicates dashboard. 


Best Practice DescriptionConfiguration Element TypeIssue SeverityIssue Impact Area
Code DuplicationApex Class

HIGH (if total number of duplicated lines is over 1000)

MEDIUM (if total number of duplicated lines is between 100 and 1000)

LOW (if total number of duplicated lines is between 10 and 100)

MANAGEABILITY
Code DuplicationApex Trigger

HIGH (if total number of duplicated lines is over 1000)

MEDIUM (if total number of duplicated lines is between 100 and 1000)

LOW (if total number of duplicated lines is between 10 and 100)

MANAGEABILITY