This is an automated email from the ASF dual-hosted git repository.
zhonghongsheng 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 7b66b6e77e0 Fix sonar issue of Methods and field names should not be
the same or differ only by capitalization (#25658)
7b66b6e77e0 is described below
commit 7b66b6e77e0b6a5afb6476b5209fd3a7b73f0f65
Author: Liang Zhang <[email protected]>
AuthorDate: Sun May 14 18:13:14 2023 +0800
Fix sonar issue of Methods and field names should not be the same or differ
only by capitalization (#25658)
---
.../assisted/MD5AssistedEncryptAlgorithm.java | 4 ++--
.../like/CharDigestLikeEncryptAlgorithm.java | 22 +++++++++++-----------
.../mask/algorithm/hash/MD5MaskAlgorithm.java | 4 ++--
.../dml/ShardingInsertStatementValidatorTest.java | 12 ++++++------
4 files changed, 21 insertions(+), 21 deletions(-)
diff --git
a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/algorithm/assisted/MD5AssistedEncryptAlgorithm.java
b/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/algorithm/assisted/MD5AssistedEncryptAlgorithm.java
index 7e33b7bb1c4..78dc9ff457a 100644
---
a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/algorithm/assisted/MD5AssistedEncryptAlgorithm.java
+++
b/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/algorithm/assisted/MD5AssistedEncryptAlgorithm.java
@@ -28,13 +28,13 @@ import java.util.Properties;
*/
public final class MD5AssistedEncryptAlgorithm implements
AssistedEncryptAlgorithm<Object, String> {
- private static final String SALT = "salt";
+ private static final String SALT_KEY = "salt";
private String salt;
@Override
public void init(final Properties props) {
- this.salt = props.getProperty(SALT, "");
+ this.salt = props.getProperty(SALT_KEY, "");
}
@Override
diff --git
a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/algorithm/like/CharDigestLikeEncryptAlgorithm.java
b/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/algorithm/like/CharDigestLikeEncryptAlgorithm.java
index b5b69fecefb..cf08dee7f99 100644
---
a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/algorithm/like/CharDigestLikeEncryptAlgorithm.java
+++
b/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/algorithm/like/CharDigestLikeEncryptAlgorithm.java
@@ -37,13 +37,13 @@ import java.util.stream.IntStream;
*/
public final class CharDigestLikeEncryptAlgorithm implements
LikeEncryptAlgorithm<Object, String> {
- private static final String DELTA = "delta";
+ private static final String DELTA_KEY = "delta";
- private static final String MASK = "mask";
+ private static final String MASK_KEY = "mask";
- private static final String START = "start";
+ private static final String START_KEY = "start";
- private static final String DICT = "dict";
+ private static final String DICT_KEY = "dict";
private static final int DEFAULT_DELTA = 1;
@@ -70,8 +70,8 @@ public final class CharDigestLikeEncryptAlgorithm implements
LikeEncryptAlgorith
}
private int createDelta(final Properties props) {
- if (props.containsKey(DELTA)) {
- String delta = props.getProperty(DELTA);
+ if (props.containsKey(DELTA_KEY)) {
+ String delta = props.getProperty(DELTA_KEY);
try {
return Integer.parseInt(delta);
} catch (final NumberFormatException ignored) {
@@ -82,8 +82,8 @@ public final class CharDigestLikeEncryptAlgorithm implements
LikeEncryptAlgorith
}
private int createMask(final Properties props) {
- if (props.containsKey(MASK)) {
- String mask = props.getProperty(MASK);
+ if (props.containsKey(MASK_KEY)) {
+ String mask = props.getProperty(MASK_KEY);
try {
return Integer.parseInt(mask);
} catch (final NumberFormatException ignored) {
@@ -94,8 +94,8 @@ public final class CharDigestLikeEncryptAlgorithm implements
LikeEncryptAlgorith
}
private int createStart(final Properties props) {
- if (props.containsKey(START)) {
- String start = props.getProperty(START);
+ if (props.containsKey(START_KEY)) {
+ String start = props.getProperty(START_KEY);
try {
return Integer.parseInt(start);
} catch (final NumberFormatException ignored) {
@@ -106,7 +106,7 @@ public final class CharDigestLikeEncryptAlgorithm
implements LikeEncryptAlgorith
}
private Map<Character, Integer> createCharIndexes(final Properties props) {
- String dictContent = props.containsKey(DICT) &&
!Strings.isNullOrEmpty(props.getProperty(DICT)) ? props.getProperty(DICT) :
initDefaultDict();
+ String dictContent = props.containsKey(DICT_KEY) &&
!Strings.isNullOrEmpty(props.getProperty(DICT_KEY)) ?
props.getProperty(DICT_KEY) : initDefaultDict();
return IntStream.range(0,
dictContent.length()).boxed().collect(Collectors.toMap(dictContent::charAt,
index -> index, (a, b) -> b));
}
diff --git
a/features/mask/core/src/main/java/org/apache/shardingsphere/mask/algorithm/hash/MD5MaskAlgorithm.java
b/features/mask/core/src/main/java/org/apache/shardingsphere/mask/algorithm/hash/MD5MaskAlgorithm.java
index 4e142d15a79..b02dd95a733 100644
---
a/features/mask/core/src/main/java/org/apache/shardingsphere/mask/algorithm/hash/MD5MaskAlgorithm.java
+++
b/features/mask/core/src/main/java/org/apache/shardingsphere/mask/algorithm/hash/MD5MaskAlgorithm.java
@@ -27,13 +27,13 @@ import java.util.Properties;
*/
public final class MD5MaskAlgorithm implements MaskAlgorithm<Object, String> {
- private static final String SALT = "salt";
+ private static final String SALT_KEY = "salt";
private String salt;
@Override
public void init(final Properties props) {
- salt = props.getProperty(SALT, "");
+ salt = props.getProperty(SALT_KEY, "");
}
@Override
diff --git
a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/dml/ShardingInsertStatementValidatorTest.java
b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/dml/ShardingInsertStatementValidatorTest.java
index 715d9f8296a..67725895614 100644
---
a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/dml/ShardingInsertStatementValidatorTest.java
+++
b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/dml/ShardingInsertStatementValidatorTest.java
@@ -157,8 +157,8 @@ class ShardingInsertStatementValidatorTest {
void assertPostValidateWhenInsertWithSingleRouting() {
SQLStatementContext<InsertStatement> sqlStatementContext =
createInsertStatementContext(Collections.singletonList(1),
createInsertStatement());
when(routeContext.isSingleRouting()).thenReturn(true);
- new
ShardingInsertStatementValidator(shardingConditions).postValidate(shardingRule,
sqlStatementContext, new HintValueContext(),
- Collections.emptyList(), mock(ShardingSphereDatabase.class,
RETURNS_DEEP_STUBS), mock(ConfigurationProperties.class), routeContext);
+ assertDoesNotThrow(() -> new
ShardingInsertStatementValidator(shardingConditions).postValidate(shardingRule,
sqlStatementContext, new HintValueContext(),
+ Collections.emptyList(), mock(ShardingSphereDatabase.class,
RETURNS_DEEP_STUBS), mock(ConfigurationProperties.class), routeContext));
}
@Test
@@ -166,8 +166,8 @@ class ShardingInsertStatementValidatorTest {
SQLStatementContext<InsertStatement> sqlStatementContext =
createInsertStatementContext(Collections.singletonList(1),
createInsertStatement());
when(routeContext.isSingleRouting()).thenReturn(false);
when(shardingRule.isBroadcastTable(sqlStatementContext.getSqlStatement().getTable().getTableName().getIdentifier().getValue())).thenReturn(true);
- new
ShardingInsertStatementValidator(shardingConditions).postValidate(shardingRule,
sqlStatementContext, new HintValueContext(),
- Collections.emptyList(), mock(ShardingSphereDatabase.class,
RETURNS_DEEP_STUBS), mock(ConfigurationProperties.class), routeContext);
+ assertDoesNotThrow(() -> new
ShardingInsertStatementValidator(shardingConditions).postValidate(shardingRule,
sqlStatementContext, new HintValueContext(),
+ Collections.emptyList(), mock(ShardingSphereDatabase.class,
RETURNS_DEEP_STUBS), mock(ConfigurationProperties.class), routeContext));
}
@Test
@@ -176,8 +176,8 @@ class ShardingInsertStatementValidatorTest {
when(routeContext.isSingleRouting()).thenReturn(false);
when(shardingRule.isBroadcastTable(sqlStatementContext.getSqlStatement().getTable().getTableName().getIdentifier().getValue())).thenReturn(false);
when(routeContext.getOriginalDataNodes()).thenReturn(getSingleRouteDataNodes());
- new
ShardingInsertStatementValidator(shardingConditions).postValidate(shardingRule,
sqlStatementContext, new HintValueContext(),
- Collections.emptyList(), mock(ShardingSphereDatabase.class,
RETURNS_DEEP_STUBS), mock(ConfigurationProperties.class), routeContext);
+ assertDoesNotThrow(() -> new
ShardingInsertStatementValidator(shardingConditions).postValidate(shardingRule,
sqlStatementContext, new HintValueContext(),
+ Collections.emptyList(), mock(ShardingSphereDatabase.class,
RETURNS_DEEP_STUBS), mock(ConfigurationProperties.class), routeContext));
}
@Test