update: SonarLint 代码扫描修改

V0.5.x
chenhui 2023-06-29 23:24:58 +08:00
parent 3372b80f35
commit c4a8002468
15 changed files with 32 additions and 69 deletions

View File

@ -1,8 +1,8 @@
package cc.iotkit.common.utils;
import cn.hutool.core.lang.Dict;
import cn.hutool.core.util.ArrayUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.PrimitiveArrayUtil;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
@ -61,7 +61,7 @@ public class JsonUtils {
}
public static <T> T parseObject(byte[] bytes, Class<T> clazz) {
if (ArrayUtil.isEmpty(bytes)) {
if (PrimitiveArrayUtil.isEmpty(bytes)) {
return null;
}
try {

View File

@ -4,10 +4,6 @@ import cn.hutool.core.io.FileUtil;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
/**
*
*

View File

@ -22,9 +22,10 @@ public interface IOwnedData<T extends Owned<ID>, ID> extends ICommonData<T, ID>
/**
*
* @return
*/
default List<T> findByUid(String uid) {
return Collections.EMPTY_LIST;
default List findByUid(String uid) {
return Collections.emptyList();
}

View File

@ -58,11 +58,6 @@
</dependency>
<!-- <dependency>-->
<!-- <groupId>io.github.linpeilie</groupId>-->
<!-- <artifactId>mapstruct-plus</artifactId>-->
<!-- </dependency>-->
<dependency>
<groupId>io.github.linpeilie</groupId>
<artifactId>mapstruct-plus-spring-boot-starter</artifactId>
@ -106,21 +101,21 @@
<source>${java.version}</source> <!-- depending on your project -->
<target>${java.version}</target> <!-- depending on your project -->
<annotationProcessorPaths>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
</path>
<path>
<groupId>io.github.linpeilie</groupId>
<artifactId>mapstruct-plus-processor</artifactId>
<version>${mapstruct-plus.version}</version>
</path>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok-mapstruct-binding</artifactId>
<version>0.2.0</version>
</path>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
</path>
<path>
<groupId>io.github.linpeilie</groupId>
<artifactId>mapstruct-plus-processor</artifactId>
<version>${mapstruct-plus.version}</version>
</path>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok-mapstruct-binding</artifactId>
<version>0.2.0</version>
</path>
<!-- other annotation processors -->
</annotationProcessorPaths>

View File

@ -1,6 +1,5 @@
package cc.iotkit.data.config;
import io.github.linpeilie.annotations.ComponentModelConfig;
import io.github.linpeilie.annotations.MapperConfig;
/**

View File

@ -29,10 +29,6 @@
<artifactId>jackson-annotations</artifactId>
</dependency>
<!-- <dependency>-->
<!-- <groupId>io.github.linpeilie</groupId>-->
<!-- <artifactId>mapstruct-plus</artifactId>-->
<!-- </dependency>-->
<dependency>
<groupId>io.github.linpeilie</groupId>
<artifactId>mapstruct-plus-spring-boot-starter</artifactId>

View File

@ -35,9 +35,7 @@ public class VirtualDeviceLogDataImpl implements IVirtualDeviceLogData {
.findByVirtualDeviceId(virtualDeviceId,
Pageable.ofSize(size).withPage(page - 1));
return new Paging<>(paged.getTotalElements(), paged.getContent().stream()
.map(o -> {
return MapstructUtils.convert(o, VirtualDeviceLog.class);
})
.map(o -> MapstructUtils.convert(o, VirtualDeviceLog.class))
.collect(Collectors.toList()));
}

View File

@ -44,10 +44,6 @@
<artifactId>jackson-annotations</artifactId>
</dependency>
<!-- <dependency>-->
<!-- <groupId>org.mapstruct</groupId>-->
<!-- <artifactId>mapstruct</artifactId>-->
<!-- </dependency>-->
<dependency>
<groupId>cn.hutool</groupId>

View File

@ -36,7 +36,7 @@ public class VirtualDeviceLogDataImpl implements IVirtualDeviceLogData {
sql = "select count(*) from virtual_device_log_" + virtualDeviceId.toLowerCase();
List<Long> counts = tdTemplate.queryForList(sql, Long.class);
return new Paging<>(counts.size() > 0 ? counts.get(0) : 0, logs.stream().map(r ->
return new Paging<>(!counts.isEmpty() ? counts.get(0) : 0, logs.stream().map(r ->
new VirtualDeviceLog(r.getTime().toString(), virtualDeviceId,
r.getVirtualDeviceName(),
r.getDeviceTotal(), r.getResult(),

View File

@ -22,7 +22,6 @@
<module>iot-data-serviceImpl-rdb</module>
<module>iot-temporal-service</module>
<module>iot-temporal-serviceImpl-es</module>
<!--<module>iot-temporal-serviceImpl-ts</module>-->
<module>iot-temproal-serviceImpl-td</module>
</modules>
@ -32,18 +31,6 @@
<dependencies>
<!-- <dependency>-->
<!-- <groupId>org.mapstruct</groupId>-->
<!-- <artifactId>mapstruct</artifactId>-->
<!-- <version>1.4.2.Final</version>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>org.mapstruct</groupId>-->
<!-- <artifactId>mapstruct-processor</artifactId>-->
<!-- <version>1.4.2.Final</version>-->
<!-- </dependency>-->
</dependencies>
</dependencyManagement>

View File

@ -3,6 +3,7 @@ package cc.iotkit.common.excel.core;
import cc.iotkit.common.utils.JsonUtils;
import cc.iotkit.common.utils.StreamUtils;
import cc.iotkit.common.utils.ValidatorUtils;
import cn.hutool.core.text.CharSequenceUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
@ -60,7 +61,7 @@ public class DefaultExcelListener<T> extends AnalysisEventListener<T> implements
// 如果是某一个单元格的转换异常 能获取到具体行号
Integer rowIndex = excelDataConvertException.getRowIndex();
Integer columnIndex = excelDataConvertException.getColumnIndex();
errMsg = StrUtil.format("第{}行-第{}列-表头{}: 解析异常<br/>",
errMsg = CharSequenceUtil.format("第{}行-第{}列-表头{}: 解析异常<br/>",
rowIndex + 1, columnIndex + 1, headMap.get(columnIndex));
if (log.isDebugEnabled()) {
log.error(errMsg);
@ -70,7 +71,7 @@ public class DefaultExcelListener<T> extends AnalysisEventListener<T> implements
ConstraintViolationException constraintViolationException = (ConstraintViolationException) exception;
Set<ConstraintViolation<?>> constraintViolations = constraintViolationException.getConstraintViolations();
String constraintViolationsMsg = StreamUtils.join(constraintViolations, ConstraintViolation::getMessage, ", ");
errMsg = StrUtil.format("第{}行数据校验异常: {}", context.readRowHolder().getRowIndex() + 1, constraintViolationsMsg);
errMsg = CharSequenceUtil.format("第{}行数据校验异常: {}", context.readRowHolder().getRowIndex() + 1, constraintViolationsMsg);
if (log.isDebugEnabled()) {
log.error(errMsg);
}

View File

@ -1,5 +1,6 @@
package cc.iotkit.common.excel.core;
import cn.hutool.core.text.CharSequenceUtil;
import cn.hutool.core.util.StrUtil;
import lombok.Setter;
@ -64,7 +65,7 @@ public class DefaultExcelResult<T> implements ExcelResult<T> {
return "读取失败,未解析到数据";
} else {
if (errorCount == 0) {
return StrUtil.format("恭喜您,全部读取成功!共{}条", successCount);
return CharSequenceUtil.format("恭喜您,全部读取成功!共{}条", successCount);
} else {
return "";
}

View File

@ -3,7 +3,7 @@ package cc.iotkit.common.web.utils;
import cc.iotkit.common.utils.StringUtils;
import cn.hutool.captcha.generator.CodeGenerator;
import cn.hutool.core.math.Calculator;
import cn.hutool.core.util.CharUtil;
import cn.hutool.core.text.CharPool;
import cn.hutool.core.util.RandomUtil;
/**
@ -44,8 +44,8 @@ public class UnsignedMathGenerator implements CodeGenerator {
int b = RandomUtil.randomInt(limit);
String max = Integer.toString(Math.max(a,b));
String min = Integer.toString(Math.min(a,b));
max = StringUtils.rightPad(max, this.numberLength, CharUtil.SPACE);
min = StringUtils.rightPad(min, this.numberLength, CharUtil.SPACE);
max = StringUtils.rightPad(max, this.numberLength, CharPool.SPACE);
min = StringUtils.rightPad(min, this.numberLength, CharPool.SPACE);
return max + RandomUtil.randomChar(OPERATORS) + min + '=';
}

View File

@ -30,9 +30,7 @@ public class VertxMqConsumer<T> implements MqConsumer<T> {
@SneakyThrows
public VertxMqConsumer(Class<T> cls) {
consumerVerticle = new MqConsumerVerticle<>(cls);
VertxManager.getVertx().deployVerticle(consumerVerticle, stringAsyncResult -> {
countDownLatch.countDown();
});
VertxManager.getVertx().deployVerticle(consumerVerticle, stringAsyncResult -> countDownLatch.countDown());
//等待初始化穿完成
countDownLatch.await();
}

View File

@ -21,12 +21,7 @@ public class VertxMqProducer<T> implements MqProducer<T> {
@SneakyThrows
public VertxMqProducer(Class<T> cls) {
producerVerticle = new MqProducerVerticle<>(cls);
VertxManager.getVertx().deployVerticle(producerVerticle, new Handler<AsyncResult<String>>() {
@Override
public void handle(AsyncResult<String> stringAsyncResult) {
countDownLatch.countDown();
}
});
VertxManager.getVertx().deployVerticle(producerVerticle, stringAsyncResult -> countDownLatch.countDown());
//等待初始化完成
countDownLatch.await();
}