mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
fixed sonar rule violations
This commit is contained in:
@@ -50,8 +50,9 @@ public class SQLBetweenExpr extends SQLExprImpl implements Serializable {
|
||||
|
||||
public void output(StringBuffer buf) {
|
||||
this.testExpr.output(buf);
|
||||
if (this.not) buf.append(" NOT BETWEEN ");
|
||||
else {
|
||||
if (this.not) {
|
||||
buf.append(" NOT BETWEEN ");
|
||||
} else {
|
||||
buf.append(" BETWEEN ");
|
||||
}
|
||||
this.beginExpr.output(buf);
|
||||
|
||||
@@ -72,8 +72,9 @@ public class SQLInListExpr extends SQLExprImpl implements Serializable {
|
||||
public void output(StringBuffer buf) {
|
||||
this.expr.output(buf);
|
||||
|
||||
if (this.not) buf.append("NOT IN ");
|
||||
else {
|
||||
if (this.not) {
|
||||
buf.append("NOT IN ");
|
||||
} else {
|
||||
buf.append("IN ");
|
||||
}
|
||||
|
||||
|
||||
@@ -100,9 +100,11 @@ public class SQLSelectQueryBlock extends SQLSelectQuery {
|
||||
public void output(StringBuffer buf) {
|
||||
buf.append("SELECT ");
|
||||
|
||||
if (SQLSetQuantifier.ALL == this.distionOption) buf.append("ALL ");
|
||||
else if (SQLSetQuantifier.DISTINCT == this.distionOption) buf.append("DISTINCT ");
|
||||
else if (SQLSetQuantifier.UNIQUE == this.distionOption) {
|
||||
if (SQLSetQuantifier.ALL == this.distionOption) {
|
||||
buf.append("ALL ");
|
||||
} else if (SQLSetQuantifier.DISTINCT == this.distionOption) {
|
||||
buf.append("DISTINCT ");
|
||||
} else if (SQLSetQuantifier.UNIQUE == this.distionOption) {
|
||||
buf.append("UNIQUE ");
|
||||
}
|
||||
|
||||
|
||||
@@ -170,9 +170,11 @@ public class MySqlOutputVisitor extends SQLASTOutputVisitor implements MySqlASTV
|
||||
print(' ');
|
||||
}
|
||||
|
||||
if (SQLSetQuantifier.ALL == x.getDistionOption()) print("ALL ");
|
||||
else if (SQLSetQuantifier.DISTINCT == x.getDistionOption()) print("DISTINCT ");
|
||||
else if (SQLSetQuantifier.DISTINCTROW == x.getDistionOption()) {
|
||||
if (SQLSetQuantifier.ALL == x.getDistionOption()) {
|
||||
print("ALL ");
|
||||
} else if (SQLSetQuantifier.DISTINCT == x.getDistionOption()) {
|
||||
print("DISTINCT ");
|
||||
} else if (SQLSetQuantifier.DISTINCTROW == x.getDistionOption()) {
|
||||
print("DISTINCTROW ");
|
||||
}
|
||||
|
||||
@@ -495,7 +497,8 @@ public class MySqlOutputVisitor extends SQLASTOutputVisitor implements MySqlASTV
|
||||
print("@@global.");
|
||||
} else {
|
||||
String varName = x.getName();
|
||||
if ((!varName.startsWith("@")) && (!varName.equals("?")) && (!varName.startsWith("#")) && (!varName.startsWith("$"))) {
|
||||
if ((!varName.startsWith("@")) && (!varName.equals("?")) && (!varName.startsWith("#"))
|
||||
&& (!varName.startsWith("$"))) {
|
||||
print("@@");
|
||||
}
|
||||
}
|
||||
@@ -2568,7 +2571,7 @@ public class MySqlOutputVisitor extends SQLASTOutputVisitor implements MySqlASTV
|
||||
public void endVisit(MySqlAlterTableAddIndex x) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean visit(MySqlAlterTableAddUnique x) {
|
||||
print("ADD ");
|
||||
@@ -2576,9 +2579,9 @@ public class MySqlOutputVisitor extends SQLASTOutputVisitor implements MySqlASTV
|
||||
print(x.getType());
|
||||
print(" ");
|
||||
}
|
||||
|
||||
|
||||
print("UNIQUE ");
|
||||
|
||||
|
||||
if (x.getName() != null) {
|
||||
x.getName().accept(this);
|
||||
print(' ');
|
||||
@@ -2586,17 +2589,17 @@ public class MySqlOutputVisitor extends SQLASTOutputVisitor implements MySqlASTV
|
||||
print("(");
|
||||
printAndAccept(x.getItems(), ", ");
|
||||
print(")");
|
||||
|
||||
|
||||
if (x.getUsing() != null) {
|
||||
print(" USING ");
|
||||
print(x.getUsing());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void endVisit(MySqlAlterTableAddUnique x) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -35,8 +35,11 @@ public abstract class OracleConstraint extends OracleSQLObjectImpl {
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
if (name == null) this.name = null;
|
||||
else this.name = new SQLIdentifierExpr(name);
|
||||
if (name == null) {
|
||||
this.name = null;
|
||||
} else {
|
||||
this.name = new SQLIdentifierExpr(name);
|
||||
}
|
||||
}
|
||||
|
||||
public void setName(SQLName name) {
|
||||
|
||||
+6
-4
@@ -30,7 +30,7 @@ public class OracleSelectQueryBlock extends SQLSelectQueryBlock {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private final List<SQLCommentHint> hints = new ArrayList<SQLCommentHint>(1);
|
||||
private final List<SQLCommentHint> hints = new ArrayList<SQLCommentHint>(1);
|
||||
|
||||
private OracleSelectHierachicalQueryClause hierachicalQueryClause;
|
||||
private ModelClause modelClause;
|
||||
@@ -93,9 +93,11 @@ public class OracleSelectQueryBlock extends SQLSelectQueryBlock {
|
||||
public void output(StringBuffer buf) {
|
||||
buf.append("SELECT ");
|
||||
|
||||
if (SQLSetQuantifier.ALL == this.distionOption) buf.append("ALL ");
|
||||
else if (SQLSetQuantifier.DISTINCT == this.distionOption) buf.append("DISTINCT ");
|
||||
else if (SQLSetQuantifier.UNIQUE == this.distionOption) {
|
||||
if (SQLSetQuantifier.ALL == this.distionOption) {
|
||||
buf.append("ALL ");
|
||||
} else if (SQLSetQuantifier.DISTINCT == this.distionOption) {
|
||||
buf.append("DISTINCT ");
|
||||
} else if (SQLSetQuantifier.UNIQUE == this.distionOption) {
|
||||
buf.append("UNIQUE ");
|
||||
}
|
||||
|
||||
|
||||
@@ -72,7 +72,7 @@ import com.alibaba.druid.sql.parser.Token;
|
||||
public class OracleSelectParser extends SQLSelectParser {
|
||||
|
||||
public OracleSelectParser(String sql){
|
||||
super (new OracleExprParser(sql));
|
||||
super(new OracleExprParser(sql));
|
||||
}
|
||||
|
||||
public OracleSelectParser(SQLExprParser exprParser){
|
||||
@@ -194,8 +194,9 @@ public class OracleSelectParser extends SQLSelectParser {
|
||||
if (identifierEquals("READ")) {
|
||||
lexer.nextToken();
|
||||
|
||||
if (identifierEquals("ONLY")) lexer.nextToken();
|
||||
else {
|
||||
if (identifierEquals("ONLY")) {
|
||||
lexer.nextToken();
|
||||
} else {
|
||||
throw new ParserException("syntax error");
|
||||
}
|
||||
|
||||
@@ -203,8 +204,9 @@ public class OracleSelectParser extends SQLSelectParser {
|
||||
} else if (lexer.token() == (Token.CHECK)) {
|
||||
lexer.nextToken();
|
||||
|
||||
if (identifierEquals("OPTION")) lexer.nextToken();
|
||||
else {
|
||||
if (identifierEquals("OPTION")) {
|
||||
lexer.nextToken();
|
||||
} else {
|
||||
throw new ParserException("syntax error");
|
||||
}
|
||||
|
||||
@@ -348,7 +350,6 @@ public class OracleSelectParser extends SQLSelectParser {
|
||||
model.setReturnRowsClause(returnRowsClause);
|
||||
}
|
||||
|
||||
|
||||
while (identifierEquals("REFERENCE")) {
|
||||
ReferenceModelClause referenceModelClause = new ReferenceModelClause();
|
||||
lexer.nextToken();
|
||||
|
||||
@@ -245,7 +245,7 @@ public class SQLASTOutputVisitor extends SQLASTVisitorAdapter {
|
||||
for (int i = groupList.size() - 1; i >= 0; --i) {
|
||||
SQLExpr item = groupList.get(i);
|
||||
visitBinaryLeft(item, x.getOperator());
|
||||
|
||||
|
||||
if (relational) {
|
||||
println();
|
||||
} else {
|
||||
@@ -255,7 +255,6 @@ public class SQLASTOutputVisitor extends SQLASTVisitorAdapter {
|
||||
print(" ");
|
||||
}
|
||||
|
||||
|
||||
visitorBinaryRight(x);
|
||||
|
||||
if (isRoot && relational) {
|
||||
@@ -376,8 +375,9 @@ public class SQLASTOutputVisitor extends SQLASTVisitorAdapter {
|
||||
}
|
||||
|
||||
public boolean visit(SQLExistsExpr x) {
|
||||
if (x.isNot()) print("NOT EXISTS (");
|
||||
else {
|
||||
if (x.isNot()) {
|
||||
print("NOT EXISTS (");
|
||||
} else {
|
||||
print("EXISTS (");
|
||||
}
|
||||
incrementIndent();
|
||||
@@ -426,12 +426,12 @@ public class SQLASTOutputVisitor extends SQLASTVisitorAdapter {
|
||||
public boolean visit(SQLAggregateExpr x) {
|
||||
print(x.getMethodName());
|
||||
print("(");
|
||||
|
||||
|
||||
if (x.getOption() != null) {
|
||||
print(x.getOption().toString());
|
||||
print(' ');
|
||||
}
|
||||
|
||||
|
||||
printAndAccept(x.getArguments(), ", ");
|
||||
print(")");
|
||||
return false;
|
||||
@@ -1123,7 +1123,7 @@ public class SQLASTOutputVisitor extends SQLASTVisitorAdapter {
|
||||
print("*/");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean visit(SQLCreateDatabaseStatement x) {
|
||||
print("CREATE DATABASE ");
|
||||
|
||||
Reference in New Issue
Block a user