@@ -10,7 +10,7 @@ import (
10
10
"strings"
11
11
"sync"
12
12
13
- "github.com/go-lintpack/lintpack "
13
+ gocriticlinter "github.com/go-critic/go-critic/framework/linter "
14
14
"golang.org/x/tools/go/analysis"
15
15
16
16
"github.com/golangci/golangci-lint/pkg/config"
@@ -38,15 +38,15 @@ func NewGocritic() *goanalysis.Linter {
38
38
nil ,
39
39
).WithContextSetter (func (lintCtx * linter.Context ) {
40
40
analyzer .Run = func (pass * analysis.Pass ) (interface {}, error ) {
41
- lintpackCtx := lintpack .NewContext (pass .Fset , sizes )
42
- enabledCheckers , err := buildEnabledCheckers (lintCtx , lintpackCtx )
41
+ linterCtx := gocriticlinter .NewContext (pass .Fset , sizes )
42
+ enabledCheckers , err := buildEnabledCheckers (lintCtx , linterCtx )
43
43
if err != nil {
44
44
return nil , err
45
45
}
46
46
47
- lintpackCtx .SetPackageInfo (pass .TypesInfo , pass .Pkg )
47
+ linterCtx .SetPackageInfo (pass .TypesInfo , pass .Pkg )
48
48
var res []goanalysis.Issue
49
- pkgIssues := runGocriticOnPackage (lintpackCtx , enabledCheckers , pass .Files )
49
+ pkgIssues := runGocriticOnPackage (linterCtx , enabledCheckers , pass .Files )
50
50
for i := range pkgIssues {
51
51
res = append (res , goanalysis .NewIssue (& pkgIssues [i ], pass ))
52
52
}
@@ -65,17 +65,17 @@ func NewGocritic() *goanalysis.Linter {
65
65
}).WithLoadMode (goanalysis .LoadModeTypesInfo )
66
66
}
67
67
68
- func normalizeCheckerInfoParams (info * lintpack .CheckerInfo ) lintpack .CheckerParams {
68
+ func normalizeCheckerInfoParams (info * gocriticlinter .CheckerInfo ) gocriticlinter .CheckerParams {
69
69
// lowercase info param keys here because golangci-lint's config parser lowercases all strings
70
- ret := lintpack .CheckerParams {}
70
+ ret := gocriticlinter .CheckerParams {}
71
71
for k , v := range info .Params {
72
72
ret [strings .ToLower (k )] = v
73
73
}
74
74
75
75
return ret
76
76
}
77
77
78
- func configureCheckerInfo (info * lintpack .CheckerInfo , allParams map [string ]config.GocriticCheckSettings ) error {
78
+ func configureCheckerInfo (info * gocriticlinter .CheckerInfo , allParams map [string ]config.GocriticCheckSettings ) error {
79
79
params := allParams [strings .ToLower (info .Name )]
80
80
if params == nil { // no config for this checker
81
81
return nil
@@ -108,12 +108,12 @@ func configureCheckerInfo(info *lintpack.CheckerInfo, allParams map[string]confi
108
108
return nil
109
109
}
110
110
111
- func buildEnabledCheckers (lintCtx * linter.Context , lintpackCtx * lintpack .Context ) ([]* lintpack .Checker , error ) {
111
+ func buildEnabledCheckers (lintCtx * linter.Context , linterCtx * gocriticlinter .Context ) ([]* gocriticlinter .Checker , error ) {
112
112
s := lintCtx .Settings ().Gocritic
113
113
allParams := s .GetLowercasedParams ()
114
114
115
- var enabledCheckers []* lintpack .Checker
116
- for _ , info := range lintpack .GetCheckersInfo () {
115
+ var enabledCheckers []* gocriticlinter .Checker
116
+ for _ , info := range gocriticlinter .GetCheckersInfo () {
117
117
if ! s .IsCheckEnabled (info .Name ) {
118
118
continue
119
119
}
@@ -122,27 +122,27 @@ func buildEnabledCheckers(lintCtx *linter.Context, lintpackCtx *lintpack.Context
122
122
return nil , err
123
123
}
124
124
125
- c := lintpack .NewChecker (lintpackCtx , info )
125
+ c := gocriticlinter .NewChecker (linterCtx , info )
126
126
enabledCheckers = append (enabledCheckers , c )
127
127
}
128
128
129
129
return enabledCheckers , nil
130
130
}
131
131
132
- func runGocriticOnPackage (lintpackCtx * lintpack .Context , checkers []* lintpack .Checker ,
132
+ func runGocriticOnPackage (linterCtx * gocriticlinter .Context , checkers []* gocriticlinter .Checker ,
133
133
files []* ast.File ) []result.Issue {
134
134
var res []result.Issue
135
135
for _ , f := range files {
136
- filename := filepath .Base (lintpackCtx .FileSet .Position (f .Pos ()).Filename )
137
- lintpackCtx .SetFileInfo (filename , f )
136
+ filename := filepath .Base (linterCtx .FileSet .Position (f .Pos ()).Filename )
137
+ linterCtx .SetFileInfo (filename , f )
138
138
139
- issues := runGocriticOnFile (lintpackCtx , f , checkers )
139
+ issues := runGocriticOnFile (linterCtx , f , checkers )
140
140
res = append (res , issues ... )
141
141
}
142
142
return res
143
143
}
144
144
145
- func runGocriticOnFile (ctx * lintpack .Context , f * ast.File , checkers []* lintpack .Checker ) []result.Issue {
145
+ func runGocriticOnFile (ctx * gocriticlinter .Context , f * ast.File , checkers []* gocriticlinter .Checker ) []result.Issue {
146
146
var res []result.Issue
147
147
148
148
for _ , c := range checkers {
0 commit comments