@@ -23,17 +23,20 @@ import (
23
23
"golang.org/x/tools/go/analysis/passes/inspect"
24
24
)
25
25
26
+ // Name is the linters name.
26
27
const Name = "zerolint"
27
28
28
29
func init () { //nolint:gochecknoinits
29
30
register .Plugin (Name , New )
30
31
}
31
32
33
+ // Settings are the linters settings.
32
34
type Settings struct {
33
35
Excluded []string `json:"excluded"`
34
36
Full bool `json:"full"`
35
37
}
36
38
39
+ // New creates a new [Plugin] instance with the given [Settings].
37
40
func New (settings any ) (register.LinterPlugin , error ) { //nolint:ireturn
38
41
s , err := register.DecodeSettings [Settings ](settings )
39
42
if err != nil {
@@ -43,10 +46,12 @@ func New(settings any) (register.LinterPlugin, error) { //nolint:ireturn
43
46
return Plugin {settings : s }, nil
44
47
}
45
48
49
+ // Plugin is a zerolint linter as a [register.LinterPlugin].
46
50
type Plugin struct {
47
51
settings Settings
48
52
}
49
53
54
+ // BuildAnalyzers returns the [analysis.Analyzer]s for a zerolint run.
50
55
func (p Plugin ) BuildAnalyzers () ([]* analysis.Analyzer , error ) {
51
56
run := analyzer .NewRun (
52
57
analyzer .WithExcludes (p .settings .Excluded ),
@@ -64,6 +69,7 @@ func (p Plugin) BuildAnalyzers() ([]*analysis.Analyzer, error) {
64
69
return []* analysis.Analyzer {analyzer }, nil
65
70
}
66
71
72
+ // GetLoadMode returns the golangci load mode.
67
73
func (Plugin ) GetLoadMode () string {
68
74
return register .LoadModeTypesInfo
69
75
}
0 commit comments