refactor: 优化部分代码

移除所有 toString(),修复 Sonar、Codacy 扫描问题
This commit is contained in:
2024-02-03 10:43:32 +08:00
parent 5457bc21c3
commit 0e3d388eb7
30 changed files with 3 additions and 171 deletions

View File

@@ -43,9 +43,4 @@ public class SpringDocExtensionProperties {
public void setComponents(Components components) { public void setComponents(Components components) {
this.components = components; this.components = components;
} }
@Override
public String toString() {
return "SpringDocExtensionProperties{" + "components=" + components + '}';
}
} }

View File

@@ -69,9 +69,4 @@ public class SaTokenExtensionProperties {
public void setSecurity(SaTokenSecurityProperties security) { public void setSecurity(SaTokenSecurityProperties security) {
this.security = security; this.security = security;
} }
@Override
public String toString() {
return "SaTokenExtensionProperties{" + "enabled=" + enabled + ", dao=" + dao + ", security=" + security + '}';
}
} }

View File

@@ -38,9 +38,4 @@ public class SaTokenDaoProperties {
public void setType(SaTokenDaoType type) { public void setType(SaTokenDaoType type) {
this.type = type; this.type = type;
} }
@Override
public String toString() {
return "SaTokenDaoProperties{" + "type=" + type + '}';
}
} }

View File

@@ -115,9 +115,4 @@ public class RedissonProperties {
public void setSentinelServersConfig(SentinelServersConfig sentinelServersConfig) { public void setSentinelServersConfig(SentinelServersConfig sentinelServersConfig) {
this.sentinelServersConfig = sentinelServersConfig; this.sentinelServersConfig = sentinelServersConfig;
} }
@Override
public String toString() {
return "RedissonProperties{" + "enabled=" + enabled + ", mode=" + mode + ", singleServerConfig=" + singleServerConfig + ", clusterServersConfig=" + clusterServersConfig + ", sentinelServersConfig=" + sentinelServersConfig + '}';
}
} }

View File

@@ -317,9 +317,4 @@ public class BehaviorCaptchaProperties {
public void setFontSize(int fontSize) { public void setFontSize(int fontSize) {
this.fontSize = fontSize; this.fontSize = fontSize;
} }
@Override
public String toString() {
return "BehaviorCaptchaProperties{" + "enabled=" + enabled + ", enableAes=" + enableAes + ", type=" + type + ", cacheType=" + cacheType + ", jigsawBaseMapPath='" + jigsawBaseMapPath + '\'' + ", slipOffset='" + slipOffset + '\'' + ", picClickBaseMapPath='" + picClickBaseMapPath + '\'' + ", fontType='" + fontType + '\'' + ", historyDataClearEnable=" + historyDataClearEnable + ", reqFrequencyLimitEnable=" + reqFrequencyLimitEnable + ", reqGetLockLimit=" + reqGetLockLimit + ", reqGetLockSeconds=" + reqGetLockSeconds + ", reqGetMinuteLimit=" + reqGetMinuteLimit + ", reqCheckMinuteLimit=" + reqCheckMinuteLimit + ", reqVerifyMinuteLimit=" + reqVerifyMinuteLimit + ", cacheNumber='" + cacheNumber + '\'' + ", timingClear='" + timingClear + '\'' + ", waterMark='" + waterMark + '\'' + ", waterFont='" + waterFont + '\'' + ", interferenceOptions='" + interferenceOptions + '\'' + ", fontStyle=" + fontStyle + ", fontSize=" + fontSize + '}';
}
} }

View File

@@ -119,9 +119,4 @@ public class GraphicCaptchaProperties {
public void setFontSize(int fontSize) { public void setFontSize(int fontSize) {
this.fontSize = fontSize; this.fontSize = fontSize;
} }
@Override
public String toString() {
return "GraphicCaptchaProperties{" + "enabled=" + enabled + ", type=" + type + ", length=" + length + ", width=" + width + ", height=" + height + ", fontName='" + fontName + '\'' + ", fontSize=" + fontSize + '}';
}
} }

View File

@@ -114,11 +114,6 @@ public class ProjectProperties {
public void setUrl(String url) { public void setUrl(String url) {
this.url = url; this.url = url;
} }
@Override
public String toString() {
return "Contact{" + "name='" + name + '\'' + ", email='" + email + '\'' + ", url='" + url + '\'' + '}';
}
} }
/** /**
@@ -150,11 +145,6 @@ public class ProjectProperties {
public void setUrl(String url) { public void setUrl(String url) {
this.url = url; this.url = url;
} }
@Override
public String toString() {
return "License{" + "name='" + name + '\'' + ", url='" + url + '\'' + '}';
}
} }
public String getName() { public String getName() {
@@ -228,9 +218,4 @@ public class ProjectProperties {
public void setProduction(boolean production) { public void setProduction(boolean production) {
this.production = production; this.production = production;
} }
@Override
public String toString() {
return "ProjectProperties{" + "name='" + name + '\'' + ", appName='" + appName + '\'' + ", version='" + version + '\'' + ", description='" + description + '\'' + ", url='" + url + '\'' + ", basePackage='" + basePackage + '\'' + ", contact=" + contact + ", license=" + license + ", production=" + production + '}';
}
} }

View File

@@ -93,9 +93,4 @@ public class ThreadPoolProperties {
public void setKeepAliveSeconds(int keepAliveSeconds) { public void setKeepAliveSeconds(int keepAliveSeconds) {
this.keepAliveSeconds = keepAliveSeconds; this.keepAliveSeconds = keepAliveSeconds;
} }
@Override
public String toString() {
return "ThreadPoolProperties{" + "enabled=" + enabled + ", corePoolSize=" + corePoolSize + ", maxPoolSize=" + maxPoolSize + ", queueCapacity=" + queueCapacity + ", keepAliveSeconds=" + keepAliveSeconds + '}';
}
} }

View File

@@ -112,9 +112,4 @@ public class Table implements Serializable {
public void setUpdateTime(LocalDateTime updateTime) { public void setUpdateTime(LocalDateTime updateTime) {
this.updateTime = updateTime; this.updateTime = updateTime;
} }
@Override
public String toString() {
return "Table{" + "tableName='" + tableName + '\'' + ", comment='" + comment + '\'' + ", engine='" + engine + '\'' + ", charset='" + charset + '\'' + ", createTime=" + createTime + ", updateTime=" + updateTime + '}';
}
} }

View File

@@ -68,11 +68,6 @@ public class MyBatisPlusExtensionProperties {
public void setEnabled(boolean enabled) { public void setEnabled(boolean enabled) {
this.enabled = enabled; this.enabled = enabled;
} }
@Override
public String toString() {
return "DataPermissionProperties{" + "enabled=" + enabled + '}';
}
} }
/** /**
@@ -131,11 +126,6 @@ public class MyBatisPlusExtensionProperties {
public void setMaxLimit(Long maxLimit) { public void setMaxLimit(Long maxLimit) {
this.maxLimit = maxLimit; this.maxLimit = maxLimit;
} }
@Override
public String toString() {
return "PaginationProperties{" + "enabled=" + enabled + ", dbType=" + dbType + ", overflow=" + overflow + ", maxLimit=" + maxLimit + '}';
}
} }
public boolean isEnabled() { public boolean isEnabled() {
@@ -169,9 +159,4 @@ public class MyBatisPlusExtensionProperties {
public void setPagination(PaginationProperties pagination) { public void setPagination(PaginationProperties pagination) {
this.pagination = pagination; this.pagination = pagination;
} }
@Override
public String toString() {
return "MyBatisPlusExtensionProperties{" + "enabled=" + enabled + ", mapperPackage='" + mapperPackage + '\'' + ", dataPermission=" + dataPermission + ", pagination=" + pagination + '}';
}
} }

View File

@@ -79,11 +79,6 @@ public class DataPermissionCurrentUser {
public void setDataScope(DataScope dataScope) { public void setDataScope(DataScope dataScope) {
this.dataScope = dataScope; this.dataScope = dataScope;
} }
@Override
public String toString() {
return "CurrentUserRole{" + "roleId='" + roleId + '\'' + ", dataScope=" + dataScope + '}';
}
} }
public String getUserId() { public String getUserId() {
@@ -109,9 +104,4 @@ public class DataPermissionCurrentUser {
public void setDeptId(String deptId) { public void setDeptId(String deptId) {
this.deptId = deptId; this.deptId = deptId;
} }
@Override
public String toString() {
return "DataPermissionCurrentUser{" + "userId='" + userId + '\'' + ", roles=" + roles + ", deptId='" + deptId + '\'' + '}';
}
} }

View File

@@ -135,8 +135,6 @@ public class QueryWrapperHelper {
} }
return consumers; return consumers;
} catch (BadRequestException e) { } catch (BadRequestException e) {
log.error("Build query wrapper occurred an validation error: {}. Query: {}, Field: {}.", e
.getMessage(), query, field, e);
throw e; throw e;
} catch (Exception e) { } catch (Exception e) {
log.error("Build query wrapper occurred an error: {}. Query: {}, Field: {}.", e log.error("Build query wrapper occurred an error: {}. Query: {}, Field: {}.", e

View File

@@ -104,9 +104,4 @@ public class BaseDO implements Serializable {
public void setUpdateTime(LocalDateTime updateTime) { public void setUpdateTime(LocalDateTime updateTime) {
this.updateTime = updateTime; this.updateTime = updateTime;
} }
@Override
public String toString() {
return "BaseDO{" + "id=" + id + ", createUser=" + createUser + ", createTime=" + createTime + ", updateUser=" + updateUser + ", updateTime=" + updateTime + '}';
}
} }

View File

@@ -99,9 +99,4 @@ public class PageQuery extends SortQuery {
public void setSize(Integer size) { public void setSize(Integer size) {
this.size = size; this.size = size;
} }
@Override
public String toString() {
return "PageQuery{" + "page=" + page + ", size=" + size + "} " + super.toString();
}
} }

View File

@@ -25,7 +25,6 @@ import top.charles7c.continew.starter.core.constant.StringConstants;
import java.io.Serial; import java.io.Serial;
import java.io.Serializable; import java.io.Serializable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.List; import java.util.List;
/** /**
@@ -76,9 +75,4 @@ public class SortQuery implements Serializable {
public void setSort(String[] sort) { public void setSort(String[] sort) {
this.sort = sort; this.sort = sort;
} }
@Override
public String toString() {
return "SortQuery{" + "sort=" + Arrays.toString(sort) + '}';
}
} }

View File

@@ -81,9 +81,4 @@ public class BaseDetailResp extends BaseResp {
public void setUpdateTime(LocalDateTime updateTime) { public void setUpdateTime(LocalDateTime updateTime) {
this.updateTime = updateTime; this.updateTime = updateTime;
} }
@Override
public String toString() {
return "BaseDetailResp{" + "updateUser=" + updateUser + ", updateUserString='" + updateUserString + '\'' + ", updateTime=" + updateTime + "} " + super.toString();
}
} }

View File

@@ -113,9 +113,4 @@ public class BaseResp implements Serializable {
public void setDisabled(Boolean disabled) { public void setDisabled(Boolean disabled) {
this.disabled = disabled; this.disabled = disabled;
} }
@Override
public String toString() {
return "BaseResp{" + "id=" + id + ", createUser=" + createUser + ", createUserString='" + createUserString + '\'' + ", createTime=" + createTime + ", disabled=" + disabled + '}';
}
} }

View File

@@ -142,9 +142,4 @@ public class PageResp<L> implements Serializable {
public void setTotal(long total) { public void setTotal(long total) {
this.total = total; this.total = total;
} }
@Override
public String toString() {
return "PageResp{" + "list=" + list + ", total=" + total + '}';
}
} }

View File

@@ -19,7 +19,7 @@ package top.charles7c.continew.starter.file.excel.util;
import cn.hutool.core.date.DatePattern; import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.URLUtil; import cn.hutool.core.util.URLUtil;
import com.alibaba.excel.EasyExcel; import com.alibaba.excel.EasyExcelFactory;
import com.alibaba.excel.write.style.column.LongestMatchColumnWidthStyleStrategy; import com.alibaba.excel.write.style.column.LongestMatchColumnWidthStyleStrategy;
import jakarta.servlet.http.HttpServletResponse; import jakarta.servlet.http.HttpServletResponse;
import org.slf4j.Logger; import org.slf4j.Logger;
@@ -74,7 +74,7 @@ public class ExcelUtils {
.format(new Date(), DatePattern.PURE_DATETIME_PATTERN))); .format(new Date(), DatePattern.PURE_DATETIME_PATTERN)));
response.setHeader("Content-disposition", "attachment;filename=" + exportFileName); response.setHeader("Content-disposition", "attachment;filename=" + exportFileName);
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8"); response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8");
EasyExcel.write(response.getOutputStream(), clazz) EasyExcelFactory.write(response.getOutputStream(), clazz)
.autoCloseStream(false) .autoCloseStream(false)
// 自动适配宽度 // 自动适配宽度
.registerWriteHandler(new LongestMatchColumnWidthStyleStrategy()) .registerWriteHandler(new LongestMatchColumnWidthStyleStrategy())

View File

@@ -176,9 +176,4 @@ public class LogRecord {
public Instant getTimestamp() { public Instant getTimestamp() {
return timestamp; return timestamp;
} }
@Override
public String toString() {
return "LogRecord{" + "description='" + description + '\'' + ", module='" + module + '\'' + ", request=" + request + ", response=" + response + ", timeTaken=" + timeTaken + ", timestamp=" + timestamp + '}';
}
} }

View File

@@ -169,9 +169,4 @@ public class LogRequest {
public void setOs(String os) { public void setOs(String os) {
this.os = os; this.os = os;
} }
@Override
public String toString() {
return "LogRequest{" + "method='" + method + '\'' + ", url=" + url + ", ip='" + ip + '\'' + ", headers=" + headers + ", body='" + body + '\'' + ", param=" + param + ", address='" + address + '\'' + ", browser='" + browser + '\'' + ", os='" + os + '\'' + '}';
}
} }

View File

@@ -89,9 +89,4 @@ public class LogResponse {
public void setParam(Map<String, Object> param) { public void setParam(Map<String, Object> param) {
this.param = param; this.param = param;
} }
@Override
public String toString() {
return "LogResponse{" + "status=" + status + ", headers=" + headers + ", body='" + body + '\'' + ", param=" + param + '}';
}
} }

View File

@@ -70,9 +70,4 @@ public class LogProperties {
public void setInclude(Set<Include> include) { public void setInclude(Set<Include> include) {
this.include = include; this.include = include;
} }
@Override
public String toString() {
return "LogProperties{" + "enabled=" + enabled + ", isPrint=" + isPrint + ", include=" + include + '}';
}
} }

View File

@@ -53,9 +53,4 @@ public class PasswordEncoderProperties {
public void setEncodingId(String encodingId) { public void setEncodingId(String encodingId) {
this.encodingId = encodingId; this.encodingId = encodingId;
} }
@Override
public String toString() {
return "PasswordEncoderProperties{" + "enabled=" + enabled + ", encodingId='" + encodingId + '\'' + '}';
}
} }

View File

@@ -85,11 +85,6 @@ public class LocalStorageProperties {
public void setMaxFileSize(DataSize maxFileSize) { public void setMaxFileSize(DataSize maxFileSize) {
this.maxFileSize = maxFileSize; this.maxFileSize = maxFileSize;
} }
@Override
public String toString() {
return "LocalStorageMapping{" + "pathPattern='" + pathPattern + '\'' + ", location='" + location + '\'' + ", maxFileSize=" + maxFileSize + '}';
}
} }
public boolean isEnabled() { public boolean isEnabled() {
@@ -107,9 +102,4 @@ public class LocalStorageProperties {
public void setMapping(Map<String, LocalStorageMapping> mapping) { public void setMapping(Map<String, LocalStorageMapping> mapping) {
this.mapping = mapping; this.mapping = mapping;
} }
@Override
public String toString() {
return "LocalStorageProperties{" + "enabled=" + enabled + ", mapping=" + mapping + '}';
}
} }

View File

@@ -99,9 +99,4 @@ public class CorsProperties {
public void setExposedHeaders(List<String> exposedHeaders) { public void setExposedHeaders(List<String> exposedHeaders) {
this.exposedHeaders = exposedHeaders; this.exposedHeaders = exposedHeaders;
} }
@Override
public String toString() {
return "CorsProperties{" + "enabled=" + enabled + ", allowedOrigins=" + allowedOrigins + ", allowedMethods=" + allowedMethods + ", allowedHeaders=" + allowedHeaders + ", exposedHeaders=" + exposedHeaders + '}';
}
} }

View File

@@ -81,9 +81,4 @@ public class TLogProperties {
public void setMdcEnable(Boolean mdcEnable) { public void setMdcEnable(Boolean mdcEnable) {
this.mdcEnable = mdcEnable; this.mdcEnable = mdcEnable;
} }
@Override
public String toString() {
return "TLogProperties{" + "pattern='" + pattern + '\'' + ", enableInvokeTimePrint=" + enableInvokeTimePrint + ", idGenerator='" + idGenerator + '\'' + ", mdcEnable=" + mdcEnable + '}';
}
} }

View File

@@ -57,10 +57,10 @@ public class TLogServletFilter implements Filter {
httpServletResponse.addHeader(headerName, TLogContext.getTraceId()); httpServletResponse.addHeader(headerName, TLogContext.getTraceId());
} }
chain.doFilter(request, response); chain.doFilter(request, response);
return;
} finally { } finally {
TLogWebCommon.loadInstance().afterCompletion(); TLogWebCommon.loadInstance().afterCompletion();
} }
return;
} }
chain.doFilter(request, response); chain.doFilter(request, response);
} }

View File

@@ -68,9 +68,4 @@ public class TraceProperties {
public void setTlog(TLogProperties tlog) { public void setTlog(TLogProperties tlog) {
this.tlog = tlog; this.tlog = tlog;
} }
@Override
public String toString() {
return "TraceProperties{" + "enabled=" + enabled + ", headerName='" + headerName + '\'' + ", tlog=" + tlog + '}';
}
} }

View File

@@ -217,9 +217,4 @@ public class R<T> implements Serializable {
public void setTimestamp(long timestamp) { public void setTimestamp(long timestamp) {
this.timestamp = timestamp; this.timestamp = timestamp;
} }
@Override
public String toString() {
return "R{" + "success=" + success + ", code=" + code + ", msg='" + msg + '\'' + ", data=" + data + ", timestamp=" + timestamp + '}';
}
} }