Skip to content

Commit

Permalink
review
Browse files Browse the repository at this point in the history
  • Loading branch information
ldez committed Dec 17, 2022
1 parent 740c158 commit d38a6ca
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 22 deletions.
2 changes: 2 additions & 0 deletions .golangci.reference.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2002,6 +2002,7 @@ linters:
- forcetypeassert
- funlen
- gci
- ginkgolinter
- gochecknoglobals
- gochecknoinits
- gocognit
Expand Down Expand Up @@ -2109,6 +2110,7 @@ linters:
- forcetypeassert
- funlen
- gci
- ginkgolinter
- gochecknoglobals
- gochecknoinits
- gocognit
Expand Down
7 changes: 2 additions & 5 deletions pkg/config/linters_settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,6 @@ var defaultLintersSettings = LintersSettings{
Sections: []string{"standard", "default"},
SkipGenerated: true,
},
GinkgoLinter: GinkgolinterSettings{
SuppressLenAssertion: false,
},
Gocognit: GocognitSettings{
MinComplexity: 30,
},
Expand Down Expand Up @@ -153,7 +150,7 @@ type LintersSettings struct {
Forbidigo ForbidigoSettings
Funlen FunlenSettings
Gci GciSettings
GinkgoLinter GinkgolinterSettings
GinkgoLinter GinkgoLinterSettings
Gocognit GocognitSettings
Goconst GoConstSettings
Gocritic GoCriticSettings
Expand Down Expand Up @@ -325,7 +322,7 @@ type GciSettings struct {
CustomOrder bool `mapstructure:"custom-order"`
}

type GinkgolinterSettings struct {
type GinkgoLinterSettings struct {
SuppressLenAssertion bool `mapstructure:"suppress-len-assertion"`
SuppressNilAssertion bool `mapstructure:"suppress-nil-assertion"`
SuppressErrAssertion bool `mapstructure:"suppress-err-assertion"`
Expand Down
21 changes: 5 additions & 16 deletions pkg/golinters/ginkgolinter.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,15 @@ import (
"github.com/golangci/golangci-lint/pkg/golinters/goanalysis"
)

func NewGinkgoLinter(cfg *config.GinkgolinterSettings) *goanalysis.Linter {
func NewGinkgoLinter(cfg *config.GinkgoLinterSettings) *goanalysis.Linter {
a := ginkgolinter.NewAnalyzer()

cfgMap := make(map[string]map[string]interface{})
if cfg != nil {
settings := make(map[string]interface{})
if cfg.SuppressLenAssertion {
settings["suppress-len-assertion"] = true
}

if cfg.SuppressNilAssertion {
settings["suppress-nil-assertion"] = true
}

if cfg.SuppressErrAssertion {
settings["suppress-err-assertion"] = true
}

if len(settings) > 0 {
cfgMap[a.Name] = settings
cfgMap[a.Name] = map[string]interface{}{
"suppress-len-assertion": cfg.SuppressLenAssertion,
"suppress-nil-assertion": cfg.SuppressNilAssertion,
"suppress-err-assertion": cfg.SuppressErrAssertion,
}
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/lint/lintersdb/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ func (m Manager) GetAllSupportedLinterConfigs() []*linter.Config {
forbidigoCfg *config.ForbidigoSettings
funlenCfg *config.FunlenSettings
gciCfg *config.GciSettings
ginkgolinterCfg *config.GinkgolinterSettings
ginkgolinterCfg *config.GinkgoLinterSettings
gocognitCfg *config.GocognitSettings
goconstCfg *config.GoConstSettings
gocriticCfg *config.GoCriticSettings
Expand Down

0 comments on commit d38a6ca

Please sign in to comment.