pmd: fix #1085 NullPointerException by at net.sourceforge.pmd.lang.java.rule.design.GodClassRule.visit(GodClassRule.java:313)

This commit is contained in:
Andreas Dangel
2013-04-25 19:11:01 +02:00
parent 2d655f4684
commit 5fb6daea58
3 changed files with 20 additions and 3 deletions

View File

@ -4,6 +4,7 @@ Fixed bug 254: False+ : UnusedImport with Javadoc @throws
Fixed bug 1080: net.sourceforge.pmd.cpd.CPDTest test failing
Fixed bug 1081: Regression: CPD skipping all files when using relative paths
Fixed bug 1082: CPD performance issue on larger projects
Fixed bug 1085: NullPointerException by at net.sourceforge.pmd.lang.java.rule.design.GodClassRule.visit(GodClassRule.java:313)
Fixed bug 1086: Unsupported Element and Attribute in Ant Task Example
Fixed bug 1087: PreserveStackTrace (still) ignores initCause()

View File

@ -13,7 +13,7 @@ import java.util.Set;
import net.sourceforge.pmd.RuleContext;
import net.sourceforge.pmd.lang.java.ast.ASTAllocationExpression;
import net.sourceforge.pmd.lang.java.ast.ASTCatchStatement;
import net.sourceforge.pmd.lang.java.ast.ASTClassOrInterfaceDeclaration;
import net.sourceforge.pmd.lang.java.ast.ASTCompilationUnit;
import net.sourceforge.pmd.lang.java.ast.ASTConditionalAndExpression;
import net.sourceforge.pmd.lang.java.ast.ASTConditionalExpression;
import net.sourceforge.pmd.lang.java.ast.ASTConditionalOrExpression;
@ -77,12 +77,12 @@ public class GodClassRule extends AbstractJavaRule {
/**
* Base entry point for the visitor - the class declaration.
* Base entry point for the visitor - the compilation unit (everything within one file).
* The metrics are initialized. Then the other nodes are visited. Afterwards
* the metrics are evaluated against fixed thresholds.
*/
@Override
public Object visit(ASTClassOrInterfaceDeclaration node, Object data) {
public Object visit(ASTCompilationUnit node, Object data) {
wmcCounter = 0;
atfdCounter = 0;
methodAttributeAccess = new HashMap<String, Set<String>>();

View File

@ -125,4 +125,20 @@ public class Foo {
}
]]></code>
</test-code>
<test-code>
<description>#1085 NullPointerException by at net.sourceforge.pmd.lang.java.rule.design.GodClassRule.visit(GodClassRule.java:313)</description>
<expected-problems>0</expected-problems>
<code><![CDATA[
public enum Color {
BLUE,
RED;
public int toHex() {
return 0;
}
}
]]>
</code>
</test-code>
</test-data>