Ignore test classes

This commit is contained in:
Robert Sösemann
2016-04-08 17:13:50 +02:00
parent 591da4f364
commit 18bc0dfe94
2 changed files with 32 additions and 0 deletions

View File

@@ -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;
}
}

View File

@@ -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>