forked from phoedos/pmd
pmd: fixed #913 SignatureDeclareThrowsException is raised twice
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
???? ??, 2012 - 5.0.2:
|
||||
|
||||
Fixed bug 878: False positive: UnusedFormalParameter for abstract methods
|
||||
Fixed bug 913: SignatureDeclareThrowsException is raised twice
|
||||
Fixed bug 1012: False positive: Useless parentheses.
|
||||
Fixed bug 1026: PMD doesn't handle 'value =' in SuppressWarnings annotation
|
||||
Fixed bug 1037: Facing a showstopper issue in PMD Report Class (report listeners)
|
||||
|
@ -1,5 +1,6 @@
|
||||
package net.sourceforge.pmd.lang.java.rule.strictexception;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import net.sourceforge.pmd.lang.ast.Node;
|
||||
@ -8,6 +9,7 @@ import net.sourceforge.pmd.lang.java.ast.ASTConstructorDeclaration;
|
||||
import net.sourceforge.pmd.lang.java.ast.ASTImportDeclaration;
|
||||
import net.sourceforge.pmd.lang.java.ast.ASTMethodDeclaration;
|
||||
import net.sourceforge.pmd.lang.java.ast.ASTName;
|
||||
import net.sourceforge.pmd.lang.java.ast.ASTNameList;
|
||||
import net.sourceforge.pmd.lang.java.rule.AbstractJavaRule;
|
||||
|
||||
/**
|
||||
@ -46,7 +48,11 @@ public class SignatureDeclareThrowsExceptionRule extends AbstractJavaRule {
|
||||
return super.visit(methodDeclaration, o);
|
||||
}
|
||||
|
||||
List<ASTName> exceptionList = methodDeclaration.findDescendantsOfType(ASTName.class);
|
||||
List<ASTName> exceptionList = Collections.emptyList();
|
||||
ASTNameList nameList = methodDeclaration.getFirstChildOfType(ASTNameList.class);
|
||||
if (nameList != null) {
|
||||
exceptionList = nameList.findDescendantsOfType(ASTName.class);
|
||||
}
|
||||
if (!exceptionList.isEmpty()) {
|
||||
evaluateExceptions(exceptionList, o);
|
||||
}
|
||||
|
@ -80,4 +80,19 @@ public class FooTest {
|
||||
}
|
||||
]]></code>
|
||||
</test-code>
|
||||
<test-code>
|
||||
<description>#913 SignatureDeclareThrowsException is raised twice</description>
|
||||
<expected-problems>1</expected-problems>
|
||||
<code><![CDATA[
|
||||
public class BugSignature {
|
||||
public void record() {
|
||||
SwingWorker worker = new SwingWorker() {
|
||||
protected String construct() throws Exception {
|
||||
//
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
]]></code>
|
||||
</test-code>
|
||||
</test-data>
|
||||
|
Reference in New Issue
Block a user