Skip to content

Commit 33de586

Browse files
committed
revive: fix default values
1 parent 0e7233e commit 33de586

File tree

3 files changed

+11
-9
lines changed

3 files changed

+11
-9
lines changed

go.mod

-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ require (
5555
github.com/matoous/godox v0.0.0-20210227103229-6504466cf951 // v1.0
5656
github.com/mattn/go-colorable v0.1.12
5757
github.com/mbilski/exhaustivestruct v1.2.0
58-
github.com/mgechev/dots v0.0.0-20210922191527-e955255bf517
5958
github.com/mgechev/revive v1.1.4
6059
github.com/mitchellh/go-homedir v1.1.0
6160
github.com/mitchellh/go-ps v1.0.0

go.sum

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

pkg/golinters/revive.go

+11-7
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import (
99
"reflect"
1010

1111
"github.com/BurntSushi/toml"
12-
"github.com/mgechev/dots"
1312
reviveConfig "github.com/mgechev/revive/config"
1413
"github.com/mgechev/revive/lint"
1514
"github.com/mgechev/revive/rule"
@@ -50,10 +49,10 @@ func NewRevive(cfg *config.ReviveSettings) *goanalysis.Linter {
5049
).WithContextSetter(func(lintCtx *linter.Context) {
5150
analyzer.Run = func(pass *analysis.Pass) (interface{}, error) {
5251
var files []string
53-
5452
for _, file := range pass.Files {
5553
files = append(files, pass.Fset.PositionFor(file.Pos(), false).Filename)
5654
}
55+
packages := [][]string{files}
5756

5857
conf, err := getReviveConfig(cfg)
5958
if err != nil {
@@ -72,11 +71,6 @@ func NewRevive(cfg *config.ReviveSettings) *goanalysis.Linter {
7271
return nil, err
7372
}
7473

75-
packages, err := dots.ResolvePackages(files, []string{})
76-
if err != nil {
77-
return nil, err
78-
}
79-
8074
failures, err := revive.Lint(packages, lintingRules, *conf)
8175
if err != nil {
8276
return nil, err
@@ -315,6 +309,16 @@ const defaultConfidence = 0.8
315309
// This element is not exported by revive, so we need copy the code.
316310
// Extracted from https://github.com/mgechev/revive/blob/v1.1.4/config/config.go#L145
317311
func normalizeConfig(cfg *lint.Config) {
312+
// NOTE: custom section must be keep.
313+
// ---
314+
if cfg.Confidence == 0 {
315+
cfg.Confidence = defaultConfidence
316+
}
317+
if cfg.Severity == "" {
318+
cfg.Severity = lint.SeverityWarning
319+
}
320+
// ---
321+
318322
if len(cfg.Rules) == 0 {
319323
cfg.Rules = map[string]lint.RuleConfig{}
320324
}

0 commit comments

Comments
 (0)