Skip to content

Commit dd80be1

Browse files
committed
Make compliant and noncompliant examples consistent, add comments to specify files separation
1 parent f06347b commit dd80be1

File tree

1 file changed

+7
-16
lines changed

1 file changed

+7
-16
lines changed

rules/S5384/apex/rule.adoc

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ This rule raises an issue when a Trigger function contains one of the following
1515

1616
[source,apex]
1717
----
18-
trigger MyTrigger on Account(after insert, after update) { // Noncompliant. The trigger is processing records itself instead of using a Trigger Handler.
18+
trigger MyTrigger on Account(after insert) { // Noncompliant. The trigger is processing records itself instead of using a Trigger Handler.
1919
for(Account a : Trigger.New) {
2020
// ...
2121
}
@@ -27,27 +27,18 @@ trigger MyTrigger on Account(after insert, after update) { // Noncompliant. The
2727

2828
[source,apex]
2929
----
30+
// In your .cls file
3031
public with sharing class AccountTriggerHandler {
31-
public static void handleAfterEvents(List<Account> newAccounts, System.TriggerOperation triggerEvent) {
32-
switch on triggerEvent {
33-
when AFTER_INSERT {
34-
processNewAccounts(newAccounts);
35-
}
36-
when AFTER_UPDATE {
37-
// ...
38-
}
39-
}
40-
}
41-
42-
private static void processNewAccounts(List<Account> accountList) {
43-
for (Account a : accountList) {
32+
public static void handleAfterEvents(List<Account> newAccounts) {
33+
for(Account a : newAccounts) {
4434
// ...
4535
}
4636
}
4737
}
4838
49-
trigger AccountTrigger on Account(after insert, after update) { // Compliant: The trigger just delegates the work
50-
AccountTriggerHandler.handleAfterEvents(Trigger.new, Trigger.operationType);
39+
// In your .trigger file
40+
trigger AccountTrigger on Account(after insert) { // Compliant: The trigger just delegates the work
41+
AccountTriggerHandler.handleAfterEvents(Trigger.New);
5142
}
5243
----
5344

0 commit comments

Comments
 (0)