From 328b32ac611c573b8ae0a8b5f8ee1f134ddd5017 Mon Sep 17 00:00:00 2001 From: golangci Date: Sat, 19 May 2018 13:07:55 +0300 Subject: [PATCH] fix config validation --- Gopkg.lock | 2 +- pkg/commands/run.go | 12 +++++++----- pkg/runner.go | 2 +- vendor/github.com/golangci/go-tools/lint/lint.go | 4 +++- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/Gopkg.lock b/Gopkg.lock index d2b397e9..16e821df 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -91,7 +91,7 @@ "unused", "version" ] - revision = "d26f272c11fdcbab5d498e7fb88587ac179f3235" + revision = "e37cd5dbe6dac91e427e242d7fb61cc92201c8bf" [[projects]] branch = "master" diff --git a/pkg/commands/run.go b/pkg/commands/run.go index d16ef2df..a18f9095 100644 --- a/pkg/commands/run.go +++ b/pkg/commands/run.go @@ -323,6 +323,8 @@ func (e *Executor) parseConfig(cmd *cobra.Command) { viper.SetConfigFile(configFile) } + commandLineConfig := *e.cfg // make copy + if err := viper.ReadInConfig(); err != nil { if _, ok := err.(viper.ConfigFileNotFoundError); ok { return @@ -334,22 +336,22 @@ func (e *Executor) parseConfig(cmd *cobra.Command) { log.Fatalf("Can't unmarshal config by viper: %s", err) } - if err := e.validateConfig(); err != nil { + if err := e.validateConfig(&commandLineConfig); err != nil { log.Fatal(err) } } -func (e *Executor) validateConfig() error { +func (e *Executor) validateConfig(commandLineConfig *config.Config) error { c := e.cfg if len(c.Run.Args) != 0 { - return errors.New("option run.args in config aren't supported now") + return errors.New("option run.args in config isn't supported now") } - if c.Run.CPUProfilePath != "" { + if commandLineConfig.Run.CPUProfilePath == "" && c.Run.CPUProfilePath != "" { return errors.New("option run.cpuprofilepath in config isn't allowed") } - if c.Run.IsVerbose { + if !commandLineConfig.Run.IsVerbose && c.Run.IsVerbose { return errors.New("can't set run.verbose option with config: only on command-line") } diff --git a/pkg/runner.go b/pkg/runner.go index 978d251b..92d797d9 100644 --- a/pkg/runner.go +++ b/pkg/runner.go @@ -111,7 +111,7 @@ func (r SimpleRunner) runGo(ctx context.Context, linters []Linter, lintCtx *goli finishedN := 0 for res := range lintResultsCh { if res.err != nil { - logrus.Warnf("Can't run linter %s: %s", res.linter.Name(), res.err) + logrus.Infof("Can't run linter %s: %s", res.linter.Name(), res.err) continue } diff --git a/vendor/github.com/golangci/go-tools/lint/lint.go b/vendor/github.com/golangci/go-tools/lint/lint.go index f33c56c6..cd574a3c 100644 --- a/vendor/github.com/golangci/go-tools/lint/lint.go +++ b/vendor/github.com/golangci/go-tools/lint/lint.go @@ -18,6 +18,7 @@ import ( "go/types" "path/filepath" "runtime" + "runtime/debug" "sort" "strings" "sync" @@ -423,7 +424,8 @@ func (l *Linter) Lint(lprog *loader.Program, conf *loader.Config, ssaprog *ssa.P go func(i int, j *Job) { defer func() { if err := recover(); err != nil { - crashesMap.Store(i, err) + perr := fmt.Errorf("panic: %s, stack: %s", err, debug.Stack()) + crashesMap.Store(i, perr) } }() defer wg.Done()