17
17
package plugin
18
18
19
19
import (
20
- "fillmore-labs.com/zerolint/pkg/analyzer"
20
+ "regexp"
21
+
22
+ "fillmore-labs.com/zerolint/pkg/zerolint"
23
+ "fillmore-labs.com/zerolint/pkg/zerolint/level"
21
24
"github.com/golangci/plugin-module-register/register"
22
25
"golang.org/x/tools/go/analysis"
23
- "golang.org/x/tools/go/analysis/passes/inspect"
24
26
)
25
27
26
- // Name is the linters name.
27
- const Name = "zerolint"
28
-
29
28
func init () { //nolint:gochecknoinits
30
- register .Plugin (Name , New )
29
+ register .Plugin (zerolint . Name , New )
31
30
}
32
31
33
32
// Settings are the linters settings.
34
33
type Settings struct {
35
- Excluded []string `json:"excluded"`
36
- Full bool `json:"full"`
34
+ Excluded []string `json:"excluded,omitempty"`
35
+ Level level.LintLevel `json:"level,omitempty"`
36
+ Match * regexp.Regexp `json:"match,omitempty"`
37
+ Generated bool `json:"generated,omitempty"`
37
38
}
38
39
39
40
// New creates a new [Plugin] instance with the given [Settings].
@@ -53,20 +54,14 @@ type Plugin struct {
53
54
54
55
// BuildAnalyzers returns the [analysis.Analyzer]s for a zerolint run.
55
56
func (p Plugin ) BuildAnalyzers () ([]* analysis.Analyzer , error ) {
56
- run := analyzer .NewRun (
57
- analyzer .WithExcludes (p .settings .Excluded ),
58
- analyzer .WithFull (p .settings .Full ),
59
- analyzer .WithGenerated (true ),
57
+ z := zerolint .New (
58
+ zerolint .WithLevel (p .settings .Level ),
59
+ zerolint .WithExcludes (p .settings .Excluded ),
60
+ zerolint .WithRegex (p .settings .Match ),
61
+ zerolint .WithGenerated (p .settings .Generated ),
60
62
)
61
63
62
- analyzer := & analysis.Analyzer {
63
- Name : Name ,
64
- Doc : analyzer .Doc ,
65
- Run : run ,
66
- Requires : []* analysis.Analyzer {inspect .Analyzer },
67
- }
68
-
69
- return []* analysis.Analyzer {analyzer }, nil
64
+ return []* analysis.Analyzer {z }, nil
70
65
}
71
66
72
67
// GetLoadMode returns the golangci load mode.
0 commit comments