Skip to content

Commit

Permalink
interfacebloat: fix configuration loading (golangci#3194)
Browse files Browse the repository at this point in the history
Co-authored-by: Fernandez Ludovic <ldez@users.noreply.github.com>
  • Loading branch information
2 people authored and SeigeC committed Apr 4, 2023
1 parent f25c2ea commit a12684d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
3 changes: 3 additions & 0 deletions pkg/config/linters_settings.go
Expand Up @@ -62,6 +62,9 @@ var defaultLintersSettings = LintersSettings{
MaxDeclLines: 1,
MaxDeclChars: 30,
},
InterfaceBloat: InterfaceBloatSettings{
Max: 10,
},
Lll: LllSettings{
LineLength: 120,
TabWidth: 1,
Expand Down
10 changes: 6 additions & 4 deletions pkg/golinters/interfacebloat.go
Expand Up @@ -11,17 +11,19 @@ import (
func NewInterfaceBloat(settings *config.InterfaceBloatSettings) *goanalysis.Linter {
a := analyzer.New()

cfgMap := make(map[string]map[string]interface{})
var cfg map[string]map[string]interface{}
if settings != nil {
cfgMap[a.Name] = map[string]interface{}{
analyzer.InterfaceMaxMethodsFlag: settings.Max,
cfg = map[string]map[string]interface{}{
a.Name: {
analyzer.InterfaceMaxMethodsFlag: settings.Max,
},
}
}

return goanalysis.NewLinter(
a.Name,
a.Doc,
[]*analysis.Analyzer{a},
nil,
cfg,
).WithLoadMode(goanalysis.LoadModeSyntax)
}

0 comments on commit a12684d

Please sign in to comment.