package com.codechecker.cache.config; import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; /** * 检测器运行配置。由 {@link ConfigLoader} 加载 jar 内默认配置并与业务配置深度合并后构建。 */ public class CheckerConfig { /** 总开关:false 时跳过检测与通知(流水线 exit 0) */ private boolean enabled = true; /** notify | block */ private String mode = "notify"; private boolean scanTestSources = false; private List sourceRoots = new ArrayList<>(); private Notify notify = new Notify(); private Ignore ignore = new Ignore(); private Detection detection = new Detection(); private Map severityOverrides = new LinkedHashMap<>(); private List manualMappings = new ArrayList<>(); private List suppressions = new ArrayList<>(); private List includeModules = new ArrayList<>(); private List excludeModules = new ArrayList<>(); 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; } } public static class Ignore { private List keyPatterns = new ArrayList<>(); private List filePatterns = new ArrayList<>(); private List writerMethods = new ArrayList<>(); public List getKeyPatterns() { return keyPatterns; } public void setKeyPatterns(List keyPatterns) { this.keyPatterns = keyPatterns; } public List getFilePatterns() { return filePatterns; } public void setFilePatterns(List filePatterns) { this.filePatterns = filePatterns; } public List getWriterMethods() { return writerMethods; } public void setWriterMethods(List writerMethods) { this.writerMethods = writerMethods; } } public static class Detection { private List patterns = new ArrayList<>(); private double minConfidence = 0.6; private int maxFieldDepth = 8; public List getPatterns() { return patterns; } public void setPatterns(List patterns) { this.patterns = patterns; } 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 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; } } public static class Suppression { private String id; private String writerMethod; private String keyPattern; private List 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 getChangeTypes() { return changeTypes; } public void setChangeTypes(List 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 getSourceRoots() { return sourceRoots; } public void setSourceRoots(List 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 getSeverityOverrides() { return severityOverrides; } public void setSeverityOverrides(Map severityOverrides) { this.severityOverrides = severityOverrides; } public List getManualMappings() { return manualMappings; } public void setManualMappings(List manualMappings) { this.manualMappings = manualMappings; } public List getSuppressions() { return suppressions; } public void setSuppressions(List suppressions) { this.suppressions = suppressions; } public List getIncludeModules() { return includeModules; } public void setIncludeModules(List includeModules) { this.includeModules = includeModules; } public List getExcludeModules() { return excludeModules; } public void setExcludeModules(List excludeModules) { this.excludeModules = excludeModules; } public boolean isBlockMode() { return "block".equalsIgnoreCase(mode); } }