feat: V1.1 - lombok集成
This commit is contained in:
8
.idea/compiler.xml
generated
8
.idea/compiler.xml
generated
@@ -7,6 +7,14 @@
|
||||
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
|
||||
<outputRelativeToContentRoot value="true" />
|
||||
<module name="serialization-schema-checker" />
|
||||
</profile>
|
||||
<profile name="Annotation profile for serialization-schema-checker" enabled="true">
|
||||
<sourceOutputDir name="target/generated-sources/annotations" />
|
||||
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
|
||||
<outputRelativeToContentRoot value="true" />
|
||||
<processorPath useClasspath="false">
|
||||
<entry name="$PROJECT_DIR$/../../../my_java/mvn_resp/org/projectlombok/lombok/1.18.34/lombok-1.18.34.jar" />
|
||||
</processorPath>
|
||||
<module name="redis-schema-checker-parent" />
|
||||
</profile>
|
||||
</annotationProcessing>
|
||||
|
||||
24
pom.xml
24
pom.xml
@@ -22,6 +22,7 @@
|
||||
<jackson.version>2.15.4</jackson.version>
|
||||
<picocli.version>4.7.5</picocli.version>
|
||||
<junit.version>5.10.2</junit.version>
|
||||
<lombok.version>1.18.34</lombok.version>
|
||||
<maven.shade.version>3.5.1</maven.shade.version>
|
||||
<maven.deploy.plugin.version>3.1.2</maven.deploy.plugin.version>
|
||||
</properties>
|
||||
@@ -71,11 +72,34 @@
|
||||
<version>${junit.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>${lombok.version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<finalName>serialization-schema-checker-${project.version}</finalName>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.11.0</version>
|
||||
<configuration>
|
||||
<source>${maven.compiler.source}</source>
|
||||
<target>${maven.compiler.target}</target>
|
||||
<annotationProcessorPaths>
|
||||
<path>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>${lombok.version}</version>
|
||||
</path>
|
||||
</annotationProcessorPaths>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-deploy-plugin</artifactId>
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.codechecker.cache.config;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
@@ -8,6 +10,7 @@ import java.util.Map;
|
||||
/**
|
||||
* 检测器运行配置。由 {@link ConfigLoader} 加载 jar 内默认配置并与业务配置深度合并后构建。
|
||||
*/
|
||||
@Data
|
||||
public class CheckerConfig {
|
||||
|
||||
/** 总开关:false 时跳过检测与通知(流水线 exit 0) */
|
||||
@@ -36,89 +39,32 @@ public class CheckerConfig {
|
||||
|
||||
private List<String> excludeModules = new ArrayList<>();
|
||||
|
||||
public boolean isBlockMode() {
|
||||
return "block".equalsIgnoreCase(mode);
|
||||
}
|
||||
|
||||
/** 企微通知相关配置。 */
|
||||
@Data
|
||||
public static class Notify {
|
||||
private boolean enabled = true;
|
||||
/** 企微机器人 Webhook 完整 URL */
|
||||
private String webhookUrl = "";
|
||||
private boolean notifyOnClean = false;
|
||||
private String titlePrefix = "[序列化结构变更]";
|
||||
|
||||
public boolean isEnabled() {
|
||||
return enabled;
|
||||
}
|
||||
|
||||
public void setEnabled(boolean enabled) {
|
||||
this.enabled = enabled;
|
||||
}
|
||||
|
||||
public String getWebhookUrl() {
|
||||
return webhookUrl;
|
||||
}
|
||||
|
||||
public void setWebhookUrl(String webhookUrl) {
|
||||
this.webhookUrl = webhookUrl;
|
||||
}
|
||||
|
||||
public boolean isNotifyOnClean() {
|
||||
return notifyOnClean;
|
||||
}
|
||||
|
||||
public void setNotifyOnClean(boolean notifyOnClean) {
|
||||
this.notifyOnClean = notifyOnClean;
|
||||
}
|
||||
|
||||
public String getTitlePrefix() {
|
||||
return titlePrefix;
|
||||
}
|
||||
|
||||
public void setTitlePrefix(String titlePrefix) {
|
||||
this.titlePrefix = titlePrefix;
|
||||
}
|
||||
}
|
||||
|
||||
/** 忽略规则:key / 文件路径 / 写入方法 / MQ destination。 */
|
||||
@Data
|
||||
public static class Ignore {
|
||||
private List<String> keyPatterns = new ArrayList<>();
|
||||
private List<String> filePatterns = new ArrayList<>();
|
||||
private List<String> writerMethods = new ArrayList<>();
|
||||
/** 忽略的 MQ destination 模式(topic / topic:tag) */
|
||||
private List<String> mqDestinations = new ArrayList<>();
|
||||
|
||||
public List<String> getKeyPatterns() {
|
||||
return keyPatterns;
|
||||
}
|
||||
|
||||
public void setKeyPatterns(List<String> keyPatterns) {
|
||||
this.keyPatterns = keyPatterns;
|
||||
}
|
||||
|
||||
public List<String> getFilePatterns() {
|
||||
return filePatterns;
|
||||
}
|
||||
|
||||
public void setFilePatterns(List<String> filePatterns) {
|
||||
this.filePatterns = filePatterns;
|
||||
}
|
||||
|
||||
public List<String> getWriterMethods() {
|
||||
return writerMethods;
|
||||
}
|
||||
|
||||
public void setWriterMethods(List<String> writerMethods) {
|
||||
this.writerMethods = writerMethods;
|
||||
}
|
||||
|
||||
public List<String> getMqDestinations() {
|
||||
return mqDestinations;
|
||||
}
|
||||
|
||||
public void setMqDestinations(List<String> mqDestinations) {
|
||||
this.mqDestinations = mqDestinations;
|
||||
}
|
||||
}
|
||||
|
||||
/** 检测模式与推断参数(Redis W*、MQ MQ*、读侧补强开关等)。 */
|
||||
@Data
|
||||
public static class Detection {
|
||||
private List<String> patterns = new ArrayList<>();
|
||||
/** MQ 投递检测模式:MQ01~MQ05、MQ-K01~MQ-K04 */
|
||||
@@ -129,255 +75,29 @@ public class CheckerConfig {
|
||||
private boolean readHintsEnabled = true;
|
||||
/** MQ-R:读侧 Listener / parse 补强 */
|
||||
private boolean mqReadHintsEnabled = true;
|
||||
|
||||
public List<String> getPatterns() {
|
||||
return patterns;
|
||||
}
|
||||
|
||||
public void setPatterns(List<String> patterns) {
|
||||
this.patterns = patterns;
|
||||
}
|
||||
|
||||
public List<String> getMqPatterns() {
|
||||
return mqPatterns;
|
||||
}
|
||||
|
||||
public void setMqPatterns(List<String> mqPatterns) {
|
||||
this.mqPatterns = mqPatterns;
|
||||
}
|
||||
|
||||
public double getMinConfidence() {
|
||||
return minConfidence;
|
||||
}
|
||||
|
||||
public void setMinConfidence(double minConfidence) {
|
||||
this.minConfidence = minConfidence;
|
||||
}
|
||||
|
||||
public int getMaxFieldDepth() {
|
||||
return maxFieldDepth;
|
||||
}
|
||||
|
||||
public void setMaxFieldDepth(int maxFieldDepth) {
|
||||
this.maxFieldDepth = maxFieldDepth;
|
||||
}
|
||||
|
||||
public boolean isReadHintsEnabled() {
|
||||
return readHintsEnabled;
|
||||
}
|
||||
|
||||
public void setReadHintsEnabled(boolean readHintsEnabled) {
|
||||
this.readHintsEnabled = readHintsEnabled;
|
||||
}
|
||||
|
||||
public boolean isMqReadHintsEnabled() {
|
||||
return mqReadHintsEnabled;
|
||||
}
|
||||
|
||||
public void setMqReadHintsEnabled(boolean mqReadHintsEnabled) {
|
||||
this.mqReadHintsEnabled = mqReadHintsEnabled;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 人工补充映射:在自动推断不准时指定写入方法对应的 key 模式与 value 类型。
|
||||
*/
|
||||
@Data
|
||||
public static class ManualMapping {
|
||||
private String id;
|
||||
private String writerMethod;
|
||||
private String keyPattern;
|
||||
private String valueType;
|
||||
private String description;
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getWriterMethod() {
|
||||
return writerMethod;
|
||||
}
|
||||
|
||||
public void setWriterMethod(String writerMethod) {
|
||||
this.writerMethod = writerMethod;
|
||||
}
|
||||
|
||||
public String getKeyPattern() {
|
||||
return keyPattern;
|
||||
}
|
||||
|
||||
public void setKeyPattern(String keyPattern) {
|
||||
this.keyPattern = keyPattern;
|
||||
}
|
||||
|
||||
public String getValueType() {
|
||||
return valueType;
|
||||
}
|
||||
|
||||
public void setValueType(String valueType) {
|
||||
this.valueType = valueType;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 抑制规则:对已知误报按 key 模式和/或变更类型跳过告警。
|
||||
*/
|
||||
@Data
|
||||
public static class Suppression {
|
||||
private String id;
|
||||
private String writerMethod;
|
||||
private String keyPattern;
|
||||
private List<String> changeTypes = new ArrayList<>();
|
||||
private String reason;
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getWriterMethod() {
|
||||
return writerMethod;
|
||||
}
|
||||
|
||||
public void setWriterMethod(String writerMethod) {
|
||||
this.writerMethod = writerMethod;
|
||||
}
|
||||
|
||||
public String getKeyPattern() {
|
||||
return keyPattern;
|
||||
}
|
||||
|
||||
public void setKeyPattern(String keyPattern) {
|
||||
this.keyPattern = keyPattern;
|
||||
}
|
||||
|
||||
public List<String> getChangeTypes() {
|
||||
return changeTypes;
|
||||
}
|
||||
|
||||
public void setChangeTypes(List<String> changeTypes) {
|
||||
this.changeTypes = changeTypes;
|
||||
}
|
||||
|
||||
public String getReason() {
|
||||
return reason;
|
||||
}
|
||||
|
||||
public void setReason(String reason) {
|
||||
this.reason = reason;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isEnabled() {
|
||||
return enabled;
|
||||
}
|
||||
|
||||
public void setEnabled(boolean enabled) {
|
||||
this.enabled = enabled;
|
||||
}
|
||||
|
||||
public String getMode() {
|
||||
return mode;
|
||||
}
|
||||
|
||||
public void setMode(String mode) {
|
||||
this.mode = mode;
|
||||
}
|
||||
|
||||
public boolean isScanTestSources() {
|
||||
return scanTestSources;
|
||||
}
|
||||
|
||||
public void setScanTestSources(boolean scanTestSources) {
|
||||
this.scanTestSources = scanTestSources;
|
||||
}
|
||||
|
||||
public List<String> getSourceRoots() {
|
||||
return sourceRoots;
|
||||
}
|
||||
|
||||
public void setSourceRoots(List<String> sourceRoots) {
|
||||
this.sourceRoots = sourceRoots;
|
||||
}
|
||||
|
||||
public Notify getNotify() {
|
||||
return notify;
|
||||
}
|
||||
|
||||
public void setNotify(Notify notify) {
|
||||
this.notify = notify;
|
||||
}
|
||||
|
||||
public Ignore getIgnore() {
|
||||
return ignore;
|
||||
}
|
||||
|
||||
public void setIgnore(Ignore ignore) {
|
||||
this.ignore = ignore;
|
||||
}
|
||||
|
||||
public Detection getDetection() {
|
||||
return detection;
|
||||
}
|
||||
|
||||
public void setDetection(Detection detection) {
|
||||
this.detection = detection;
|
||||
}
|
||||
|
||||
public Map<String, String> getSeverityOverrides() {
|
||||
return severityOverrides;
|
||||
}
|
||||
|
||||
public void setSeverityOverrides(Map<String, String> severityOverrides) {
|
||||
this.severityOverrides = severityOverrides;
|
||||
}
|
||||
|
||||
public List<ManualMapping> getManualMappings() {
|
||||
return manualMappings;
|
||||
}
|
||||
|
||||
public void setManualMappings(List<ManualMapping> manualMappings) {
|
||||
this.manualMappings = manualMappings;
|
||||
}
|
||||
|
||||
public List<Suppression> getSuppressions() {
|
||||
return suppressions;
|
||||
}
|
||||
|
||||
public void setSuppressions(List<Suppression> suppressions) {
|
||||
this.suppressions = suppressions;
|
||||
}
|
||||
|
||||
public List<String> getIncludeModules() {
|
||||
return includeModules;
|
||||
}
|
||||
|
||||
public void setIncludeModules(List<String> includeModules) {
|
||||
this.includeModules = includeModules;
|
||||
}
|
||||
|
||||
public List<String> getExcludeModules() {
|
||||
return excludeModules;
|
||||
}
|
||||
|
||||
public void setExcludeModules(List<String> excludeModules) {
|
||||
this.excludeModules = excludeModules;
|
||||
}
|
||||
|
||||
public boolean isBlockMode() {
|
||||
return "block".equalsIgnoreCase(mode);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
package com.codechecker.cache.detector;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 读侧反序列化类型提示(W06):从 parseObject / getJsonToBean 等推断「缓存 value 被当成什么类型用」。
|
||||
* 不单独产生告警,仅用于补强同文件/同 key 写入点的 value 类型。
|
||||
*/
|
||||
@Data
|
||||
public class CacheReadHint {
|
||||
|
||||
private String filePath;
|
||||
@@ -17,76 +20,4 @@ public class CacheReadHint {
|
||||
private String resolvedValueType;
|
||||
private boolean rootArray;
|
||||
private double confidence = 0.7;
|
||||
|
||||
public String getFilePath() {
|
||||
return filePath;
|
||||
}
|
||||
|
||||
public void setFilePath(String filePath) {
|
||||
this.filePath = filePath;
|
||||
}
|
||||
|
||||
public int getLineNumber() {
|
||||
return lineNumber;
|
||||
}
|
||||
|
||||
public void setLineNumber(int lineNumber) {
|
||||
this.lineNumber = lineNumber;
|
||||
}
|
||||
|
||||
public String getEnclosingClass() {
|
||||
return enclosingClass;
|
||||
}
|
||||
|
||||
public void setEnclosingClass(String enclosingClass) {
|
||||
this.enclosingClass = enclosingClass;
|
||||
}
|
||||
|
||||
public String getEnclosingMethod() {
|
||||
return enclosingMethod;
|
||||
}
|
||||
|
||||
public void setEnclosingMethod(String enclosingMethod) {
|
||||
this.enclosingMethod = enclosingMethod;
|
||||
}
|
||||
|
||||
public String getResolvedKeyPattern() {
|
||||
return resolvedKeyPattern;
|
||||
}
|
||||
|
||||
public void setResolvedKeyPattern(String resolvedKeyPattern) {
|
||||
this.resolvedKeyPattern = resolvedKeyPattern;
|
||||
}
|
||||
|
||||
public String getKeyExpression() {
|
||||
return keyExpression;
|
||||
}
|
||||
|
||||
public void setKeyExpression(String keyExpression) {
|
||||
this.keyExpression = keyExpression;
|
||||
}
|
||||
|
||||
public String getResolvedValueType() {
|
||||
return resolvedValueType;
|
||||
}
|
||||
|
||||
public void setResolvedValueType(String resolvedValueType) {
|
||||
this.resolvedValueType = resolvedValueType;
|
||||
}
|
||||
|
||||
public boolean isRootArray() {
|
||||
return rootArray;
|
||||
}
|
||||
|
||||
public void setRootArray(boolean rootArray) {
|
||||
this.rootArray = rootArray;
|
||||
}
|
||||
|
||||
public double getConfidence() {
|
||||
return confidence;
|
||||
}
|
||||
|
||||
public void setConfidence(double confidence) {
|
||||
this.confidence = confidence;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,13 @@
|
||||
package com.codechecker.cache.detector;
|
||||
|
||||
import lombok.AccessLevel;
|
||||
import lombok.Data;
|
||||
import lombok.Setter;
|
||||
|
||||
/**
|
||||
* 一个 Redis / MQ value 写入(投递)点的静态描述。
|
||||
*/
|
||||
@Data
|
||||
public class WritePoint {
|
||||
|
||||
public static final String CHANNEL_REDIS = "REDIS";
|
||||
@@ -25,8 +30,13 @@ public class WritePoint {
|
||||
private double confidence = 1.0;
|
||||
|
||||
/** REDIS / ROCKETMQ / KAFKA;默认 REDIS 兼容现网 */
|
||||
@Setter(AccessLevel.NONE)
|
||||
private String channel = CHANNEL_REDIS;
|
||||
|
||||
public void setChannel(String channel) {
|
||||
this.channel = channel == null || channel.isEmpty() ? CHANNEL_REDIS : channel;
|
||||
}
|
||||
|
||||
/** 稳定标识:用于在 old/new 两个版本间配对同一写入点 */
|
||||
public String signature() {
|
||||
return enclosingClass + "#" + enclosingMethod + "|" + normalizeKey();
|
||||
@@ -41,102 +51,6 @@ public class WritePoint {
|
||||
return CHANNEL_ROCKETMQ.equals(channel) || CHANNEL_KAFKA.equals(channel);
|
||||
}
|
||||
|
||||
public String getFilePath() {
|
||||
return filePath;
|
||||
}
|
||||
|
||||
public void setFilePath(String filePath) {
|
||||
this.filePath = filePath;
|
||||
}
|
||||
|
||||
public int getLineNumber() {
|
||||
return lineNumber;
|
||||
}
|
||||
|
||||
public void setLineNumber(int lineNumber) {
|
||||
this.lineNumber = lineNumber;
|
||||
}
|
||||
|
||||
public String getEnclosingClass() {
|
||||
return enclosingClass;
|
||||
}
|
||||
|
||||
public void setEnclosingClass(String enclosingClass) {
|
||||
this.enclosingClass = enclosingClass;
|
||||
}
|
||||
|
||||
public String getEnclosingMethod() {
|
||||
return enclosingMethod;
|
||||
}
|
||||
|
||||
public void setEnclosingMethod(String enclosingMethod) {
|
||||
this.enclosingMethod = enclosingMethod;
|
||||
}
|
||||
|
||||
public String getPattern() {
|
||||
return pattern;
|
||||
}
|
||||
|
||||
public void setPattern(String pattern) {
|
||||
this.pattern = pattern;
|
||||
}
|
||||
|
||||
public String getKeyExpression() {
|
||||
return keyExpression;
|
||||
}
|
||||
|
||||
public void setKeyExpression(String keyExpression) {
|
||||
this.keyExpression = keyExpression;
|
||||
}
|
||||
|
||||
public String getResolvedKeyPattern() {
|
||||
return resolvedKeyPattern;
|
||||
}
|
||||
|
||||
public void setResolvedKeyPattern(String resolvedKeyPattern) {
|
||||
this.resolvedKeyPattern = resolvedKeyPattern;
|
||||
}
|
||||
|
||||
public String getValueExpression() {
|
||||
return valueExpression;
|
||||
}
|
||||
|
||||
public void setValueExpression(String valueExpression) {
|
||||
this.valueExpression = valueExpression;
|
||||
}
|
||||
|
||||
public String getResolvedValueType() {
|
||||
return resolvedValueType;
|
||||
}
|
||||
|
||||
public void setResolvedValueType(String resolvedValueType) {
|
||||
this.resolvedValueType = resolvedValueType;
|
||||
}
|
||||
|
||||
public boolean isRootArray() {
|
||||
return rootArray;
|
||||
}
|
||||
|
||||
public void setRootArray(boolean rootArray) {
|
||||
this.rootArray = rootArray;
|
||||
}
|
||||
|
||||
public double getConfidence() {
|
||||
return confidence;
|
||||
}
|
||||
|
||||
public void setConfidence(double confidence) {
|
||||
this.confidence = confidence;
|
||||
}
|
||||
|
||||
public String getChannel() {
|
||||
return channel;
|
||||
}
|
||||
|
||||
public void setChannel(String channel) {
|
||||
this.channel = channel == null || channel.isEmpty() ? CHANNEL_REDIS : channel;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return 展示用写入位置,形如 {@code SimpleClass#method:line}
|
||||
*/
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
package com.codechecker.cache.diff;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 一条结构变更记录:关联 key/destination、写入位置、字段路径与前后取值说明。
|
||||
* <p>由 {@link SchemaDiffer} 或分析器在「新增/删除写入点」时生成,再进入报告明细。</p>
|
||||
*/
|
||||
@Data
|
||||
public class SchemaChange {
|
||||
|
||||
private Severity severity;
|
||||
@@ -21,84 +24,4 @@ public class SchemaChange {
|
||||
this.changeType = changeType;
|
||||
this.severity = changeType.getDefaultSeverity();
|
||||
}
|
||||
|
||||
public Severity getSeverity() {
|
||||
return severity;
|
||||
}
|
||||
|
||||
public void setSeverity(Severity severity) {
|
||||
this.severity = severity;
|
||||
}
|
||||
|
||||
public ChangeType getChangeType() {
|
||||
return changeType;
|
||||
}
|
||||
|
||||
public void setChangeType(ChangeType changeType) {
|
||||
this.changeType = changeType;
|
||||
}
|
||||
|
||||
public String getKeyPattern() {
|
||||
return keyPattern;
|
||||
}
|
||||
|
||||
public void setKeyPattern(String keyPattern) {
|
||||
this.keyPattern = keyPattern;
|
||||
}
|
||||
|
||||
public String getKeyExpression() {
|
||||
return keyExpression;
|
||||
}
|
||||
|
||||
public void setKeyExpression(String keyExpression) {
|
||||
this.keyExpression = keyExpression;
|
||||
}
|
||||
|
||||
public String getWriteLocation() {
|
||||
return writeLocation;
|
||||
}
|
||||
|
||||
public void setWriteLocation(String writeLocation) {
|
||||
this.writeLocation = writeLocation;
|
||||
}
|
||||
|
||||
public String getValueType() {
|
||||
return valueType;
|
||||
}
|
||||
|
||||
public void setValueType(String valueType) {
|
||||
this.valueType = valueType;
|
||||
}
|
||||
|
||||
public String getFieldPath() {
|
||||
return fieldPath;
|
||||
}
|
||||
|
||||
public void setFieldPath(String fieldPath) {
|
||||
this.fieldPath = fieldPath;
|
||||
}
|
||||
|
||||
public String getOldValue() {
|
||||
return oldValue;
|
||||
}
|
||||
|
||||
public void setOldValue(String oldValue) {
|
||||
this.oldValue = oldValue;
|
||||
}
|
||||
|
||||
public String getNewValue() {
|
||||
return newValue;
|
||||
}
|
||||
|
||||
public void setNewValue(String newValue) {
|
||||
this.newValue = newValue;
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public void setMessage(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.codechecker.cache.report;
|
||||
|
||||
import com.codechecker.cache.diff.SchemaChange;
|
||||
import com.codechecker.cache.diff.Severity;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -10,6 +11,7 @@ import java.util.List;
|
||||
* 一次检测的完整结果:元信息、字段级 {@link SchemaChange} 列表、按 Key/Topic 聚合的
|
||||
* {@link KeyStructureChange},以及是否阻断流水线与建议退出码。
|
||||
*/
|
||||
@Data
|
||||
public class CheckReport {
|
||||
|
||||
private String repository;
|
||||
@@ -34,84 +36,4 @@ public class CheckReport {
|
||||
public long count(Severity severity) {
|
||||
return changes.stream().filter(c -> c.getSeverity() == severity).count();
|
||||
}
|
||||
|
||||
public String getRepository() {
|
||||
return repository;
|
||||
}
|
||||
|
||||
public void setRepository(String repository) {
|
||||
this.repository = repository;
|
||||
}
|
||||
|
||||
public String getBranch() {
|
||||
return branch;
|
||||
}
|
||||
|
||||
public void setBranch(String branch) {
|
||||
this.branch = branch;
|
||||
}
|
||||
|
||||
public String getOldSha() {
|
||||
return oldSha;
|
||||
}
|
||||
|
||||
public void setOldSha(String oldSha) {
|
||||
this.oldSha = oldSha;
|
||||
}
|
||||
|
||||
public String getNewSha() {
|
||||
return newSha;
|
||||
}
|
||||
|
||||
public void setNewSha(String newSha) {
|
||||
this.newSha = newSha;
|
||||
}
|
||||
|
||||
public String getModifier() {
|
||||
return modifier;
|
||||
}
|
||||
|
||||
public void setModifier(String modifier) {
|
||||
this.modifier = modifier;
|
||||
}
|
||||
|
||||
public String getModifyTime() {
|
||||
return modifyTime;
|
||||
}
|
||||
|
||||
public void setModifyTime(String modifyTime) {
|
||||
this.modifyTime = modifyTime;
|
||||
}
|
||||
|
||||
public String getMode() {
|
||||
return mode;
|
||||
}
|
||||
|
||||
public void setMode(String mode) {
|
||||
this.mode = mode;
|
||||
}
|
||||
|
||||
public List<SchemaChange> getChanges() {
|
||||
return changes;
|
||||
}
|
||||
|
||||
public List<KeyStructureChange> getKeyChanges() {
|
||||
return keyChanges;
|
||||
}
|
||||
|
||||
public boolean isBlocked() {
|
||||
return blocked;
|
||||
}
|
||||
|
||||
public void setBlocked(boolean blocked) {
|
||||
this.blocked = blocked;
|
||||
}
|
||||
|
||||
public int getExitCode() {
|
||||
return exitCode;
|
||||
}
|
||||
|
||||
public void setExitCode(int exitCode) {
|
||||
this.exitCode = exitCode;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,9 @@ package com.codechecker.cache.report;
|
||||
|
||||
import com.codechecker.cache.diff.SchemaChange;
|
||||
import com.codechecker.cache.diff.Severity;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.Data;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -9,6 +12,7 @@ import java.util.List;
|
||||
/**
|
||||
* 按 Redis key / MQ Topic(或未知时的写入点)聚合后的结构变更摘要。
|
||||
*/
|
||||
@Data
|
||||
public class KeyStructureChange {
|
||||
|
||||
/** 解析到的 key / destination 模式;未知时为 unknown-key */
|
||||
@@ -21,56 +25,13 @@ public class KeyStructureChange {
|
||||
private String valueType;
|
||||
private boolean keyUnresolved;
|
||||
/** REDIS / ROCKETMQ / KAFKA */
|
||||
@Setter(AccessLevel.NONE)
|
||||
private String channel = "REDIS";
|
||||
private String oldSkeletonJson;
|
||||
private String newSkeletonJson;
|
||||
private Severity severity = Severity.P2;
|
||||
private final List<SchemaChange> fieldDetails = new ArrayList<>();
|
||||
|
||||
public String getKeyPattern() {
|
||||
return keyPattern;
|
||||
}
|
||||
|
||||
public void setKeyPattern(String keyPattern) {
|
||||
this.keyPattern = keyPattern;
|
||||
}
|
||||
|
||||
public String getKeyExpression() {
|
||||
return keyExpression;
|
||||
}
|
||||
|
||||
public void setKeyExpression(String keyExpression) {
|
||||
this.keyExpression = keyExpression;
|
||||
}
|
||||
|
||||
public String getWriteLocation() {
|
||||
return writeLocation;
|
||||
}
|
||||
|
||||
public void setWriteLocation(String writeLocation) {
|
||||
this.writeLocation = writeLocation;
|
||||
}
|
||||
|
||||
public String getValueType() {
|
||||
return valueType;
|
||||
}
|
||||
|
||||
public void setValueType(String valueType) {
|
||||
this.valueType = valueType;
|
||||
}
|
||||
|
||||
public boolean isKeyUnresolved() {
|
||||
return keyUnresolved;
|
||||
}
|
||||
|
||||
public void setKeyUnresolved(boolean keyUnresolved) {
|
||||
this.keyUnresolved = keyUnresolved;
|
||||
}
|
||||
|
||||
public String getChannel() {
|
||||
return channel;
|
||||
}
|
||||
|
||||
public void setChannel(String channel) {
|
||||
this.channel = channel == null || channel.isEmpty() ? "REDIS" : channel;
|
||||
}
|
||||
@@ -91,34 +52,6 @@ public class KeyStructureChange {
|
||||
return "Redis";
|
||||
}
|
||||
|
||||
public String getOldSkeletonJson() {
|
||||
return oldSkeletonJson;
|
||||
}
|
||||
|
||||
public void setOldSkeletonJson(String oldSkeletonJson) {
|
||||
this.oldSkeletonJson = oldSkeletonJson;
|
||||
}
|
||||
|
||||
public String getNewSkeletonJson() {
|
||||
return newSkeletonJson;
|
||||
}
|
||||
|
||||
public void setNewSkeletonJson(String newSkeletonJson) {
|
||||
this.newSkeletonJson = newSkeletonJson;
|
||||
}
|
||||
|
||||
public Severity getSeverity() {
|
||||
return severity;
|
||||
}
|
||||
|
||||
public void setSeverity(Severity severity) {
|
||||
this.severity = severity;
|
||||
}
|
||||
|
||||
public List<SchemaChange> getFieldDetails() {
|
||||
return fieldDetails;
|
||||
}
|
||||
|
||||
/**
|
||||
* 用更严重的级别抬升当前聚合严重度(ordinal 更小者优先)。
|
||||
*
|
||||
|
||||
@@ -1,53 +1,17 @@
|
||||
package com.codechecker.cache.schema;
|
||||
|
||||
import java.util.Objects;
|
||||
import lombok.Value;
|
||||
|
||||
/**
|
||||
* 扁平化后的单个字段节点。path 使用点号分隔,数组元素以 {@code []} 标记。
|
||||
* 例如:{@code vo.linkList[].id}。
|
||||
*/
|
||||
@Value
|
||||
public class FieldSchema {
|
||||
|
||||
private final String path;
|
||||
private final JsonType jsonType;
|
||||
private final String javaType;
|
||||
|
||||
public FieldSchema(String path, JsonType jsonType, String javaType) {
|
||||
this.path = path;
|
||||
this.jsonType = jsonType;
|
||||
this.javaType = javaType;
|
||||
}
|
||||
|
||||
public String getPath() {
|
||||
return path;
|
||||
}
|
||||
|
||||
public JsonType getJsonType() {
|
||||
return jsonType;
|
||||
}
|
||||
|
||||
public String getJavaType() {
|
||||
return javaType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (!(o instanceof FieldSchema)) {
|
||||
return false;
|
||||
}
|
||||
FieldSchema that = (FieldSchema) o;
|
||||
return Objects.equals(path, that.path)
|
||||
&& jsonType == that.jsonType
|
||||
&& Objects.equals(javaType, that.javaType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(path, jsonType, javaType);
|
||||
}
|
||||
String path;
|
||||
JsonType jsonType;
|
||||
String javaType;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
|
||||
@@ -6,6 +6,9 @@ import com.github.javaparser.ast.CompilationUnit;
|
||||
import com.github.javaparser.ast.ImportDeclaration;
|
||||
import com.github.javaparser.ast.body.ClassOrInterfaceDeclaration;
|
||||
import com.github.javaparser.ast.body.TypeDeclaration;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
@@ -172,33 +175,12 @@ public class SourceIndex {
|
||||
/**
|
||||
* 索引中的类型条目。
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor(access = AccessLevel.PACKAGE)
|
||||
public static final class IndexedType {
|
||||
private final ClassOrInterfaceDeclaration declaration;
|
||||
private final String packageName;
|
||||
private final List<String> imports;
|
||||
private final String fqn;
|
||||
|
||||
IndexedType(ClassOrInterfaceDeclaration declaration, String packageName, List<String> imports, String fqn) {
|
||||
this.declaration = declaration;
|
||||
this.packageName = packageName;
|
||||
this.imports = imports;
|
||||
this.fqn = fqn;
|
||||
}
|
||||
|
||||
public ClassOrInterfaceDeclaration getDeclaration() {
|
||||
return declaration;
|
||||
}
|
||||
|
||||
public String getPackageName() {
|
||||
return packageName;
|
||||
}
|
||||
|
||||
public List<String> getImports() {
|
||||
return imports;
|
||||
}
|
||||
|
||||
public String getFqn() {
|
||||
return fqn;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +1,19 @@
|
||||
package com.codechecker.cache.schema;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 某个 Redis value 类型展开后的扁平化 Schema:path -> {@link FieldSchema}。
|
||||
*/
|
||||
@Getter
|
||||
public class TypeSchema {
|
||||
|
||||
private final String rootType;
|
||||
@Setter
|
||||
private double confidence = 1.0;
|
||||
private final Map<String, FieldSchema> fields = new LinkedHashMap<>();
|
||||
|
||||
@@ -16,22 +21,6 @@ public class TypeSchema {
|
||||
this.rootType = rootType;
|
||||
}
|
||||
|
||||
public String getRootType() {
|
||||
return rootType;
|
||||
}
|
||||
|
||||
public double getConfidence() {
|
||||
return confidence;
|
||||
}
|
||||
|
||||
public void setConfidence(double confidence) {
|
||||
this.confidence = confidence;
|
||||
}
|
||||
|
||||
public Map<String, FieldSchema> getFields() {
|
||||
return fields;
|
||||
}
|
||||
|
||||
/** 按字段 path 放入(同 path 后者覆盖)。 */
|
||||
public void add(FieldSchema field) {
|
||||
fields.put(field.getPath(), field);
|
||||
|
||||
Reference in New Issue
Block a user