/
exhaustive.go
33 lines (28 loc) · 965 Bytes
/
exhaustive.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package golinters
import (
"github.com/nishanths/exhaustive"
"golang.org/x/tools/go/analysis"
"github.com/golangci/golangci-lint/pkg/config"
"github.com/golangci/golangci-lint/pkg/golinters/goanalysis"
)
func NewExhaustive(settings *config.ExhaustiveSettings) *goanalysis.Linter {
a := exhaustive.Analyzer
var cfg map[string]map[string]interface{}
if settings != nil {
cfg = map[string]map[string]interface{}{
a.Name: {
exhaustive.CheckGeneratedFlag: settings.CheckGenerated,
exhaustive.DefaultSignifiesExhaustiveFlag: settings.DefaultSignifiesExhaustive,
exhaustive.ExplicitExhaustiveMapFlag: settings.ExplicitExhaustiveMap,
exhaustive.ExplicitExhaustiveSwitchFlag: settings.PackageScopeOnly,
exhaustive.IgnoreEnumMembersFlag: settings.IgnoreEnumMembers,
},
}
}
return goanalysis.NewLinter(
a.Name,
a.Doc,
[]*analysis.Analyzer{a},
cfg,
).WithLoadMode(goanalysis.LoadModeTypesInfo)
}