Inconsistent naming Apex triggers
Why is this an issue?
Naming conventions help drive consistency across the application, making source code easier to read and understand. When triggers don't follow established naming patterns, it becomes harder to:
Identify which object a trigger belongs to
Locate triggers in the codebase
Maintain consistency across the development team
Examples
Example of incorrect naming:
trigger updateAccounts on Account (before update) {
// Trigger name doesn't follow convention
}
trigger trg_Contact on Contact (after insert) {
// Inconsistent abbreviation
}
Example of correct naming:
trigger AccountTrigger on Account (before update, after update) {
// Clear, consistent naming
}
trigger ContactTrigger on Contact (after insert) {
// Follows the same pattern
}
How can I fix violations?
Rename the trigger to follow your organization's naming convention. A common pattern is <ObjectName>Trigger, for example:
AccountTriggerContactTriggerOpportunityTrigger
If you use different naming conventions, configure the rule to check this following your conventions.
Resources
