unparam 死代码清理 12→2(保留 2 处 objectstore 构造函数统一签名):移除 10 处恒 nil error / 从未使用的结果(getPoWConfigForRoute 的恒 nil *PoWConfig、getSQLiteOverview/getPostgresOverview/getStatus/loadKumaConfig/filterExpectedRoutes 的恒 nil error、rawJSONString/parsePositiveInt 的弃用 bool、buildProxyRoute 的弃用 []ZoneDomain、getLocked 的恒 nil error),同步简化 12+ 处调用方与死错误检查。9 个受影响包测试通过。metric 持平 8(改进在基准之外)。

Result: {"status":"keep","total_issues":8,"golint_canonicalheader":0,"golint_errname":0,"golint_errorlint":1,"golint_exhaustive":0,"golint_forcetypeassert":0,"golint_gosec":0,"golint_intrange":0,"golint_modernize":3,"golint_nilnil":3,"golint_perfsprint":0,"golint_prealloc":0,"golint_recvcheck":1,"golint_usestdlibvars":0,"golint_wastedassign":0,"golint_total":8,"golint_test_testifylint":0,"golint_test_thelper":0,"golint_test_usetesting":0,"golint_test_total":0,"golint_vetx_total":0,"eslint_problems":0,"eslint_errors":0,"eslint_warnings":0,"tsc_errors":0,"measure_s":43}
This commit is contained in:
ryan
2026-08-16 18:29:51 +08:00
parent d7b8f44f90
commit c85373ff47
12 changed files with 64 additions and 80 deletions
+7 -13
View File
@@ -33,7 +33,7 @@ type kumaConfig struct {
}
// loadKumaConfig 从 SystemConfig 加载 UptimeKuma 配置
func loadKumaConfig(ctx context.Context) (*kumaConfig, error) {
func loadKumaConfig(ctx context.Context) *kumaConfig {
url, _ := repository.GetSystemConfigByKey(ctx, model.ConfigKeyUptimeKumaURL)
username, _ := repository.GetSystemConfigByKey(ctx, model.ConfigKeyUptimeKumaUsername)
password, _ := repository.GetSystemConfigByKey(ctx, model.ConfigKeyUptimeKumaPassword)
@@ -68,7 +68,7 @@ func loadKumaConfig(ctx context.Context) (*kumaConfig, error) {
Retry: retry,
RetryInterval: retryInterval,
Timeout: timeout,
}, nil
}
}
// SyncToUptimeKuma synchronizes enabled proxy routes to Uptime Kuma monitors.
@@ -85,10 +85,7 @@ func SyncToUptimeKuma(ctx context.Context) error {
defer isSyncing.Store(false)
// 加载配置
config, err := loadKumaConfig(ctx)
if err != nil {
return err
}
config := loadKumaConfig(ctx)
// 验证配置
if err := validateKumaConfig(config); err != nil {
@@ -106,10 +103,7 @@ func SyncToUptimeKuma(ctx context.Context) error {
return fmt.Errorf("failed to list local proxy routes: %w", err)
}
expectedRoutes, err := filterExpectedRoutes(allRoutes, config)
if err != nil {
return err
}
expectedRoutes := filterExpectedRoutes(allRoutes, config)
client, err := connectAndLoginUptimeKuma(config.URL, config.Username, config.Password)
if err != nil {
@@ -129,7 +123,7 @@ func SyncToUptimeKuma(ctx context.Context) error {
return nil
}
func filterExpectedRoutes(allRoutes []*model.ProxyRoute, config *kumaConfig) ([]*model.ProxyRoute, error) {
func filterExpectedRoutes(allRoutes []*model.ProxyRoute, config *kumaConfig) []*model.ProxyRoute {
scope := config.MonitorScope
if scope == "selected" {
selectedList := strings.Split(config.SelectedSites, ",")
@@ -146,7 +140,7 @@ func filterExpectedRoutes(allRoutes []*model.ProxyRoute, config *kumaConfig) ([]
expectedRoutes = append(expectedRoutes, route)
}
}
return expectedRoutes, nil
return expectedRoutes
}
var expectedRoutes []*model.ProxyRoute
@@ -155,7 +149,7 @@ func filterExpectedRoutes(allRoutes []*model.ProxyRoute, config *kumaConfig) ([]
expectedRoutes = append(expectedRoutes, route)
}
}
return expectedRoutes, nil
return expectedRoutes
}
func ensureOpenFlareTag(client *SocketIOClient) (int, error) {