Starrier/commons

View on GitHub

Showing 59 of 59 total issues

Similar blocks of code found in 2 locations. Consider refactoring.
Open

public String set(String key, String value) {
Jedis jedis = null;
try {
jedis = getJedis();
return jedis.set(key, value);
Severity: Minor
Found in src/main/java/org/starrier/common/utils/JedisUtil.java and 1 other location - About 55 mins to fix
src/main/java/org/starrier/common/utils/JedisUtil.java on lines 73..84

Similar blocks of code found in 2 locations. Consider refactoring.
Open

public Long setnx(String key, String value) {
Jedis jedis = null;
try {
jedis = getJedis();
return jedis.setnx(key, value);
Severity: Minor
Found in src/main/java/org/starrier/common/utils/JedisUtil.java and 1 other location - About 55 mins to fix
src/main/java/org/starrier/common/utils/JedisUtil.java on lines 32..43

Similar blocks of code found in 3 locations. Consider refactoring.
Open

public static String generateDigitalStr(int length) {
StringBuffer sb = new StringBuffer();
Random random = new Random();
for (int i = 0; i < length; i++) {
sb.append(numberChar.charAt(random.nextInt(numberChar.length())));
Severity: Major
Found in src/main/java/org/starrier/common/utils/RandomUtil.java and 2 other locations - About 55 mins to fix
src/main/java/org/starrier/common/utils/RandomUtil.java on lines 32..39
src/main/java/org/starrier/common/utils/RandomUtil.java on lines 62..69

Similar blocks of code found in 3 locations. Consider refactoring.
Open

public static String generateLetterStr(int length) {
StringBuffer sb = new StringBuffer();
Random random = new Random();
for (int i = 0; i < length; i++) {
sb.append(letterChar.charAt(random.nextInt(letterChar.length())));
Severity: Major
Found in src/main/java/org/starrier/common/utils/RandomUtil.java and 2 other locations - About 55 mins to fix
src/main/java/org/starrier/common/utils/RandomUtil.java on lines 32..39
src/main/java/org/starrier/common/utils/RandomUtil.java on lines 47..54

Similar blocks of code found in 3 locations. Consider refactoring.
Open

public static String generateStr(int length) {
StringBuffer sb = new StringBuffer();
Random random = new Random();
for (int i = 0; i < length; i++) {
sb.append(allChar.charAt(random.nextInt(allChar.length())));
Severity: Major
Found in src/main/java/org/starrier/common/utils/RandomUtil.java and 2 other locations - About 55 mins to fix
src/main/java/org/starrier/common/utils/RandomUtil.java on lines 47..54
src/main/java/org/starrier/common/utils/RandomUtil.java on lines 62..69

Similar blocks of code found in 2 locations. Consider refactoring.
Open

public Long del(String key) {
Jedis jedis = null;
try {
jedis = getJedis();
return jedis.del(key.getBytes());
Severity: Minor
Found in src/main/java/org/starrier/common/utils/JedisUtil.java and 1 other location - About 50 mins to fix
src/main/java/org/starrier/common/utils/JedisUtil.java on lines 130..141

Similar blocks of code found in 2 locations. Consider refactoring.
Open

public Boolean exists(String key) {
Jedis jedis = null;
try {
jedis = getJedis();
return jedis.exists(key.getBytes());
Severity: Minor
Found in src/main/java/org/starrier/common/utils/JedisUtil.java and 1 other location - About 50 mins to fix
src/main/java/org/starrier/common/utils/JedisUtil.java on lines 111..122

Similar blocks of code found in 2 locations. Consider refactoring.
Open

public String get(String key) {
Jedis jedis = null;
try {
jedis = getJedis();
return jedis.get(key);
Severity: Minor
Found in src/main/java/org/starrier/common/utils/JedisUtil.java and 1 other location - About 50 mins to fix
src/main/java/org/starrier/common/utils/JedisUtil.java on lines 169..180

Similar blocks of code found in 2 locations. Consider refactoring.
Open

public Long ttl(String key) {
Jedis jedis = null;
try {
jedis = getJedis();
return jedis.ttl(key);
Severity: Minor
Found in src/main/java/org/starrier/common/utils/JedisUtil.java and 1 other location - About 50 mins to fix
src/main/java/org/starrier/common/utils/JedisUtil.java on lines 92..103

Identical blocks of code found in 2 locations. Consider refactoring.
Confirmed

package org.starrier.common.utils;
 
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.TypeReference;
 
 
Severity: Minor
Found in src/main/java/org/starrier/common/utils/FastJsonUtils.java and 1 other location - About 50 mins to fix
src/main/java/org/starrier/common/utils/json/FastJsonUtils.java on lines 1..58

Identical blocks of code found in 2 locations. Consider refactoring.
Confirmed

package org.starrier.common.utils.json;
 
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.TypeReference;
 
 
Severity: Minor
Found in src/main/java/org/starrier/common/utils/json/FastJsonUtils.java and 1 other location - About 50 mins to fix
src/main/java/org/starrier/common/utils/FastJsonUtils.java on lines 1..58

Identical blocks of code found in 2 locations. Consider refactoring.
Confirmed

if (lastTimestamp == timestamp) {
//sequence自增,因为sequence只有12bit,所以和sequenceMask相与一下,去掉高位
sequence = (sequence + 1) & sequenceMask;
//判断是否溢出,也就是每毫秒内超过4095,当为4096时,与sequenceMask相与,sequence就等于0
if (sequence == 0) {
Severity: Minor
Found in src/main/java/org/starrier/common/unique/IdGenerator.java and 1 other location - About 50 mins to fix
src/main/java/org/starrier/common/unique/UniqueIdGenerateUtils.java on lines 55..64

Identical blocks of code found in 2 locations. Consider refactoring.
Confirmed

if (lastTimestamp == timestamp) {
//sequence自增,因为sequence只有12bit,所以和sequenceMask相与一下,去掉高位
sequence = (sequence + 1) & sequenceMask;
//判断是否溢出,也就是每毫秒内超过4095,当为4096时,与sequenceMask相与,sequence就等于0
if (sequence == 0) {
src/main/java/org/starrier/common/unique/IdGenerator.java on lines 39..48

Method handleLoginException has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

private Result handleLoginException(Throwable e, String identifierValue, final long watch, final int times, final long lock) {
 
if (e instanceof LoginException) {
LOGGER.info(">>> handle login exception...");
final ValueOperations<String, String> ssOps = stringRedisTemplate.opsForValue();

Similar blocks of code found in 2 locations. Consider refactoring.
Open

public static byte[] decryptAES(byte[] content, SecretKey secretKey) throws Exception {
 
IvParameterSpec iv = new IvParameterSpec(INIT_VECTOR.getBytes(StandardCharsets.UTF_8));
Cipher cipher = Cipher.getInstance(ALGORITHM_HIGH);
cipher.init(Cipher.DECRYPT_MODE, secretKey, iv);
Severity: Minor
Found in src/main/java/org/starrier/common/utils/encrypt/AESUtils.java and 1 other location - About 45 mins to fix
src/main/java/org/starrier/common/utils/encrypt/AESUtils.java on lines 96..103

Method parseStringToLong has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

@ExceptionZero
public static long parseStringToLong(String dateStr) {
dateStr = dateStr.trim();
Calendar cal = Calendar.getInstance();
if (dateStr.length() == 19 || dateStr.length() == 23) {
Severity: Minor
Found in src/main/java/org/starrier/common/utils/DateUtils.java - About 45 mins to fix

Similar blocks of code found in 2 locations. Consider refactoring.
Open

public static byte[] encryptAES(byte[] content, SecretKey secretKey) throws Exception {
 
IvParameterSpec iv = new IvParameterSpec(INIT_VECTOR.getBytes(StandardCharsets.UTF_8));
Cipher cipher = Cipher.getInstance(ALGORITHM_HIGH);
cipher.init(Cipher.ENCRYPT_MODE, secretKey, iv);
Severity: Minor
Found in src/main/java/org/starrier/common/utils/encrypt/AESUtils.java and 1 other location - About 45 mins to fix
src/main/java/org/starrier/common/utils/encrypt/AESUtils.java on lines 112..119

Similar blocks of code found in 2 locations. Consider refactoring.
Open

private Result(Builder builder) {
this.code = builder.code;
this.data = builder.data;
this.message = builder.message;
this.url = builder.url;
Severity: Minor
Found in src/main/java/org/starrier/common/result/Result.java and 1 other location - About 45 mins to fix
src/main/java/org/starrier/common/result/ReactiveResult.java on lines 33..38

Similar blocks of code found in 2 locations. Consider refactoring.
Open

private ReactiveResult(ReactiveResult.Builder builder) {
this.code = builder.code;
this.data = builder.data;
this.message = builder.message;
this.url = builder.url;
Severity: Minor
Found in src/main/java/org/starrier/common/result/ReactiveResult.java and 1 other location - About 45 mins to fix
src/main/java/org/starrier/common/result/Result.java on lines 37..42

Method handleLoginException has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

private Result handleLoginException(Throwable e, String identifierValue, final long watch, final int times, final long lock) {
    Severity
    Category
    Status
    Source
    Language