Skip to content

Commit

Permalink
Address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
doriable committed Dec 19, 2024
1 parent e5d360e commit bdf16b9
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 33 deletions.
20 changes: 6 additions & 14 deletions private/buf/cmd/buf/command/breaking/breaking.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,20 +220,12 @@ func run(
}()
// We add all check configs (both lint and breaking) as related configs to check if plugins
// have rules configured.
allCheckConfigs := append(
slicesext.Map(
imageWithConfigs,
func(imageWithConfig bufctl.ImageWithConfig) bufconfig.CheckConfig {
return imageWithConfig.LintConfig()
},
),
slicesext.Map(
imageWithConfigs,
func(imageWithConfig bufctl.ImageWithConfig) bufconfig.CheckConfig {
return imageWithConfig.BreakingConfig()
},
)...,
)
// We allocated twice the size of imageWithConfigs for both lint and breaking configs.
allCheckConfigs := make([]bufconfig.CheckConfig, 0, len(imageWithConfigs)*2)
for _, imageWithConfig := range imageWithConfigs {
allCheckConfigs = append(allCheckConfigs, imageWithConfig.LintConfig())
allCheckConfigs = append(allCheckConfigs, imageWithConfig.BreakingConfig())
}
var allFileAnnotations []bufanalysis.FileAnnotation
for i, imageWithConfig := range imageWithConfigs {
client, err := bufcheck.NewClient(
Expand Down
10 changes: 6 additions & 4 deletions private/buf/cmd/buf/command/config/internal/internal.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,10 +239,12 @@ func lsRun(
var checkConfig bufconfig.CheckConfig
// We add all check configs (both lint and breaking) as related configs to check if plugins
// have rules configured.
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() })...,
)
// We allocated twice the size of moduleConfigs for both lint and breaking configs.
allCheckConfigs := make([]bufconfig.CheckConfig, 0, len(moduleConfigs)*2)
for _, moduleConfig := range moduleConfigs {
allCheckConfigs = append(allCheckConfigs, moduleConfig.LintConfig())
allCheckConfigs = append(allCheckConfigs, moduleConfig.BreakingConfig())
}
switch ruleType {
case check.RuleTypeLint:
checkConfig = moduleConfig.LintConfig()
Expand Down
21 changes: 6 additions & 15 deletions private/buf/cmd/buf/command/lint/lint.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import (
"github.com/bufbuild/buf/private/bufpkg/bufplugin"
"github.com/bufbuild/buf/private/pkg/app/appcmd"
"github.com/bufbuild/buf/private/pkg/app/appext"
"github.com/bufbuild/buf/private/pkg/slicesext"
"github.com/bufbuild/buf/private/pkg/stringutil"
"github.com/bufbuild/buf/private/pkg/wasm"
"github.com/spf13/pflag"
Expand Down Expand Up @@ -147,20 +146,12 @@ func run(
var allFileAnnotations []bufanalysis.FileAnnotation
// We add all check configs (both lint and breaking) as related configs to check if plugins
// have rules configured.
allCheckConfigs := append(
slicesext.Map(
imageWithConfigs,
func(imageWithConfig bufctl.ImageWithConfig) bufconfig.CheckConfig {
return imageWithConfig.LintConfig()
},
),
slicesext.Map(
imageWithConfigs,
func(imageWithConfig bufctl.ImageWithConfig) bufconfig.CheckConfig {
return imageWithConfig.BreakingConfig()
},
)...,
)
// We allocated twice the size of imageWithConfigs for both lint and breaking configs.
allCheckConfigs := make([]bufconfig.CheckConfig, 0, len(imageWithConfigs)*2)
for _, imageWithConfig := range imageWithConfigs {
allCheckConfigs = append(allCheckConfigs, imageWithConfig.LintConfig())
allCheckConfigs = append(allCheckConfigs, imageWithConfig.BreakingConfig())
}
for _, imageWithConfig := range imageWithConfigs {
client, err := bufcheck.NewClient(
container.Logger(),
Expand Down

0 comments on commit bdf16b9

Please sign in to comment.