forked from phoedos/pmd
Ignore test classes
This commit is contained in:
@@ -5,6 +5,7 @@ package net.sourceforge.pmd.lang.apex.rule.codesize;
|
||||
|
||||
import net.sourceforge.pmd.lang.apex.ast.ASTUserClass;
|
||||
import net.sourceforge.pmd.lang.apex.rule.design.ExcessiveLengthRule;
|
||||
import static apex.jorje.semantic.symbol.type.AnnotationTypeInfos.IS_TEST;
|
||||
|
||||
/**
|
||||
* This rule detects when a class exceeds a certain threshold. i.e. if a class
|
||||
@@ -15,4 +16,13 @@ public class ExcessiveClassLengthRule extends ExcessiveLengthRule {
|
||||
super(ASTUserClass.class);
|
||||
setProperty(MINIMUM_DESCRIPTOR, 1000d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object visit(ASTUserClass node, Object data) {
|
||||
if(node.getNode().getModifiers().getModifiers().not(IS_TEST)) {
|
||||
return super.visit(node, data);
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
}
|
@@ -46,4 +46,26 @@ public class Foo {
|
||||
<code-ref id="long"/>
|
||||
</test-code>
|
||||
|
||||
<test-code>
|
||||
<description>ignore test classes</description>
|
||||
<expected-problems>0</expected-problems>
|
||||
<code><![CDATA[
|
||||
@isTest
|
||||
public class Foo {
|
||||
public void bar() {
|
||||
bar();
|
||||
bar();
|
||||
bar();
|
||||
bar();
|
||||
bar();
|
||||
bar();
|
||||
bar();
|
||||
bar();
|
||||
bar();
|
||||
bar();
|
||||
}
|
||||
}
|
||||
]]></code>
|
||||
</test-code>
|
||||
|
||||
</test-data>
|
Reference in New Issue
Block a user