mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
fix sonar rule check violations
This commit is contained in:
@@ -16,12 +16,11 @@
|
||||
package com.alibaba.druid.sql.dialect.hive.parser;
|
||||
|
||||
import com.alibaba.druid.sql.parser.Lexer;
|
||||
import com.alibaba.druid.sql.parser.ParserException;
|
||||
import com.alibaba.druid.sql.parser.SQLExprParser;
|
||||
|
||||
|
||||
public class HiveExprParser extends SQLExprParser {
|
||||
public HiveExprParser(String sql) throws ParserException{
|
||||
public HiveExprParser(String sql) {
|
||||
super(new HiveLexer(sql));
|
||||
this.lexer.nextToken();
|
||||
}
|
||||
|
||||
+4
-4
@@ -32,7 +32,7 @@ import com.alibaba.druid.sql.parser.Token;
|
||||
|
||||
public class MySqlCreateTableParser extends SQLCreateTableParser {
|
||||
|
||||
public MySqlCreateTableParser(String sql) throws ParserException{
|
||||
public MySqlCreateTableParser(String sql) {
|
||||
super(new MySqlExprParser(sql));
|
||||
}
|
||||
|
||||
@@ -40,11 +40,11 @@ public class MySqlCreateTableParser extends SQLCreateTableParser {
|
||||
super(exprParser);
|
||||
}
|
||||
|
||||
public SQLCreateTableStatement parseCrateTable() throws ParserException {
|
||||
public SQLCreateTableStatement parseCrateTable() {
|
||||
return parseCrateTable(true);
|
||||
}
|
||||
|
||||
public MySqlCreateTableStatement parseCrateTable(boolean acceptCreate) throws ParserException {
|
||||
public MySqlCreateTableStatement parseCrateTable(boolean acceptCreate) {
|
||||
if (acceptCreate) {
|
||||
accept(Token.CREATE);
|
||||
}
|
||||
@@ -182,7 +182,7 @@ public class MySqlCreateTableParser extends SQLCreateTableParser {
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
protected SQLTableConstaint parseConstraint() throws ParserException {
|
||||
protected SQLTableConstaint parseConstraint() {
|
||||
SQLName name = null;
|
||||
if (lexer.token() == (Token.CONSTRAINT)) {
|
||||
lexer.nextToken();
|
||||
|
||||
@@ -52,12 +52,12 @@ public class MySqlExprParser extends SQLExprParser {
|
||||
super(lexer);
|
||||
}
|
||||
|
||||
public MySqlExprParser(String sql) throws ParserException{
|
||||
public MySqlExprParser(String sql) {
|
||||
this(new MySqlLexer(sql));
|
||||
this.lexer.nextToken();
|
||||
}
|
||||
|
||||
public SQLExpr relationalRest(SQLExpr expr) throws ParserException {
|
||||
public SQLExpr relationalRest(SQLExpr expr) {
|
||||
if (identifierEquals("REGEXP")) {
|
||||
lexer.nextToken();
|
||||
SQLExpr rightExp = equality();
|
||||
@@ -79,7 +79,7 @@ public class MySqlExprParser extends SQLExprParser {
|
||||
return super.relationalRest(expr);
|
||||
}
|
||||
|
||||
public SQLExpr multiplicativeRest(SQLExpr expr) throws ParserException {
|
||||
public SQLExpr multiplicativeRest(SQLExpr expr) {
|
||||
if (lexer.token() == Token.IDENTIFIER && "MOD".equalsIgnoreCase(lexer.stringVal())) {
|
||||
lexer.nextToken();
|
||||
SQLExpr rightExp = primary();
|
||||
@@ -114,7 +114,7 @@ public class MySqlExprParser extends SQLExprParser {
|
||||
return super.notRationalRest(expr);
|
||||
}
|
||||
|
||||
public SQLExpr primary() throws ParserException {
|
||||
public SQLExpr primary() {
|
||||
final Token tok = lexer.token();
|
||||
|
||||
if (identifierEquals("outfile")) {
|
||||
@@ -158,7 +158,7 @@ public class MySqlExprParser extends SQLExprParser {
|
||||
|
||||
}
|
||||
|
||||
public final SQLExpr primaryRest(SQLExpr expr) throws ParserException {
|
||||
public final SQLExpr primaryRest(SQLExpr expr) {
|
||||
if (expr == null) {
|
||||
throw new IllegalArgumentException("expr");
|
||||
}
|
||||
@@ -489,7 +489,7 @@ public class MySqlExprParser extends SQLExprParser {
|
||||
}
|
||||
}
|
||||
|
||||
public SQLColumnDefinition parseColumn() throws ParserException {
|
||||
public SQLColumnDefinition parseColumn() {
|
||||
MySqlSQLColumnDefinition column = new MySqlSQLColumnDefinition();
|
||||
column.setName(name());
|
||||
column.setDataType(parseDataType());
|
||||
@@ -497,7 +497,7 @@ public class MySqlExprParser extends SQLExprParser {
|
||||
return parseColumnRest(column);
|
||||
}
|
||||
|
||||
public SQLColumnDefinition parseColumnRest(SQLColumnDefinition column) throws ParserException {
|
||||
public SQLColumnDefinition parseColumnRest(SQLColumnDefinition column) {
|
||||
if (identifierEquals("AUTO_INCREMENT")) {
|
||||
lexer.nextToken();
|
||||
if (column instanceof MySqlSQLColumnDefinition) {
|
||||
@@ -514,7 +514,7 @@ public class MySqlExprParser extends SQLExprParser {
|
||||
return column;
|
||||
}
|
||||
|
||||
public SQLExpr orRest(SQLExpr expr) throws ParserException {
|
||||
public SQLExpr orRest(SQLExpr expr) {
|
||||
|
||||
for (;;) {
|
||||
if (lexer.token() == Token.OR || lexer.token() == Token.BARBAR) {
|
||||
@@ -566,7 +566,7 @@ public class MySqlExprParser extends SQLExprParser {
|
||||
return item;
|
||||
}
|
||||
|
||||
public SQLName nameRest(SQLName name) throws ParserException {
|
||||
public SQLName nameRest(SQLName name) {
|
||||
if (lexer.token() == Token.VARIANT && "@".equals(lexer.stringVal())) {
|
||||
lexer.nextToken();
|
||||
MySqlUserName userName = new MySqlUserName();
|
||||
|
||||
@@ -44,12 +44,12 @@ public class MySqlSelectParser extends SQLSelectParser {
|
||||
super(exprParser);
|
||||
}
|
||||
|
||||
public MySqlSelectParser(String sql) throws ParserException{
|
||||
public MySqlSelectParser(String sql) {
|
||||
this(new MySqlExprParser(sql));
|
||||
}
|
||||
|
||||
@Override
|
||||
public SQLSelectQuery query() throws ParserException {
|
||||
public SQLSelectQuery query() {
|
||||
if (lexer.token() == (Token.LPAREN)) {
|
||||
lexer.nextToken();
|
||||
|
||||
@@ -220,7 +220,7 @@ public class MySqlSelectParser extends SQLSelectParser {
|
||||
return queryRest(queryBlock);
|
||||
}
|
||||
|
||||
protected void parseGroupBy(SQLSelectQueryBlock queryBlock) throws ParserException {
|
||||
protected void parseGroupBy(SQLSelectQueryBlock queryBlock) {
|
||||
if (lexer.token() == (Token.GROUP)) {
|
||||
lexer.nextToken();
|
||||
accept(Token.BY);
|
||||
@@ -255,7 +255,7 @@ public class MySqlSelectParser extends SQLSelectParser {
|
||||
}
|
||||
}
|
||||
|
||||
protected SQLTableSource parseTableSourceRest(SQLTableSource tableSource) throws ParserException {
|
||||
protected SQLTableSource parseTableSourceRest(SQLTableSource tableSource) {
|
||||
if (identifierEquals("USING")) {
|
||||
return tableSource;
|
||||
}
|
||||
|
||||
@@ -144,7 +144,7 @@ public class MySqlStatementParser extends SQLStatementParser {
|
||||
private static final String DELAYED = "DELAYED";
|
||||
private static final String LOW_PRIORITY = "LOW_PRIORITY";
|
||||
|
||||
public MySqlStatementParser(String sql) throws ParserException{
|
||||
public MySqlStatementParser(String sql) {
|
||||
super(new MySqlExprParser(sql));
|
||||
}
|
||||
|
||||
|
||||
@@ -91,7 +91,7 @@ public class OracleExprParser extends SQLExprParser {
|
||||
this.lexer.nextToken();
|
||||
}
|
||||
|
||||
public SQLDataType parseDataType() throws ParserException {
|
||||
public SQLDataType parseDataType() {
|
||||
|
||||
if (lexer.token() == Token.DEFAULT || lexer.token() == Token.NOT || lexer.token() == Token.NULL) {
|
||||
return null;
|
||||
@@ -127,7 +127,7 @@ public class OracleExprParser extends SQLExprParser {
|
||||
return false;
|
||||
}
|
||||
|
||||
public SQLExpr primary() throws ParserException {
|
||||
public SQLExpr primary() {
|
||||
final Token tok = lexer.token();
|
||||
|
||||
SQLExpr sqlExpr = null;
|
||||
@@ -302,7 +302,7 @@ public class OracleExprParser extends SQLExprParser {
|
||||
return super.methodRest(expr, false);
|
||||
}
|
||||
|
||||
public SQLExpr primaryRest(SQLExpr expr) throws ParserException {
|
||||
public SQLExpr primaryRest(SQLExpr expr) {
|
||||
if (lexer.token() == Token.IDENTIFIER && expr instanceof SQLNumericLiteralExpr) {
|
||||
String ident = lexer.stringVal();
|
||||
if (ident.length() == 1) {
|
||||
@@ -729,7 +729,7 @@ public class OracleExprParser extends SQLExprParser {
|
||||
return interval;
|
||||
}
|
||||
|
||||
public SQLExpr relationalRest(SQLExpr expr) throws ParserException {
|
||||
public SQLExpr relationalRest(SQLExpr expr) {
|
||||
if (lexer.token() == Token.IS) {
|
||||
lexer.nextToken();
|
||||
|
||||
@@ -752,7 +752,7 @@ public class OracleExprParser extends SQLExprParser {
|
||||
}
|
||||
|
||||
|
||||
public SQLName name() throws ParserException {
|
||||
public SQLName name() {
|
||||
SQLName name = super.name();
|
||||
|
||||
if (lexer.token() == Token.MONKEYS_AT) {
|
||||
@@ -770,7 +770,7 @@ public class OracleExprParser extends SQLExprParser {
|
||||
return name;
|
||||
}
|
||||
|
||||
public SQLExpr equalityRest(SQLExpr expr) throws ParserException {
|
||||
public SQLExpr equalityRest(SQLExpr expr) {
|
||||
SQLExpr rightExp;
|
||||
if (lexer.token() == Token.EQ) {
|
||||
lexer.nextToken();
|
||||
@@ -828,7 +828,7 @@ public class OracleExprParser extends SQLExprParser {
|
||||
return column;
|
||||
}
|
||||
|
||||
public SQLExpr exprRest(SQLExpr expr) throws ParserException {
|
||||
public SQLExpr exprRest(SQLExpr expr) {
|
||||
expr = super.exprRest(expr);
|
||||
|
||||
if (lexer.token() == Token.COLONEQ) {
|
||||
|
||||
@@ -620,7 +620,7 @@ public class OracleSelectParser extends SQLSelectParser {
|
||||
}
|
||||
}
|
||||
|
||||
protected String as() throws ParserException {
|
||||
protected String as() {
|
||||
if (lexer.token() == Token.CONNECT) {
|
||||
return null;
|
||||
}
|
||||
|
||||
+5
-5
@@ -130,11 +130,11 @@ public class OracleStatementParser extends SQLStatementParser {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void parseStatementList(List<SQLStatement> statementList) throws ParserException {
|
||||
public void parseStatementList(List<SQLStatement> statementList) {
|
||||
parseStatementList(statementList, -1);
|
||||
}
|
||||
|
||||
public void parseStatementList(List<SQLStatement> statementList, int max) throws ParserException {
|
||||
public void parseStatementList(List<SQLStatement> statementList, int max) {
|
||||
for (;;) {
|
||||
if (max != -1) {
|
||||
if (statementList.size() >= max) {
|
||||
@@ -1106,7 +1106,7 @@ public class OracleStatementParser extends SQLStatementParser {
|
||||
return new OracleSelectParser(this.exprParser);
|
||||
}
|
||||
|
||||
public OracleMergeStatement parseMerge() throws ParserException {
|
||||
public OracleMergeStatement parseMerge() {
|
||||
accept(Token.MERGE);
|
||||
|
||||
OracleMergeStatement stmt = new OracleMergeStatement();
|
||||
@@ -1410,7 +1410,7 @@ public class OracleStatementParser extends SQLStatementParser {
|
||||
return stmt;
|
||||
}
|
||||
|
||||
public OracleDeleteStatement parseDeleteStatement() throws ParserException {
|
||||
public OracleDeleteStatement parseDeleteStatement() {
|
||||
OracleDeleteStatement deleteStatement = new OracleDeleteStatement();
|
||||
|
||||
if (lexer.token() == Token.DELETE) {
|
||||
@@ -1595,7 +1595,7 @@ public class OracleStatementParser extends SQLStatementParser {
|
||||
return stmt;
|
||||
}
|
||||
|
||||
public SQLUpdateStatement parseUpdateStatement() throws ParserException {
|
||||
public SQLUpdateStatement parseUpdateStatement() {
|
||||
return new OracleUpdateParser(this.lexer).parseUpdateStatement();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ import com.alibaba.druid.sql.parser.Token;
|
||||
|
||||
public class OracleUpdateParser extends SQLStatementParser {
|
||||
|
||||
public OracleUpdateParser(String sql) throws ParserException{
|
||||
public OracleUpdateParser(String sql) {
|
||||
super(new OracleExprParser(sql));
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ public class OracleUpdateParser extends SQLStatementParser {
|
||||
super(new OracleExprParser(lexer));
|
||||
}
|
||||
|
||||
public OracleUpdateStatement parseUpdateStatement() throws ParserException {
|
||||
public OracleUpdateStatement parseUpdateStatement() {
|
||||
OracleUpdateStatement update = new OracleUpdateStatement();
|
||||
|
||||
if (lexer.token() == Token.UPDATE) {
|
||||
@@ -66,13 +66,13 @@ public class OracleUpdateParser extends SQLStatementParser {
|
||||
return update;
|
||||
}
|
||||
|
||||
private void parseErrorLoging(OracleUpdateStatement update) throws ParserException {
|
||||
private void parseErrorLoging(OracleUpdateStatement update) {
|
||||
if (identifierEquals("LOG")) {
|
||||
throw new ParserException("TODO");
|
||||
}
|
||||
}
|
||||
|
||||
private void parseReturn(OracleUpdateStatement update) throws ParserException {
|
||||
private void parseReturn(OracleUpdateStatement update) {
|
||||
if (identifierEquals("RETURN") || lexer.token() == Token.RETURNING) {
|
||||
lexer.nextToken();
|
||||
|
||||
@@ -104,20 +104,20 @@ public class OracleUpdateParser extends SQLStatementParser {
|
||||
}
|
||||
}
|
||||
|
||||
private void parseHints(OracleUpdateStatement update) throws ParserException {
|
||||
private void parseHints(OracleUpdateStatement update) {
|
||||
if (lexer.token() == Token.HINT) {
|
||||
throw new ParserException("TODO");
|
||||
}
|
||||
}
|
||||
|
||||
private void parseWhere(OracleUpdateStatement update) throws ParserException {
|
||||
private void parseWhere(OracleUpdateStatement update) {
|
||||
if (lexer.token() == (Token.WHERE)) {
|
||||
lexer.nextToken();
|
||||
update.setWhere(this.exprParser.expr());
|
||||
}
|
||||
}
|
||||
|
||||
private void parseSet(OracleUpdateStatement update) throws ParserException {
|
||||
private void parseSet(OracleUpdateStatement update) {
|
||||
accept(Token.SET);
|
||||
|
||||
for (;;) {
|
||||
|
||||
@@ -20,12 +20,11 @@ import com.alibaba.druid.sql.dialect.postgresql.ast.PGAggregateExpr;
|
||||
import com.alibaba.druid.sql.dialect.postgresql.ast.PGOrderBy;
|
||||
import com.alibaba.druid.sql.dialect.postgresql.ast.expr.PGAnalytic;
|
||||
import com.alibaba.druid.sql.parser.Lexer;
|
||||
import com.alibaba.druid.sql.parser.ParserException;
|
||||
import com.alibaba.druid.sql.parser.SQLExprParser;
|
||||
import com.alibaba.druid.sql.parser.Token;
|
||||
|
||||
public class PGExprParser extends SQLExprParser{
|
||||
public PGExprParser(String sql) throws ParserException{
|
||||
public PGExprParser(String sql) {
|
||||
super(new PGLexer(sql));
|
||||
this.lexer.nextToken();
|
||||
}
|
||||
@@ -34,7 +33,7 @@ public class PGExprParser extends SQLExprParser{
|
||||
super(lexer);
|
||||
}
|
||||
|
||||
protected SQLAggregateExpr parseAggregateExpr(String methodName) throws ParserException {
|
||||
protected SQLAggregateExpr parseAggregateExpr(String methodName) {
|
||||
methodName = methodName.toUpperCase();
|
||||
|
||||
PGAggregateExpr aggregateExpr;
|
||||
|
||||
+4
-4
@@ -40,7 +40,7 @@ import com.alibaba.druid.sql.parser.Token;
|
||||
|
||||
public class PGSQLStatementParser extends SQLStatementParser {
|
||||
|
||||
public PGSQLStatementParser(String sql) throws ParserException{
|
||||
public PGSQLStatementParser(String sql) {
|
||||
super (new PGExprParser(sql));
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ public class PGSQLStatementParser extends SQLStatementParser {
|
||||
return new PGSelectParser(this.exprParser);
|
||||
}
|
||||
|
||||
public SQLUpdateStatement parseUpdateStatement() throws ParserException {
|
||||
public SQLUpdateStatement parseUpdateStatement() {
|
||||
accept(Token.UPDATE);
|
||||
|
||||
PGUpdateStatement udpateStatement = new PGUpdateStatement();
|
||||
@@ -150,7 +150,7 @@ public class PGSQLStatementParser extends SQLStatementParser {
|
||||
return stmt;
|
||||
}
|
||||
|
||||
public PGDeleteStatement parseDeleteStatement() throws ParserException {
|
||||
public PGDeleteStatement parseDeleteStatement() {
|
||||
lexer.nextToken();
|
||||
PGDeleteStatement deleteStatement = new PGDeleteStatement();
|
||||
|
||||
@@ -329,7 +329,7 @@ public class PGSQLStatementParser extends SQLStatementParser {
|
||||
return withQuery;
|
||||
}
|
||||
|
||||
public PGSelectStatement parseSelect() throws ParserException {
|
||||
public PGSelectStatement parseSelect() {
|
||||
return new PGSelectStatement(createSQLSelectParser().select());
|
||||
}
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ public class PGSelectParser extends SQLSelectParser {
|
||||
super(exprParser);
|
||||
}
|
||||
|
||||
public PGSelectParser(String sql) throws ParserException{
|
||||
public PGSelectParser(String sql) {
|
||||
this(new PGExprParser(sql));
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ public class PGSelectParser extends SQLSelectParser {
|
||||
}
|
||||
|
||||
@Override
|
||||
public SQLSelectQuery query() throws ParserException {
|
||||
public SQLSelectQuery query() {
|
||||
PGSelectQueryBlock queryBlock = new PGSelectQueryBlock();
|
||||
|
||||
if (lexer.token() == Token.SELECT) {
|
||||
@@ -219,7 +219,7 @@ public class PGSelectParser extends SQLSelectParser {
|
||||
return queryRest(queryBlock);
|
||||
}
|
||||
|
||||
protected SQLTableSource parseTableSourceRest(SQLTableSource tableSource) throws ParserException {
|
||||
protected SQLTableSource parseTableSourceRest(SQLTableSource tableSource) {
|
||||
if (lexer.token() == Token.AS && tableSource instanceof SQLExprTableSource) {
|
||||
String alias = this.as();
|
||||
|
||||
|
||||
+3
-4
@@ -20,7 +20,6 @@ import com.alibaba.druid.sql.ast.SQLName;
|
||||
import com.alibaba.druid.sql.ast.expr.SQLPropertyExpr;
|
||||
import com.alibaba.druid.sql.dialect.sqlserver.ast.expr.SQLServerObjectReferenceExpr;
|
||||
import com.alibaba.druid.sql.parser.Lexer;
|
||||
import com.alibaba.druid.sql.parser.ParserException;
|
||||
import com.alibaba.druid.sql.parser.SQLExprParser;
|
||||
import com.alibaba.druid.sql.parser.Token;
|
||||
|
||||
@@ -30,12 +29,12 @@ public class SQLServerExprParser extends SQLExprParser {
|
||||
super(lexer);
|
||||
}
|
||||
|
||||
public SQLServerExprParser(String sql) throws ParserException{
|
||||
public SQLServerExprParser(String sql) {
|
||||
super(new SQLServerLexer(sql));
|
||||
this.lexer.nextToken();
|
||||
}
|
||||
|
||||
public SQLExpr primaryRest(SQLExpr expr) throws ParserException {
|
||||
public SQLExpr primaryRest(SQLExpr expr) {
|
||||
if (lexer.token() == Token.DOTDOT) {
|
||||
expr = nameRest((SQLName) expr);
|
||||
}
|
||||
@@ -43,7 +42,7 @@ public class SQLServerExprParser extends SQLExprParser {
|
||||
return super.primaryRest(expr);
|
||||
}
|
||||
|
||||
public SQLName nameRest(SQLName expr) throws ParserException {
|
||||
public SQLName nameRest(SQLName expr) {
|
||||
if (lexer.token() == Token.DOTDOT) {
|
||||
lexer.nextToken();
|
||||
String text = lexer.stringVal();
|
||||
|
||||
+2
-3
@@ -21,7 +21,6 @@ import com.alibaba.druid.sql.ast.statement.SQLSelectQuery;
|
||||
import com.alibaba.druid.sql.dialect.sqlserver.ast.SQLServerSelect;
|
||||
import com.alibaba.druid.sql.dialect.sqlserver.ast.SQLServerSelectQueryBlock;
|
||||
import com.alibaba.druid.sql.dialect.sqlserver.ast.Top;
|
||||
import com.alibaba.druid.sql.parser.ParserException;
|
||||
import com.alibaba.druid.sql.parser.SQLExprParser;
|
||||
import com.alibaba.druid.sql.parser.SQLSelectParser;
|
||||
import com.alibaba.druid.sql.parser.Token;
|
||||
@@ -36,7 +35,7 @@ public class SQLServerSelectParser extends SQLSelectParser {
|
||||
super(exprParser);
|
||||
}
|
||||
|
||||
public SQLSelect select() throws ParserException {
|
||||
public SQLSelect select() {
|
||||
SQLServerSelect select = new SQLServerSelect();
|
||||
|
||||
select.setQuery(query());
|
||||
@@ -49,7 +48,7 @@ public class SQLServerSelectParser extends SQLSelectParser {
|
||||
return select;
|
||||
}
|
||||
|
||||
public SQLSelectQuery query() throws ParserException {
|
||||
public SQLSelectQuery query() {
|
||||
if (lexer.token() == Token.LPAREN) {
|
||||
lexer.nextToken();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user