This commit is contained in:
Robert Sösemann
2017-12-20 15:58:12 +01:00
parent b3161639f8
commit f267a8f7c7
2 changed files with 17 additions and 4 deletions
@@ -22,7 +22,7 @@ Avoid directly accessing Trigger.old and Trigger.new as it can lead to a bug. Tr
<property name="xpath">
<value>
<![CDATA[
//ArrayLoadExpression/TriggerVariableExpression | //ArrayLoadExpression/LiteralExpression
//ArrayLoadExpression[TriggerVariableExpression and LiteralExpression]
]]>
</value>
</property>
@@ -7,15 +7,15 @@
<test-code>
<description>Directly accessing the Trigger.old map.</description>
<expected-problems>2</expected-problems>
<expected-problems>1</expected-problems>
<code><![CDATA[
trigger AccountTrigger on Account (before insert, before update) {
Account a = Trigger.new[0]; //Bad: Accessing the trigger array directly is not recommended.
}
]]></code>
</test-code>
<test-code>
<test-code>
<description>Looping through map, best practice</description>
<expected-problems>0</expected-problems>
<code><![CDATA[
@@ -27,5 +27,18 @@ trigger AccountTrigger on Account (before insert, before update) {
}
]]></code>
</test-code>
<test-code>
<description>Regression issue #792</description>
<expected-problems>0</expected-problems>
<code><![CDATA[
class NotATrigger {
void foo(){
Account[] accounts = opportunity.Accounts[0];
}
}
]]></code>
</test-code>
</test-data>