forked from phoedos/pmd
[apex] Verify EmptyIfStmt and EmptyStatementBlock with triggers
This commit is contained in:
parent
fe0d05d8d5
commit
1038eaa283
@ -30,4 +30,29 @@ public class Foo {
|
||||
}
|
||||
]]></code>
|
||||
</test-code>
|
||||
|
||||
<test-code>
|
||||
<description>EmptyIfStatement in trigger (#5138)</description>
|
||||
<expected-problems>1</expected-problems>
|
||||
<expected-linenumbers>9</expected-linenumbers>
|
||||
<code><![CDATA[
|
||||
// https://github.com/SalesforceLabs/chatter-delete-blocker/blob/master/src/triggers/DisableFeedPostDeletes.trigger
|
||||
/**
|
||||
* Author: Marcus Ericsson - mericsson@salesforce.com
|
||||
*/
|
||||
trigger DisableFeedPostDeletes on FeedItem (before delete)
|
||||
{
|
||||
if (!DisableChatterDeleteDelegate.allowDelete()) {
|
||||
for(FeedItem f : Trigger.old){
|
||||
if (((String)f.parentId).startsWith('00Q') && f.type == 'TrackedChange') {
|
||||
// ok to ignore
|
||||
}
|
||||
else {
|
||||
f.addError('Your administrator has disabled feed post and comment deletions.');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]]></code>
|
||||
</test-code>
|
||||
</test-data>
|
||||
|
@ -143,6 +143,35 @@ public class Foo {
|
||||
}
|
||||
}
|
||||
}
|
||||
]]></code>
|
||||
</test-code>
|
||||
|
||||
<test-code>
|
||||
<description>EmptyStatementBlock in trigger (#5138)</description>
|
||||
<expected-problems>1</expected-problems>
|
||||
<expected-linenumbers>18</expected-linenumbers>
|
||||
<code><![CDATA[
|
||||
// https://github.com/SalesforceLabs/chatter-delete-blocker/blob/master/src/triggers/DisableFeedPostDeletes.trigger
|
||||
/**
|
||||
* Author: Marcus Ericsson - mericsson@salesforce.com
|
||||
*/
|
||||
trigger DisableFeedPostDeletes on FeedItem (before delete)
|
||||
{
|
||||
if (!DisableChatterDeleteDelegate.allowDelete()) {
|
||||
for(FeedItem f : Trigger.old){
|
||||
if (((String)f.parentId).startsWith('00Q') && f.type == 'TrackedChange') {
|
||||
// ok to ignore
|
||||
}
|
||||
else {
|
||||
f.addError('Your administrator has disabled feed post and comment deletions.');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setBar(Integer bar) {
|
||||
// empty
|
||||
}
|
||||
}
|
||||
]]></code>
|
||||
</test-code>
|
||||
</test-data>
|
||||
|
Loading…
x
Reference in New Issue
Block a user