fixed sonar rule violations

This commit is contained in:
wenshao
2012-08-29 15:26:59 +08:00
parent a7ae8848fa
commit c96af1628e
9 changed files with 43 additions and 48 deletions
@@ -27,9 +27,7 @@ public class OracleCommitStatement extends OracleStatementImpl {
@Override
public void accept0(OracleASTVisitor visitor) {
if (visitor.visit(this)) {
}
visitor.visit(this);
visitor.endVisit(this);
}
@@ -73,9 +73,9 @@ public class PGExprParser extends SQLExprParser{
over.setOrderBy(parseOrderBy());
if (over.getOrderBy() != null) {
//TODO window
}
// if (over.getOrderBy() != null) {
// //TODO window
// }
accept(Token.RPAREN);
aggregateExpr.setOver(over);
@@ -147,9 +147,6 @@ public class PGSelectParser extends SQLSelectParser {
if (lexer.token() == Token.ROW || lexer.token() == Token.ROWS) {
lexer.nextToken();
} else {
// TODO
// throw new ParserException("expect 'ROW' or 'ROWS'");
}
}
@@ -55,9 +55,8 @@ public class Top extends SQLServerObjectImpl {
@Override
public void accept0(SQLServerASTVisitor visitor) {
if (visitor.visit(this)) {
}
visitor.visit(this);
visitor.endVisit(this);
}
}
@@ -60,9 +60,7 @@ public class SQLServerObjectReferenceExpr extends SQLServerObjectImpl implements
@Override
public void accept0(SQLServerASTVisitor visitor) {
if (visitor.visit(this)) {
}
visitor.visit(this);
visitor.endVisit(this);
}
@@ -15,7 +15,6 @@
*/
package com.alibaba.druid.sql.parser;
import com.alibaba.druid.sql.ast.SQLName;
import com.alibaba.druid.sql.ast.statement.SQLTableConstaint;
public class SQLDDLParser extends SQLStatementParser {
@@ -29,13 +28,13 @@ public class SQLDDLParser extends SQLStatementParser {
}
protected SQLTableConstaint parseConstraint() {
SQLName name = null;
if (lexer.token() == Token.CONSTRAINT) {
lexer.nextToken();
}
if (lexer.token() == Token.IDENTIFIER) {
name = this.exprParser.name();
this.exprParser.name();
throw new ParserException("TODO");
}
if (lexer.token() == Token.PRIMARY) {
@@ -45,10 +44,6 @@ public class SQLDDLParser extends SQLStatementParser {
throw new ParserException("TODO");
}
if (name != null) {
}
throw new ParserException("TODO");
}
}
@@ -126,7 +126,7 @@ public class MySqlWallVisitor extends MySqlASTVisitorAdapter implements WallVisi
WallVisitorUtils.checkDelete(this, x);
return true;
}
@Override
public boolean visit(MySqlUpdateStatement x) {
return visit((SQLUpdateStatement) x);
@@ -241,21 +241,22 @@ public class MySqlWallVisitor extends MySqlASTVisitorAdapter implements WallVisi
return;
}
boolean allow = false;
if (x instanceof SQLInsertStatement) {
allow = true;
} else if (x instanceof SQLSelectStatement) {
allow = true;
} else if (x instanceof SQLDeleteStatement) {
allow = true;
} else if (x instanceof SQLUpdateStatement) {
allow = true;
} else if (x instanceof SQLCallStatement) {
allow = true;
} else if (x instanceof SQLTruncateStatement) {
if (!config.isTruncateAllow()) {
violations.add(new IllegalSQLObjectViolation(toSQL(x)));
}
} else {
allow = config.isTruncateAllow();
}
if (!allow) {
violations.add(new IllegalSQLObjectViolation(toSQL(x)));
}
}
@@ -174,21 +174,26 @@ public class OracleWallVisitor extends OracleASTVisitorAdapter implements WallVi
return;
}
boolean allow = false;
if (x instanceof SQLInsertStatement) {
allow = true;
} else if (x instanceof SQLSelectStatement) {
allow = true;
} else if (x instanceof SQLDeleteStatement) {
allow = true;
} else if (x instanceof SQLUpdateStatement) {
allow = true;
} else if (x instanceof OracleMultiInsertStatement) {
allow = true;
} else if (x instanceof OracleMergeStatement) {
allow = true;
} else if (x instanceof SQLCallStatement) {
allow = true;
} else if (x instanceof SQLTruncateStatement) {
if (!config.isTruncateAllow()) {
violations.add(new IllegalSQLObjectViolation(toSQL(x)));
}
} else {
allow = config.isTruncateAllow();
}
if (!allow) {
violations.add(new IllegalSQLObjectViolation(toSQL(x)));
}
}
@@ -53,7 +53,7 @@ public class SQLServerWallVisitor extends SQLServerASTVisitorAdapter implements
private final WallProvider provider;
private final List<Violation> violations = new ArrayList<Violation>();
public SQLServerWallVisitor(WallProvider provider) {
public SQLServerWallVisitor(WallProvider provider){
this.config = provider.getConfig();
this.provider = provider;
}
@@ -156,20 +156,22 @@ public class SQLServerWallVisitor extends SQLServerASTVisitorAdapter implements
return;
}
boolean allow = false;
if (x instanceof SQLInsertStatement) {
allow = true;
} else if (x instanceof SQLSelectStatement) {
allow = true;
} else if (x instanceof SQLDeleteStatement) {
allow = true;
} else if (x instanceof SQLUpdateStatement) {
allow = true;
} else if (x instanceof SQLCallStatement) {
allow = true;
} else if (x instanceof SQLTruncateStatement) {
if (!config.isTruncateAllow()) {
violations.add(new IllegalSQLObjectViolation(toSQL(x)));
}
} else {
allow = config.isTruncateAllow();
}
if (!allow) {
violations.add(new IllegalSQLObjectViolation(toSQL(x)));
}
}