diff --git a/pkg/config/loader.go b/pkg/config/loader.go index deace8ff0b17..e153c6adc169 100644 --- a/pkg/config/loader.go +++ b/pkg/config/loader.go @@ -223,6 +223,10 @@ func (l *Loader) handleFormatterOverrides() { if slices.Contains(l.cfg.Formatters.Enable, "gci") { l.cfg.Linters.Settings.Gci = l.cfg.Formatters.Settings.Gci } + + if slices.Contains(l.cfg.Formatters.Enable, "golines") { + l.cfg.Linters.Settings.GoLines = l.cfg.Formatters.Settings.GoLines + } } // Add formatter exclusions to linters exclusions. diff --git a/pkg/golinters/golines/testdata/fix/in/golines-custom.go b/pkg/golinters/golines/testdata/fix/in/golines-custom.go new file mode 100644 index 000000000000..d749e27c414f --- /dev/null +++ b/pkg/golinters/golines/testdata/fix/in/golines-custom.go @@ -0,0 +1,16 @@ +//golangcitest:config_path testdata/golines-custom.yml +//golangcitest:expected_exitcode 0 +package testdata + +// the struct tags should not be reformatted here +type Foo struct { + Bar `a:"b=\"c\"" d:"e"` + Baz `a:"f" d:"g"` +} + +var ( + // this ends at 80 columns with tab size 2, and would only be a little wider + // with tab size 8, not failing the default line-len, so it checks both + // settings are applied properly + abc = []string{"a string that is only wrapped at narrow widths and wide tabs"} +) diff --git a/pkg/golinters/golines/testdata/fix/out/golines-custom.go b/pkg/golinters/golines/testdata/fix/out/golines-custom.go new file mode 100644 index 000000000000..c6009373ad17 --- /dev/null +++ b/pkg/golinters/golines/testdata/fix/out/golines-custom.go @@ -0,0 +1,18 @@ +//golangcitest:config_path testdata/golines-custom.yml +//golangcitest:expected_exitcode 0 +package testdata + +// the struct tags should not be reformatted here +type Foo struct { + Bar `a:"b=\"c\"" d:"e"` + Baz `a:"f" d:"g"` +} + +var ( + // this ends at 80 columns with tab size 2, and would only be a little wider + // with tab size 8, not failing the default line-len, so it checks both + // settings are applied properly + abc = []string{ + "a string that is only wrapped at narrow widths and wide tabs", + } +) diff --git a/pkg/golinters/golines/testdata/golines-custom.yml b/pkg/golinters/golines/testdata/golines-custom.yml new file mode 100644 index 000000000000..2a728aa320f0 --- /dev/null +++ b/pkg/golinters/golines/testdata/golines-custom.yml @@ -0,0 +1,11 @@ +version: "2" + +formatters: + enable: + - golines + settings: + golines: + # override many settings + max-len: 80 + tab-len: 8 + reformat-tags: false