From 7df59504653cda68a3ce8f82734e9e88a5331c36 Mon Sep 17 00:00:00 2001 From: Doria Keung Date: Wed, 18 Dec 2024 14:49:53 -0500 Subject: [PATCH] Fix related check configs for ls-rules --- private/buf/cmd/buf/command/config/internal/internal.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/private/buf/cmd/buf/command/config/internal/internal.go b/private/buf/cmd/buf/command/config/internal/internal.go index 995f1b9007..4803bfeb84 100644 --- a/private/buf/cmd/buf/command/config/internal/internal.go +++ b/private/buf/cmd/buf/command/config/internal/internal.go @@ -211,10 +211,6 @@ func lsRun( var rules []bufcheck.Rule if flags.ConfiguredOnly { moduleConfigs := bufYAMLFile.ModuleConfigs() - allCheckConfigs := append( - slicesext.Map(moduleConfigs, func(moduleConfig bufconfig.ModuleConfig) bufconfig.CheckConfig { return moduleConfig.LintConfig() }), - slicesext.Map(moduleConfigs, func(moduleConfig bufconfig.ModuleConfig) bufconfig.CheckConfig { return moduleConfig.BreakingConfig() })..., - ) var moduleConfig bufconfig.ModuleConfig switch fileVersion := bufYAMLFile.FileVersion(); fileVersion { case bufconfig.FileVersionV1Beta1, bufconfig.FileVersionV1: @@ -241,17 +237,20 @@ func lsRun( return syserror.Newf("unknown FileVersion: %v", fileVersion) } var checkConfig bufconfig.CheckConfig + var relatedCheckConfigsForType []bufconfig.CheckConfig switch ruleType { case check.RuleTypeLint: checkConfig = moduleConfig.LintConfig() + relatedCheckConfigsForType = slicesext.Map(moduleConfigs, func(moduleConfig bufconfig.ModuleConfig) bufconfig.CheckConfig { return moduleConfig.LintConfig() }) case check.RuleTypeBreaking: checkConfig = moduleConfig.BreakingConfig() + relatedCheckConfigsForType = slicesext.Map(moduleConfigs, func(moduleConfig bufconfig.ModuleConfig) bufconfig.CheckConfig { return moduleConfig.BreakingConfig() }) default: return fmt.Errorf("unknown check.RuleType: %v", ruleType) } configuredRuleOptions := []bufcheck.ConfiguredRulesOption{ bufcheck.WithPluginConfigs(bufYAMLFile.PluginConfigs()...), - bufcheck.WithRelatedCheckConfigs(allCheckConfigs...), + bufcheck.WithRelatedCheckConfigs(relatedCheckConfigsForType...), } rules, err = client.ConfiguredRules( ctx,