Skip to content

Commit 68b8aaa

Browse files
committed
Add check-composites flag to Govet
Ref golangci#446
1 parent de1d1ad commit 68b8aaa

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

pkg/commands/run.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,10 @@ func initFlagSet(fs *pflag.FlagSet, cfg *config.Config, m *lintersdb.Manager, is
108108
"Govet: check for shadowed variables")
109109
hideFlag("govet.check-shadowing")
110110

111+
fs.BoolVar(&lsc.Govet.CheckComposites, "govet.check-composites", true,
112+
"Govet: check for unkeyed composite literals")
113+
hideFlag("govet.check-composites")
114+
111115
fs.Float64Var(&lsc.Golint.MinConfidence, "golint.min-confidence", 0.8,
112116
"Golint: minimum confidence of a problem to print it")
113117
hideFlag("golint.min-confidence")

pkg/config/config.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,8 +172,9 @@ type LintersSettings struct {
172172
}
173173

174174
type GovetSettings struct {
175-
CheckShadowing bool `mapstructure:"check-shadowing"`
176-
Settings map[string]map[string]interface{}
175+
CheckShadowing bool `mapstructure:"check-shadowing"`
176+
CheckComposites bool `mapstructure:"check-composites"`
177+
Settings map[string]map[string]interface{}
177178
}
178179

179180
type ErrcheckSettings struct {

pkg/golinters/govet.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ func NewGovet(cfg *config.GovetSettings) *goanalysis.Linter {
4545
bools.Analyzer,
4646
buildtag.Analyzer,
4747
cgocall.Analyzer,
48-
composite.Analyzer,
4948
copylock.Analyzer,
5049
httpresponse.Analyzer,
5150
loopclosure.Analyzer,
@@ -74,6 +73,9 @@ func NewGovet(cfg *config.GovetSettings) *goanalysis.Linter {
7473
if cfg.CheckShadowing {
7574
analyzers = append(analyzers, shadow.Analyzer)
7675
}
76+
if cfg.CheckComposites {
77+
analyzers = append(analyzers, composite.Analyzer)
78+
}
7779
settings = cfg.Settings
7880
}
7981

0 commit comments

Comments
 (0)