fix config validation
This commit is contained in:
parent
5e3eae0cf1
commit
328b32ac61
2
Gopkg.lock
generated
2
Gopkg.lock
generated
@ -91,7 +91,7 @@
|
|||||||
"unused",
|
"unused",
|
||||||
"version"
|
"version"
|
||||||
]
|
]
|
||||||
revision = "d26f272c11fdcbab5d498e7fb88587ac179f3235"
|
revision = "e37cd5dbe6dac91e427e242d7fb61cc92201c8bf"
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
branch = "master"
|
branch = "master"
|
||||||
|
@ -323,6 +323,8 @@ func (e *Executor) parseConfig(cmd *cobra.Command) {
|
|||||||
viper.SetConfigFile(configFile)
|
viper.SetConfigFile(configFile)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
commandLineConfig := *e.cfg // make copy
|
||||||
|
|
||||||
if err := viper.ReadInConfig(); err != nil {
|
if err := viper.ReadInConfig(); err != nil {
|
||||||
if _, ok := err.(viper.ConfigFileNotFoundError); ok {
|
if _, ok := err.(viper.ConfigFileNotFoundError); ok {
|
||||||
return
|
return
|
||||||
@ -334,22 +336,22 @@ func (e *Executor) parseConfig(cmd *cobra.Command) {
|
|||||||
log.Fatalf("Can't unmarshal config by viper: %s", err)
|
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)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *Executor) validateConfig() error {
|
func (e *Executor) validateConfig(commandLineConfig *config.Config) error {
|
||||||
c := e.cfg
|
c := e.cfg
|
||||||
if len(c.Run.Args) != 0 {
|
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")
|
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")
|
return errors.New("can't set run.verbose option with config: only on command-line")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -111,7 +111,7 @@ func (r SimpleRunner) runGo(ctx context.Context, linters []Linter, lintCtx *goli
|
|||||||
finishedN := 0
|
finishedN := 0
|
||||||
for res := range lintResultsCh {
|
for res := range lintResultsCh {
|
||||||
if res.err != nil {
|
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
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
4
vendor/github.com/golangci/go-tools/lint/lint.go
generated
vendored
4
vendor/github.com/golangci/go-tools/lint/lint.go
generated
vendored
@ -18,6 +18,7 @@ import (
|
|||||||
"go/types"
|
"go/types"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
"runtime/debug"
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
@ -423,7 +424,8 @@ func (l *Linter) Lint(lprog *loader.Program, conf *loader.Config, ssaprog *ssa.P
|
|||||||
go func(i int, j *Job) {
|
go func(i int, j *Job) {
|
||||||
defer func() {
|
defer func() {
|
||||||
if err := recover(); err != nil {
|
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()
|
defer wg.Done()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user