AvoidLogicInTrigger - lpohl-Reply/pmd-github-action GitHub Wiki
Rule: AvoidLogicInTrigger
Message
Avoid logic in triggers
Description
As triggers do not allow methods like regular classes they are less flexible and suited to apply good encapsulation style. Therefore delegate the triggers work to a regular class (often called Trigger handler class).
See more here: https://developer.salesforce.com/page/Trigger_Frameworks_and_Apex_Trigger_Best_Practices
Priority
3
Example
trigger Accounts on Account (before insert, before update, before delete, after insert, after update, after delete, after undelete) {
for(Account acc : Trigger.new) {
if(Trigger.isInsert) {
// ...
}
// ...
if(Trigger.isDelete) {
// ...
}
}
}