Fixed several rules (exceptions on jdk 1.5 source code).

git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/trunk@4735 51baf565-9d33-0410-a72c-fc3788e3496d
This commit is contained in:
Xavier Le Vourch
2006-10-23 07:05:21 +00:00
parent 5287ab72a2
commit 8cc36876c1
4 changed files with 11 additions and 2 deletions

View File

@ -23,6 +23,7 @@ Fixed CSVRenderer - had flipped line and priority columns
Fixed bug in Ant task - CSV reports were being output as text.
Fixed false negatives in UseArraysAsList.
Fixed several JDK 1.5 parsing bugs.
Fixed several rules (exceptions on jdk 1.5 source code).
CloseResource rule now checks code without java.sql import.
ArrayIsStoredDirectly rule now checks Constructors
undo/redo added to text areas in Designer.

View File

@ -573,7 +573,7 @@ public final class ConstructorCallsOverridableMethod extends AbstractRule {
if (h.isDangerous()) {
String methName = h.getASTMethodDeclarator().getImage();
int count = h.getASTMethodDeclarator().getParameterCount();
if (meth.getName().equals(methName) && meth.getArgumentCount() == count) {
if (methName.equals(meth.getName()) && meth.getArgumentCount() == count) {
addViolation(data, meth.getASTPrimaryExpression(), "method '" + h.getCalled() + "'");
}
}

View File

@ -222,6 +222,10 @@ public class NpathComplexity extends StatisticalRule {
* @return complexity of the boolean expression
*/
public static int sumExpressionComplexity(ASTExpression expr) {
if (expr == null) {
return 0;
}
List andNodes = expr.findChildrenOfType( ASTConditionalAndExpression.class );
List orNodes = expr.findChildrenOfType( ASTConditionalOrExpression.class );

View File

@ -77,7 +77,11 @@ public class ArrayIsStoredDirectly extends AbstractSunSecureRule {
ASTPrimaryExpression pe = (ASTPrimaryExpression) se.jjtGetChild(0);
String assignedVar = getFirstNameImage(pe);
if (assignedVar == null) {
assignedVar = ((ASTPrimarySuffix) se.getFirstChildOfType(ASTPrimarySuffix.class)).getImage();
ASTPrimarySuffix suffix = (ASTPrimarySuffix) se.getFirstChildOfType(ASTPrimarySuffix.class);
if (suffix == null) {
continue;
}
assignedVar = suffix.getImage();
}
SimpleNode n = (ASTMethodDeclaration) pe.getFirstParentOfType(ASTMethodDeclaration.class);