pmd: fix #1085 NullPointerException by at net.sourceforge.pmd.lang.java.rule.design.GodClassRule.visit(GodClassRule.java:313)
This commit is contained in:
@ -4,6 +4,7 @@ Fixed bug 254: False+ : UnusedImport with Javadoc @throws
|
|||||||
Fixed bug 1080: net.sourceforge.pmd.cpd.CPDTest test failing
|
Fixed bug 1080: net.sourceforge.pmd.cpd.CPDTest test failing
|
||||||
Fixed bug 1081: Regression: CPD skipping all files when using relative paths
|
Fixed bug 1081: Regression: CPD skipping all files when using relative paths
|
||||||
Fixed bug 1082: CPD performance issue on larger projects
|
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 1086: Unsupported Element and Attribute in Ant Task Example
|
||||||
Fixed bug 1087: PreserveStackTrace (still) ignores initCause()
|
Fixed bug 1087: PreserveStackTrace (still) ignores initCause()
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@ import java.util.Set;
|
|||||||
import net.sourceforge.pmd.RuleContext;
|
import net.sourceforge.pmd.RuleContext;
|
||||||
import net.sourceforge.pmd.lang.java.ast.ASTAllocationExpression;
|
import net.sourceforge.pmd.lang.java.ast.ASTAllocationExpression;
|
||||||
import net.sourceforge.pmd.lang.java.ast.ASTCatchStatement;
|
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.ASTConditionalAndExpression;
|
||||||
import net.sourceforge.pmd.lang.java.ast.ASTConditionalExpression;
|
import net.sourceforge.pmd.lang.java.ast.ASTConditionalExpression;
|
||||||
import net.sourceforge.pmd.lang.java.ast.ASTConditionalOrExpression;
|
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 initialized. Then the other nodes are visited. Afterwards
|
||||||
* the metrics are evaluated against fixed thresholds.
|
* the metrics are evaluated against fixed thresholds.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Object visit(ASTClassOrInterfaceDeclaration node, Object data) {
|
public Object visit(ASTCompilationUnit node, Object data) {
|
||||||
wmcCounter = 0;
|
wmcCounter = 0;
|
||||||
atfdCounter = 0;
|
atfdCounter = 0;
|
||||||
methodAttributeAccess = new HashMap<String, Set<String>>();
|
methodAttributeAccess = new HashMap<String, Set<String>>();
|
||||||
|
@ -125,4 +125,20 @@ public class Foo {
|
|||||||
}
|
}
|
||||||
]]></code>
|
]]></code>
|
||||||
</test-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>
|
</test-data>
|
||||||
|
Reference in New Issue
Block a user