forked from phoedos/pmd
[apex] Verify OperationWithLimitsInLoop for triggers
This commit is contained in:
parent
9810bfc3cc
commit
97fe106724
@ -519,4 +519,27 @@ public class Foo {
|
||||
]]></code>
|
||||
</test-code>
|
||||
<!-- End system method invocations -->
|
||||
|
||||
<test-code>
|
||||
<description>SOQL inside loop in trigger (#5138)</description>
|
||||
<expected-problems>1</expected-problems>
|
||||
<expected-linenumbers>6</expected-linenumbers>
|
||||
<code><![CDATA[
|
||||
// from https://github.com/certinia/orizuru-sample-app/blob/master/src/apex/force-app/main/default/triggers/DataGeneratorStepTrigger.trigger
|
||||
trigger DataGeneratorStepTrigger on DataGeneratorStep__e (after insert) {
|
||||
|
||||
List<GenerateDataTask__c> tasks = new List<GenerateDataTask__c>();
|
||||
for (DataGeneratorStep__e event : Trigger.New) {
|
||||
GenerateDataTask__c task = [SELECT Id, TaskStatus__c FROM GenerateDataTask__c WHERE Id=:event.SObjectId__c LIMIT 1];
|
||||
|
||||
if (task.TaskStatus__c != 'CREATED_ORDERS') {
|
||||
task.TaskStatus__c = event.Status__c;
|
||||
tasks.add(task);
|
||||
}
|
||||
}
|
||||
|
||||
update tasks;
|
||||
}
|
||||
]]></code>
|
||||
</test-code>
|
||||
</test-data>
|
||||
|
Loading…
x
Reference in New Issue
Block a user