This is an automated email from the ASF dual-hosted git repository.

duanzhengqiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git


The following commit(s) were added to refs/heads/master by this push:
     new 4e7c1d3af49 Fix sonar issues of This branch's code block is the same 
as the block for the branch (#25698)
4e7c1d3af49 is described below

commit 4e7c1d3af497ca86010eb2decc347c2f7129a3d7
Author: Liang Zhang <[email protected]>
AuthorDate: Tue May 16 16:03:37 2023 +0800

    Fix sonar issues of This branch's code block is the same as the block for 
the branch (#25698)
---
 .../column/value/string/MySQLJsonValueDecoder.java  |  4 +---
 .../type/SQLServerDCLStatementVisitor.java          | 21 ++++++---------------
 2 files changed, 7 insertions(+), 18 deletions(-)

diff --git 
a/db-protocol/mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/packet/binlog/row/column/value/string/MySQLJsonValueDecoder.java
 
b/db-protocol/mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/packet/binlog/row/column/value/string/MySQLJsonValueDecoder.java
index c691ab8343c..8b1211a7667 100644
--- 
a/db-protocol/mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/packet/binlog/row/column/value/string/MySQLJsonValueDecoder.java
+++ 
b/db-protocol/mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/packet/binlog/row/column/value/string/MySQLJsonValueDecoder.java
@@ -228,9 +228,7 @@ public final class MySQLJsonValueDecoder {
         out.append('"');
         for (int i = 0; i < str.length(); ++i) {
             char c = str.charAt(i);
-            if (c == '"') {
-                out.append('\\');
-            } else if (c == '\\') {
+            if (c == '"' || c == '\\') {
                 out.append('\\');
             }
             out.append(c);
diff --git 
a/parser/sql/dialect/sqlserver/src/main/java/org/apache/shardingsphere/sql/parser/sqlserver/visitor/statement/type/SQLServerDCLStatementVisitor.java
 
b/parser/sql/dialect/sqlserver/src/main/java/org/apache/shardingsphere/sql/parser/sqlserver/visitor/statement/type/SQLServerDCLStatementVisitor.java
index 0b64bd09a16..4b41bedc11b 100644
--- 
a/parser/sql/dialect/sqlserver/src/main/java/org/apache/shardingsphere/sql/parser/sqlserver/visitor/statement/type/SQLServerDCLStatementVisitor.java
+++ 
b/parser/sql/dialect/sqlserver/src/main/java/org/apache/shardingsphere/sql/parser/sqlserver/visitor/statement/type/SQLServerDCLStatementVisitor.java
@@ -103,11 +103,8 @@ public final class SQLServerDCLStatementVisitor extends 
SQLServerStatementVisito
     private Collection<SimpleTableSegment> 
getTableFromGrantPrivilegeClause(final GrantClassPrivilegesClauseContext ctx) {
         Collection<SimpleTableSegment> result = new LinkedList<>();
         if (null != ctx.onClassClause()) {
-            if (null != ctx.onClassClause().classItem() && null != 
ctx.onClassClause().classItem().OBJECT()) {
-                result.add((SimpleTableSegment) 
visit(ctx.onClassClause().securable()));
-            } else if (null != 
ctx.classPrivileges().privilegeType().get(0).objectPermission()) {
-                result.add((SimpleTableSegment) 
visit(ctx.onClassClause().securable()));
-            } else if (null != 
ctx.classPrivileges().privilegeType().get(0).PRIVILEGES()) {
+            if (null != ctx.onClassClause().classItem() && null != 
ctx.onClassClause().classItem().OBJECT()
+                    || null != 
ctx.classPrivileges().privilegeType().get(0).objectPermission() || null != 
ctx.classPrivileges().privilegeType().get(0).PRIVILEGES()) {
                 result.add((SimpleTableSegment) 
visit(ctx.onClassClause().securable()));
             }
         }
@@ -146,11 +143,8 @@ public final class SQLServerDCLStatementVisitor extends 
SQLServerStatementVisito
     private Collection<SimpleTableSegment> 
getTableFromRevokeClassPrivilegesClause(final 
RevokeClassPrivilegesClauseContext ctx) {
         Collection<SimpleTableSegment> result = new LinkedList<>();
         if (null != ctx.onClassClause()) {
-            if (null != ctx.onClassClause().classItem() && null != 
ctx.onClassClause().classItem().OBJECT()) {
-                result.add((SimpleTableSegment) 
visit(ctx.onClassClause().securable()));
-            } else if (null != 
ctx.classPrivileges().privilegeType().get(0).objectPermission()) {
-                result.add((SimpleTableSegment) 
visit(ctx.onClassClause().securable()));
-            } else if (null != 
ctx.classPrivileges().privilegeType().get(0).PRIVILEGES()) {
+            if (null != ctx.onClassClause().classItem() && null != 
ctx.onClassClause().classItem().OBJECT()
+                    || null != 
ctx.classPrivileges().privilegeType().get(0).objectPermission() || null != 
ctx.classPrivileges().privilegeType().get(0).PRIVILEGES()) {
                 result.add((SimpleTableSegment) 
visit(ctx.onClassClause().securable()));
             }
         }
@@ -259,11 +253,8 @@ public final class SQLServerDCLStatementVisitor extends 
SQLServerStatementVisito
     private Collection<SimpleTableSegment> 
getTableFromDenyClassPrivilegesClause(final DenyClassPrivilegesClauseContext 
ctx) {
         Collection<SimpleTableSegment> result = new LinkedList<>();
         if (null != ctx.onClassClause()) {
-            if (null != ctx.onClassClause().classItem() && null != 
ctx.onClassClause().classItem().OBJECT()) {
-                result.add((SimpleTableSegment) 
visit(ctx.onClassClause().securable()));
-            } else if (null != 
ctx.classPrivileges().privilegeType().get(0).objectPermission()) {
-                result.add((SimpleTableSegment) 
visit(ctx.onClassClause().securable()));
-            } else if (null != 
ctx.classPrivileges().privilegeType().get(0).PRIVILEGES()) {
+            if (null != ctx.onClassClause().classItem() && null != 
ctx.onClassClause().classItem().OBJECT()
+                    || null != 
ctx.classPrivileges().privilegeType().get(0).objectPermission() || null != 
ctx.classPrivileges().privilegeType().get(0).PRIVILEGES()) {
                 result.add((SimpleTableSegment) 
visit(ctx.onClassClause().securable()));
             }
         }

Reply via email to