优化:增加判断方式

wuhaoyang
RenFengJiang 8 months ago
parent 9f5710ea29
commit a6bac91163
  1. 10
      sonar-keyware-plugins-cxx/src/main/java/com/keyware/sonar/cxx/rules/checkers/CmdDataVerifyChecker.java
  2. 9
      sonar-keyware-plugins-cxx/src/main/java/com/keyware/sonar/cxx/rules/checkers/SQLVerifyChecker.java

@ -76,11 +76,13 @@ public class CmdDataVerifyChecker extends SquidCheck<Grammar> {
for (AstNode expr:astNodeList) { for (AstNode expr:astNodeList) {
lists.add(expr.getToken().getValue()); lists.add(expr.getToken().getValue());
} }
if(astNodeList.size() == 0){ if(astNodeList.size() == 0){
List<AstNode> descendants = astNode.getDescendants(CxxGrammarImpl.condition); List<AstNode> astNodes = astNode.getDescendants(CxxGrammarImpl.relationalExpression);
for (AstNode desc:descendants) { for (AstNode as:astNodes) {
lists.add(desc.getToken().getValue()); List<AstNode> children = as.getChildren();
for (AstNode chil:children) {
lists.add(chil.getTokenValue());
}
} }
} }
} }

@ -77,9 +77,12 @@ public class SQLVerifyChecker extends SquidCheck<Grammar> {
lists.add(expr.getToken().getValue()); lists.add(expr.getToken().getValue());
} }
if(astNodeList.size() == 0){ if(astNodeList.size() == 0){
List<AstNode> descendants = astNode.getDescendants(CxxGrammarImpl.condition); List<AstNode> astNodes = astNode.getDescendants(CxxGrammarImpl.relationalExpression);
for (AstNode desc:descendants) { for (AstNode as:astNodes) {
lists.add(desc.getToken().getValue()); List<AstNode> children = as.getChildren();
for (AstNode chil:children) {
lists.add(chil.getTokenValue());
}
} }
} }
} }

Loading…
Cancel
Save