From 68b8aaacd09b1591ddc982d5dfa5815f19b214a2 Mon Sep 17 00:00:00 2001 From: Alessio Treglia Date: Mon, 8 Apr 2019 03:05:06 +0100 Subject: [PATCH] Add check-composites flag to Govet Ref #446 --- pkg/commands/run.go | 4 ++++ pkg/config/config.go | 5 +++-- pkg/golinters/govet.go | 4 +++- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/pkg/commands/run.go b/pkg/commands/run.go index 42faf7e2400a..5586bb2ab9b5 100644 --- a/pkg/commands/run.go +++ b/pkg/commands/run.go @@ -108,6 +108,10 @@ func initFlagSet(fs *pflag.FlagSet, cfg *config.Config, m *lintersdb.Manager, is "Govet: check for shadowed variables") hideFlag("govet.check-shadowing") + fs.BoolVar(&lsc.Govet.CheckComposites, "govet.check-composites", true, + "Govet: check for unkeyed composite literals") + hideFlag("govet.check-composites") + fs.Float64Var(&lsc.Golint.MinConfidence, "golint.min-confidence", 0.8, "Golint: minimum confidence of a problem to print it") hideFlag("golint.min-confidence") diff --git a/pkg/config/config.go b/pkg/config/config.go index 720c5e312e2d..5d90862829b2 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -172,8 +172,9 @@ type LintersSettings struct { } type GovetSettings struct { - CheckShadowing bool `mapstructure:"check-shadowing"` - Settings map[string]map[string]interface{} + CheckShadowing bool `mapstructure:"check-shadowing"` + CheckComposites bool `mapstructure:"check-composites"` + Settings map[string]map[string]interface{} } type ErrcheckSettings struct { diff --git a/pkg/golinters/govet.go b/pkg/golinters/govet.go index 683d1a96f0bc..a79c0ada65c7 100644 --- a/pkg/golinters/govet.go +++ b/pkg/golinters/govet.go @@ -45,7 +45,6 @@ func NewGovet(cfg *config.GovetSettings) *goanalysis.Linter { bools.Analyzer, buildtag.Analyzer, cgocall.Analyzer, - composite.Analyzer, copylock.Analyzer, httpresponse.Analyzer, loopclosure.Analyzer, @@ -74,6 +73,9 @@ func NewGovet(cfg *config.GovetSettings) *goanalysis.Linter { if cfg.CheckShadowing { analyzers = append(analyzers, shadow.Analyzer) } + if cfg.CheckComposites { + analyzers = append(analyzers, composite.Analyzer) + } settings = cfg.Settings }