Consider lower-case, use parameter strictMode

This commit is contained in:
Andreas Dangel
2019-09-13 15:57:14 +02:00
parent 22e5538e14
commit dd294d3813
2 changed files with 29 additions and 1 deletions

View File

@ -187,7 +187,8 @@ Having the Logging Level specified provides a cleaner log, and improves readabil
<property name="xpath">
<value>
<![CDATA[
//MethodCallExpression[@FullMethodName='System.debug'][count(*)=2]
//MethodCallExpression[lower-case(@FullMethodName)='system.debug'][count(*)=2
or ($strictMode=true() and count(*)=3 and lower-case(VariableExpression/@Image)='debug')]
]]>
</value>
</property>

View File

@ -46,6 +46,33 @@ public class Foo {
static void methodATest() {
System.debug(LoggingLevel.DEBUG, 'I am a good debug.') // good
}
}
]]></code>
</test-code>
<test-code>
<description>Any other method of System is allowed - avoiding false positives</description>
<expected-problems>0</expected-problems>
<code><![CDATA[
public class Foo {
public void bar() {
System.otherMethod();
System.otherMethod('test');
}
}
]]></code>
</test-code>
<test-code>
<description>Test case insensitivity</description>
<rule-property name="strictMode">true</rule-property>
<expected-problems>2</expected-problems>
<code><![CDATA[
public class Foo {
public void bar() {
SyStEm.DeBuG('test');
SyStEm.DeBuG(LoGiNgLeVeL.dEbUg, 'test');
}
}
]]></code>
</test-code>