Skip to content

Commit 328b32a

Browse files
committed
fix config validation
1 parent 5e3eae0 commit 328b32a

File tree

4 files changed

+12
-8
lines changed

4 files changed

+12
-8
lines changed

Gopkg.lock

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/commands/run.go

+7-5
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,8 @@ func (e *Executor) parseConfig(cmd *cobra.Command) {
323323
viper.SetConfigFile(configFile)
324324
}
325325

326+
commandLineConfig := *e.cfg // make copy
327+
326328
if err := viper.ReadInConfig(); err != nil {
327329
if _, ok := err.(viper.ConfigFileNotFoundError); ok {
328330
return
@@ -334,22 +336,22 @@ func (e *Executor) parseConfig(cmd *cobra.Command) {
334336
log.Fatalf("Can't unmarshal config by viper: %s", err)
335337
}
336338

337-
if err := e.validateConfig(); err != nil {
339+
if err := e.validateConfig(&commandLineConfig); err != nil {
338340
log.Fatal(err)
339341
}
340342
}
341343

342-
func (e *Executor) validateConfig() error {
344+
func (e *Executor) validateConfig(commandLineConfig *config.Config) error {
343345
c := e.cfg
344346
if len(c.Run.Args) != 0 {
345-
return errors.New("option run.args in config aren't supported now")
347+
return errors.New("option run.args in config isn't supported now")
346348
}
347349

348-
if c.Run.CPUProfilePath != "" {
350+
if commandLineConfig.Run.CPUProfilePath == "" && c.Run.CPUProfilePath != "" {
349351
return errors.New("option run.cpuprofilepath in config isn't allowed")
350352
}
351353

352-
if c.Run.IsVerbose {
354+
if !commandLineConfig.Run.IsVerbose && c.Run.IsVerbose {
353355
return errors.New("can't set run.verbose option with config: only on command-line")
354356
}
355357

pkg/runner.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ func (r SimpleRunner) runGo(ctx context.Context, linters []Linter, lintCtx *goli
111111
finishedN := 0
112112
for res := range lintResultsCh {
113113
if res.err != nil {
114-
logrus.Warnf("Can't run linter %s: %s", res.linter.Name(), res.err)
114+
logrus.Infof("Can't run linter %s: %s", res.linter.Name(), res.err)
115115
continue
116116
}
117117

vendor/github.com/golangci/go-tools/lint/lint.go

+3-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)