diff --git a/pmd-plsql/src/main/java/net/sourceforge/pmd/lang/plsql/rule/design/AbstractNcssCountRule.java b/pmd-plsql/src/main/java/net/sourceforge/pmd/lang/plsql/rule/design/AbstractNcssCountRule.java index 9d8c0c6775..dc3a5eecc3 100644 --- a/pmd-plsql/src/main/java/net/sourceforge/pmd/lang/plsql/rule/design/AbstractNcssCountRule.java +++ b/pmd-plsql/src/main/java/net/sourceforge/pmd/lang/plsql/rule/design/AbstractNcssCountRule.java @@ -53,7 +53,7 @@ public abstract class AbstractNcssCountRule extends Abstrac return 1 + (Integer) node.jjtAccept(new NcssVisitor(), null); } - private static class NcssVisitor extends PLSQLParserVisitorAdapter { + private static final class NcssVisitor extends PLSQLParserVisitorAdapter { @Override public Object visitPlsqlNode(PLSQLNode node, Object data) { diff --git a/pmd-plsql/src/main/java/net/sourceforge/pmd/lang/plsql/rule/design/CyclomaticComplexityRule.java b/pmd-plsql/src/main/java/net/sourceforge/pmd/lang/plsql/rule/design/CyclomaticComplexityRule.java index dc85b93b4a..9721a88152 100644 --- a/pmd-plsql/src/main/java/net/sourceforge/pmd/lang/plsql/rule/design/CyclomaticComplexityRule.java +++ b/pmd-plsql/src/main/java/net/sourceforge/pmd/lang/plsql/rule/design/CyclomaticComplexityRule.java @@ -6,11 +6,11 @@ package net.sourceforge.pmd.lang.plsql.rule.design; import static net.sourceforge.pmd.properties.constraints.NumericConstraints.positive; -import java.util.Stack; +import java.util.ArrayDeque; +import java.util.Deque; import java.util.logging.Level; import java.util.logging.Logger; -import net.sourceforge.pmd.lang.ast.Node; import net.sourceforge.pmd.lang.plsql.ast.ASTCaseStatement; import net.sourceforge.pmd.lang.plsql.ast.ASTCaseWhenClause; import net.sourceforge.pmd.lang.plsql.ast.ASTConditionalOrExpression; @@ -65,16 +65,11 @@ public class CyclomaticComplexityRule extends AbstractPLSQLRule { private boolean showClassesComplexity = true; private boolean showMethodsComplexity = true; - private static class Entry { - private Node node; + private static final class Entry { private int decisionPoints = 1; public int highestDecisionPoints; public int methodCount; - private Entry(Node node) { - this.node = node; - } - public void bumpDecisionPoints() { decisionPoints++; } @@ -88,7 +83,7 @@ public class CyclomaticComplexityRule extends AbstractPLSQLRule { } } - private Stack entryStack = new Stack<>(); + private Deque entryStack = new ArrayDeque<>(); public CyclomaticComplexityRule() { definePropertyDescriptor(REPORT_LEVEL_DESCRIPTOR); @@ -231,7 +226,7 @@ public class CyclomaticComplexityRule extends AbstractPLSQLRule { public Object visit(ASTPackageBody node, Object data) { LOGGER.entering(CLASS_NAME, "visit(ASTPackageBody)"); - entryStack.push(new Entry(node)); + entryStack.push(new Entry()); super.visit(node, data); Entry classEntry = entryStack.pop(); if (LOGGER.isLoggable(Level.FINEST)) { @@ -252,7 +247,7 @@ public class CyclomaticComplexityRule extends AbstractPLSQLRule { public Object visit(ASTTriggerUnit node, Object data) { LOGGER.entering(CLASS_NAME, "visit(ASTTriggerUnit)"); - entryStack.push(new Entry(node)); + entryStack.push(new Entry()); super.visit(node, data); Entry classEntry = entryStack.pop(); if (LOGGER.isLoggable(Level.FINEST)) { @@ -282,7 +277,7 @@ public class CyclomaticComplexityRule extends AbstractPLSQLRule { @Override public Object visit(ASTProgramUnit node, Object data) { LOGGER.entering(CLASS_NAME, "visit(ASTProgramUnit)"); - entryStack.push(new Entry(node)); + entryStack.push(new Entry()); super.visit(node, data); Entry methodEntry = entryStack.pop(); if (LOGGER.isLoggable(Level.FINEST)) { @@ -324,7 +319,7 @@ public class CyclomaticComplexityRule extends AbstractPLSQLRule { @Override public Object visit(ASTTypeMethod node, Object data) { LOGGER.entering(CLASS_NAME, "visit(ASTTypeMethod)"); - entryStack.push(new Entry(node)); + entryStack.push(new Entry()); super.visit(node, data); Entry methodEntry = entryStack.pop(); if (LOGGER.isLoggable(Level.FINEST)) { @@ -357,7 +352,7 @@ public class CyclomaticComplexityRule extends AbstractPLSQLRule { @Override public Object visit(ASTTriggerTimingPointSection node, Object data) { LOGGER.entering(CLASS_NAME, "visit(ASTTriggerTimingPointSection)"); - entryStack.push(new Entry(node)); + entryStack.push(new Entry()); super.visit(node, data); Entry methodEntry = entryStack.pop(); if (LOGGER.isLoggable(Level.FINE)) { diff --git a/pmd-plsql/src/main/java/net/sourceforge/pmd/lang/plsql/symboltable/PLSQLNameOccurrence.java b/pmd-plsql/src/main/java/net/sourceforge/pmd/lang/plsql/symboltable/PLSQLNameOccurrence.java index 4b6c8ce0af..3c8e91390a 100644 --- a/pmd-plsql/src/main/java/net/sourceforge/pmd/lang/plsql/symboltable/PLSQLNameOccurrence.java +++ b/pmd-plsql/src/main/java/net/sourceforge/pmd/lang/plsql/symboltable/PLSQLNameOccurrence.java @@ -85,10 +85,6 @@ public class PLSQLNameOccurrence implements NameOccurrence { * if (isStandAlonePostfix(primaryExpression)) { return true; } */ - if (primaryExpression.getNumChildren() <= 1) { - return false; - } - /* * if (!(primaryExpression.getChild(1) instanceof * ASTAssignmentOperator)) { return false; } @@ -98,7 +94,7 @@ public class PLSQLNameOccurrence implements NameOccurrence { * if (isCompoundAssignment(primaryExpression)) { return false; } */ - return !isPartOfQualifiedName() /* and not is an array type */; + return primaryExpression.getNumChildren() > 1 && !isPartOfQualifiedName() /* and not is an array type */; } /* diff --git a/pmd-plsql/src/main/java/net/sourceforge/pmd/lang/plsql/symboltable/ScopeAndDeclarationFinder.java b/pmd-plsql/src/main/java/net/sourceforge/pmd/lang/plsql/symboltable/ScopeAndDeclarationFinder.java index e22fe60469..3be83e89db 100644 --- a/pmd-plsql/src/main/java/net/sourceforge/pmd/lang/plsql/symboltable/ScopeAndDeclarationFinder.java +++ b/pmd-plsql/src/main/java/net/sourceforge/pmd/lang/plsql/symboltable/ScopeAndDeclarationFinder.java @@ -4,7 +4,8 @@ package net.sourceforge.pmd.lang.plsql.symboltable; -import java.util.Stack; +import java.util.ArrayDeque; +import java.util.Deque; import java.util.logging.Level; import java.util.logging.Logger; @@ -47,7 +48,7 @@ public class ScopeAndDeclarationFinder extends PLSQLParserVisitorAdapter { * A stack of scopes reflecting the scope hierarchy when a node is visited. * This is used to set the parents of the created scopes correctly. */ - private Stack scopes = new Stack<>(); + private Deque scopes = new ArrayDeque<>(); /** * Sets the scope of a node and adjusts the scope stack accordingly. The