Merge pull request #5 from golangci/feature/fix-config-validation
fix config validation
This commit is contained in:
commit
3a5d2a46fd
2
Gopkg.lock
generated
2
Gopkg.lock
generated
@ -91,7 +91,7 @@
|
||||
"unused",
|
||||
"version"
|
||||
]
|
||||
revision = "d26f272c11fdcbab5d498e7fb88587ac179f3235"
|
||||
revision = "e37cd5dbe6dac91e427e242d7fb61cc92201c8bf"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
|
@ -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")
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
|
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"
|
||||
"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()
|
||||
|
Loading…
x
Reference in New Issue
Block a user