@@ -14,7 +14,8 @@ import (
14
14
"golang.org/x/tools/go/analysis"
15
15
16
16
"github.com/golangci/golangci-lint/pkg/config"
17
- "github.com/golangci/golangci-lint/pkg/golinters/goanalysis"
17
+ "github.com/golangci/golangci-lint/pkg/goanalysis"
18
+ "github.com/golangci/golangci-lint/pkg/golinters/internal"
18
19
"github.com/golangci/golangci-lint/pkg/lint/linter"
19
20
)
20
21
@@ -48,7 +49,7 @@ func NewGci(settings *config.GciSettings) *goanalysis.Linter {
48
49
var err error
49
50
cfg , err = rawCfg .Parse ()
50
51
if err != nil {
51
- linterLogger .Fatalf ("gci: configuration parsing: %v" , err )
52
+ internal . LinterLogger .Fatalf ("gci: configuration parsing: %v" , err )
52
53
}
53
54
}
54
55
@@ -82,7 +83,7 @@ func NewGci(settings *config.GciSettings) *goanalysis.Linter {
82
83
}
83
84
84
85
func runGci (pass * analysis.Pass , lintCtx * linter.Context , cfg * gcicfg.Config , lock * sync.Mutex ) ([]goanalysis.Issue , error ) {
85
- fileNames := getFileNames (pass )
86
+ fileNames := internal . GetFileNames (pass )
86
87
87
88
var diffs []string
88
89
err := diffFormattedFilesToArray (fileNames , * cfg , & diffs , lock )
@@ -97,7 +98,7 @@ func runGci(pass *analysis.Pass, lintCtx *linter.Context, cfg *gcicfg.Config, lo
97
98
continue
98
99
}
99
100
100
- is , err := extractIssuesFromPatch (diff , lintCtx , gciName )
101
+ is , err := internal . ExtractIssuesFromPatch (diff , lintCtx , gciName , getIssuedTextGci )
101
102
if err != nil {
102
103
return nil , fmt .Errorf ("can't extract issues from gci diff output %s: %w" , diff , err )
103
104
}
@@ -129,27 +130,27 @@ func diffFormattedFilesToArray(paths []string, cfg gcicfg.Config, diffs *[]strin
129
130
})
130
131
}
131
132
132
- func getErrorTextForGci (settings config.GciSettings ) string {
133
+ func getIssuedTextGci (settings * config.LintersSettings ) string {
133
134
text := "File is not `gci`-ed"
134
135
135
- hasOptions := settings .SkipGenerated || len (settings .Sections ) > 0
136
+ hasOptions := settings .Gci . SkipGenerated || len (settings . Gci .Sections ) > 0
136
137
if ! hasOptions {
137
138
return text
138
139
}
139
140
140
141
text += " with"
141
142
142
- if settings .SkipGenerated {
143
+ if settings .Gci . SkipGenerated {
143
144
text += " --skip-generated"
144
145
}
145
146
146
- if len (settings .Sections ) > 0 {
147
- for _ , section := range settings .Sections {
147
+ if len (settings .Gci . Sections ) > 0 {
148
+ for _ , section := range settings .Gci . Sections {
148
149
text += " -s " + section
149
150
}
150
151
}
151
152
152
- if settings .CustomOrder {
153
+ if settings .Gci . CustomOrder {
153
154
text += " --custom-order"
154
155
}
155
156
0 commit comments