Skip to content

Commit 97f2fd6

Browse files
fix: copy golines settings during linter settings load (#5607)
1 parent 301efb3 commit 97f2fd6

File tree

4 files changed

+49
-0
lines changed

4 files changed

+49
-0
lines changed

pkg/config/loader.go

+4
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,10 @@ func (l *Loader) handleFormatterOverrides() {
223223
if slices.Contains(l.cfg.Formatters.Enable, "gci") {
224224
l.cfg.Linters.Settings.Gci = l.cfg.Formatters.Settings.Gci
225225
}
226+
227+
if slices.Contains(l.cfg.Formatters.Enable, "golines") {
228+
l.cfg.Linters.Settings.GoLines = l.cfg.Formatters.Settings.GoLines
229+
}
226230
}
227231

228232
// Add formatter exclusions to linters exclusions.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
//golangcitest:config_path testdata/golines-custom.yml
2+
//golangcitest:expected_exitcode 0
3+
package testdata
4+
5+
// the struct tags should not be reformatted here
6+
type Foo struct {
7+
Bar `a:"b=\"c\"" d:"e"`
8+
Baz `a:"f" d:"g"`
9+
}
10+
11+
var (
12+
// this ends at 80 columns with tab size 2, and would only be a little wider
13+
// with tab size 8, not failing the default line-len, so it checks both
14+
// settings are applied properly
15+
abc = []string{"a string that is only wrapped at narrow widths and wide tabs"}
16+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
//golangcitest:config_path testdata/golines-custom.yml
2+
//golangcitest:expected_exitcode 0
3+
package testdata
4+
5+
// the struct tags should not be reformatted here
6+
type Foo struct {
7+
Bar `a:"b=\"c\"" d:"e"`
8+
Baz `a:"f" d:"g"`
9+
}
10+
11+
var (
12+
// this ends at 80 columns with tab size 2, and would only be a little wider
13+
// with tab size 8, not failing the default line-len, so it checks both
14+
// settings are applied properly
15+
abc = []string{
16+
"a string that is only wrapped at narrow widths and wide tabs",
17+
}
18+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
version: "2"
2+
3+
formatters:
4+
enable:
5+
- golines
6+
settings:
7+
golines:
8+
# override many settings
9+
max-len: 80
10+
tab-len: 8
11+
reformat-tags: false

0 commit comments

Comments
 (0)