diff --git a/test/fix_test.go b/test/fix_test.go index 41a2a492de3e..6b0e27e36db2 100644 --- a/test/fix_test.go +++ b/test/fix_test.go @@ -7,7 +7,6 @@ import ( "testing" "github.com/stretchr/testify/require" - "gopkg.in/yaml.v3" "github.com/golangci/golangci-lint/pkg/exitcodes" "github.com/golangci/golangci-lint/test/testshared" @@ -56,15 +55,12 @@ func TestFix(t *testing.T) { args = append(args, rc.args...) - cfg, err := yaml.Marshal(rc.config) - require.NoError(t, err) - var runResult *testshared.RunResult if rc.configPath != "" { args = append(args, "-c", rc.configPath) runResult = testshared.NewLintRunner(t).RunCommand("run", args...) } else { - runResult = testshared.NewLintRunner(t).RunWithYamlConfig(string(cfg), args...) + runResult = testshared.NewLintRunner(t).RunWithYamlConfig("", args...) } // nolintlint test uses non existing linters (bob, alice) diff --git a/test/linters_test.go b/test/linters_test.go index 9e5d641f5edd..637067d959d5 100644 --- a/test/linters_test.go +++ b/test/linters_test.go @@ -14,7 +14,6 @@ import ( hcversion "github.com/hashicorp/go-version" "github.com/stretchr/testify/require" - "gopkg.in/yaml.v3" "github.com/golangci/golangci-lint/pkg/exitcodes" "github.com/golangci/golangci-lint/test/testshared" @@ -82,7 +81,7 @@ func TestGoimportsLocal(t *testing.T) { args = append(args, rc.args...) - cfg, err := yaml.Marshal(rc.config) + cfg, err := os.ReadFile(rc.configPath) require.NoError(t, err) testshared.NewLintRunner(t).RunWithYamlConfig(string(cfg), args...). @@ -175,25 +174,6 @@ func TestFileOutput(t *testing.T) { require.Contains(t, string(b), `"Issues":[`) } -func saveConfig(t *testing.T, cfg map[string]interface{}) (cfgPath string, finishFunc func()) { - f, err := os.CreateTemp("", "golangci_lint_test") - require.NoError(t, err) - - cfgPath = f.Name() + ".yml" - err = os.Rename(f.Name(), cfgPath) - require.NoError(t, err) - - err = yaml.NewEncoder(f).Encode(cfg) - require.NoError(t, err) - - return cfgPath, func() { - require.NoError(t, f.Close()) - if os.Getenv("GL_KEEP_TEMP_FILES") != "1" { - require.NoError(t, os.Remove(cfgPath)) - } - } -} - func testOneSource(t *testing.T, sourcePath string) { args := []string{ "run", @@ -210,25 +190,16 @@ func testOneSource(t *testing.T, sourcePath string) { t.Skipf("Skipped: %s", sourcePath) } - var cfgPath string - if rc.config != nil { - p, finish := saveConfig(t, rc.config) - defer finish() - cfgPath = p - } else if rc.configPath != "" { - cfgPath = rc.configPath - } - for _, addArg := range []string{"", "-Etypecheck"} { caseArgs := append([]string{}, args...) caseArgs = append(caseArgs, rc.args...) if addArg != "" { caseArgs = append(caseArgs, addArg) } - if cfgPath == "" { + if rc.configPath == "" { caseArgs = append(caseArgs, "--no-config") } else { - caseArgs = append(caseArgs, "-c", cfgPath) + caseArgs = append(caseArgs, "-c", rc.configPath) } caseArgs = append(caseArgs, sourcePath) @@ -241,41 +212,17 @@ func testOneSource(t *testing.T, sourcePath string) { type runContext struct { args []string - config map[string]interface{} configPath string expectedLinter string } -func buildConfigFromShortRepr(t *testing.T, repr string, config map[string]interface{}) { - kv := strings.Split(repr, "=") - require.Len(t, kv, 2, "repr: %s", repr) - - keyParts := strings.Split(kv[0], ".") - require.True(t, len(keyParts) >= 2, len(keyParts)) - - lastObj := config - for _, k := range keyParts[:len(keyParts)-1] { - var v map[string]interface{} - if lastObj[k] == nil { - v = map[string]interface{}{} - } else { - v = lastObj[k].(map[string]interface{}) - } - - lastObj[k] = v - lastObj = v - } - - lastObj[keyParts[len(keyParts)-1]] = kv[1] -} - func skipMultilineComment(scanner *bufio.Scanner) { for line := scanner.Text(); !strings.Contains(line, "*/") && scanner.Scan(); { line = scanner.Text() } } -//nolint:gocyclo,funlen +//nolint:gocyclo func extractRunContextFromComments(t *testing.T, sourcePath string) *runContext { f, err := os.Open(sourcePath) require.NoError(t, err) @@ -324,14 +271,6 @@ func extractRunContextFromComments(t *testing.T, sourcePath string) *runContext rc.args = strings.Split(after, " ") continue - case "//golangcitest:config": - require.NotEmpty(t, after) - if rc.config == nil { - rc.config = map[string]interface{}{} - } - buildConfigFromShortRepr(t, after, rc.config) - continue - case "//golangcitest:config_path": require.NotEmpty(t, after) rc.configPath = after @@ -394,10 +333,7 @@ func TestTparallel(t *testing.T) { args = append(args, rc.args...) - cfg, err := yaml.Marshal(rc.config) - require.NoError(t, err) - - testshared.NewLintRunner(t).RunWithYamlConfig(string(cfg), args...). + testshared.NewLintRunner(t).RunWithYamlConfig("", args...). ExpectHasIssue( "testdata/tparallel/missing_toplevel_test.go:7:6: TestTopLevel should call t.Parallel on the top level as well as its subtests\n", ) @@ -416,10 +352,7 @@ func TestTparallel(t *testing.T) { args = append(args, rc.args...) - cfg, err := yaml.Marshal(rc.config) - require.NoError(t, err) - - testshared.NewLintRunner(t).RunWithYamlConfig(string(cfg), args...). + testshared.NewLintRunner(t).RunWithYamlConfig("", args...). ExpectHasIssue( "testdata/tparallel/missing_subtest_test.go:7:6: TestSubtests's subtests should call t.Parallel\n", ) @@ -438,9 +371,6 @@ func TestTparallel(t *testing.T) { args = append(args, rc.args...) - cfg, err := yaml.Marshal(rc.config) - require.NoError(t, err) - - testshared.NewLintRunner(t).RunWithYamlConfig(string(cfg), args...).ExpectNoIssues() + testshared.NewLintRunner(t).RunWithYamlConfig("", args...).ExpectNoIssues() }) } diff --git a/test/testdata/configs/cyclop.yml b/test/testdata/configs/cyclop.yml new file mode 100644 index 000000000000..abc1deb1b34f --- /dev/null +++ b/test/testdata/configs/cyclop.yml @@ -0,0 +1,3 @@ +linters-settings: + cyclop: + max-complexity: 15 diff --git a/test/testdata/configs/dupl.yml b/test/testdata/configs/dupl.yml new file mode 100644 index 000000000000..8abf10175e0c --- /dev/null +++ b/test/testdata/configs/dupl.yml @@ -0,0 +1,3 @@ +linters-settings: + dupl: + threshold: 20 diff --git a/test/testdata/configs/errcheck_exclude.yml b/test/testdata/configs/errcheck_exclude.yml new file mode 100644 index 000000000000..19fac1567019 --- /dev/null +++ b/test/testdata/configs/errcheck_exclude.yml @@ -0,0 +1,4 @@ +linters-settings: + errcheck: + check-blank: true + exclude: testdata/errcheck/exclude.txt diff --git a/test/testdata/configs/errcheck_ignore_default.yml b/test/testdata/configs/errcheck_ignore_default.yml new file mode 100644 index 000000000000..fe801445f7ae --- /dev/null +++ b/test/testdata/configs/errcheck_ignore_default.yml @@ -0,0 +1,3 @@ +linters-settings: + errcheck: + check-blank: true diff --git a/test/testdata/configs/errcheck_type_assertions.yml b/test/testdata/configs/errcheck_type_assertions.yml new file mode 100644 index 000000000000..aa2ba20a422d --- /dev/null +++ b/test/testdata/configs/errcheck_type_assertions.yml @@ -0,0 +1,3 @@ +linters-settings: + errcheck: + check-type-assertions: true diff --git a/test/testdata/configs/forbidigo_include_godoc_examples.yml b/test/testdata/configs/forbidigo_include_godoc_examples.yml new file mode 100644 index 000000000000..8bf10328866a --- /dev/null +++ b/test/testdata/configs/forbidigo_include_godoc_examples.yml @@ -0,0 +1,4 @@ +linters-settings: + forbidigo: + exclude-godoc-examples: false + diff --git a/test/testdata/configs/funlen.yml b/test/testdata/configs/funlen.yml new file mode 100644 index 000000000000..47acaaf42dff --- /dev/null +++ b/test/testdata/configs/funlen.yml @@ -0,0 +1,4 @@ +linters-settings: + funlen: + lines: 20 + statements: 10 diff --git a/test/testdata/configs/gocognit.yml b/test/testdata/configs/gocognit.yml new file mode 100644 index 000000000000..451443caf1a6 --- /dev/null +++ b/test/testdata/configs/gocognit.yml @@ -0,0 +1,3 @@ +linters-settings: + gocognit: + min-complexity: 2 diff --git a/test/testdata/configs/goconst_calls_enabled.yml b/test/testdata/configs/goconst_calls_enabled.yml new file mode 100644 index 000000000000..5d0d09585f7d --- /dev/null +++ b/test/testdata/configs/goconst_calls_enabled.yml @@ -0,0 +1,3 @@ +linters-settings: + goconst: + ignore-calls: false diff --git a/test/testdata/configs/goconst_dont_ignore.yml b/test/testdata/configs/goconst_dont_ignore.yml new file mode 100644 index 000000000000..fed6e5b28707 --- /dev/null +++ b/test/testdata/configs/goconst_dont_ignore.yml @@ -0,0 +1,3 @@ +linters-settings: + goconst: + ignore-tests: false diff --git a/test/testdata/configs/goconst_ignore.yml b/test/testdata/configs/goconst_ignore.yml new file mode 100644 index 000000000000..f0fd0c242bae --- /dev/null +++ b/test/testdata/configs/goconst_ignore.yml @@ -0,0 +1,3 @@ +linters-settings: + goconst: + ignore-tests: true diff --git a/test/testdata/configs/gocyclo.yml b/test/testdata/configs/gocyclo.yml new file mode 100644 index 000000000000..c42672fae94d --- /dev/null +++ b/test/testdata/configs/gocyclo.yml @@ -0,0 +1,3 @@ +linters-settings: + gocyclo: + min-complexity: 20 diff --git a/test/testdata/configs/godox.yml b/test/testdata/configs/godox.yml new file mode 100644 index 000000000000..d9bd4d44f6d2 --- /dev/null +++ b/test/testdata/configs/godox.yml @@ -0,0 +1,5 @@ +linters-settings: + godox: + keywords: + - FIXME + - TODO diff --git a/test/testdata/configs/gofmt_no_simplify.yml b/test/testdata/configs/gofmt_no_simplify.yml new file mode 100644 index 000000000000..ceeaa00f9946 --- /dev/null +++ b/test/testdata/configs/gofmt_no_simplify.yml @@ -0,0 +1,3 @@ +linters-settings: + gofmt: + simplify: false diff --git a/test/testdata/configs/gofumpt-fix.yml b/test/testdata/configs/gofumpt-fix.yml new file mode 100644 index 000000000000..921da9f4c15c --- /dev/null +++ b/test/testdata/configs/gofumpt-fix.yml @@ -0,0 +1,3 @@ +linters-settings: + gofumpt: + extra-rules: true diff --git a/test/testdata/configs/gofumpt_with_extra.yml b/test/testdata/configs/gofumpt_with_extra.yml new file mode 100644 index 000000000000..921da9f4c15c --- /dev/null +++ b/test/testdata/configs/gofumpt_with_extra.yml @@ -0,0 +1,3 @@ +linters-settings: + gofumpt: + extra-rules: true diff --git a/test/testdata/configs/goimports.yml b/test/testdata/configs/goimports.yml new file mode 100644 index 000000000000..cb8c0edf99f8 --- /dev/null +++ b/test/testdata/configs/goimports.yml @@ -0,0 +1,3 @@ +linters-settings: + goimports: + local-prefixes: github.com/golangci/golangci-lint diff --git a/test/testdata/configs/govet.yml b/test/testdata/configs/govet.yml new file mode 100644 index 000000000000..86e8edd3377c --- /dev/null +++ b/test/testdata/configs/govet.yml @@ -0,0 +1,3 @@ +linters-settings: + govet: + check-shadowing: true diff --git a/test/testdata/configs/govet_fieldalignment.yml b/test/testdata/configs/govet_fieldalignment.yml new file mode 100644 index 000000000000..a4d4fe91f67d --- /dev/null +++ b/test/testdata/configs/govet_fieldalignment.yml @@ -0,0 +1,3 @@ +linters-settings: + govet: + enable: fieldalignment diff --git a/test/testdata/configs/govet_ifaceassert.yml b/test/testdata/configs/govet_ifaceassert.yml new file mode 100644 index 000000000000..581dbc05100e --- /dev/null +++ b/test/testdata/configs/govet_ifaceassert.yml @@ -0,0 +1,3 @@ +linters-settings: + govet: + enable: ifaceassert diff --git a/test/testdata/configs/lll.yml b/test/testdata/configs/lll.yml new file mode 100644 index 000000000000..2e2fde53e908 --- /dev/null +++ b/test/testdata/configs/lll.yml @@ -0,0 +1,3 @@ +linters-settings: + lll: + tab-width: 4 diff --git a/test/testdata/configs/makezero_always.yml b/test/testdata/configs/makezero_always.yml new file mode 100644 index 000000000000..d7d1fa656cfb --- /dev/null +++ b/test/testdata/configs/makezero_always.yml @@ -0,0 +1,3 @@ +linters-settings: + makezero: + always: true diff --git a/test/testdata/configs/nestif.yml b/test/testdata/configs/nestif.yml new file mode 100644 index 000000000000..e6c4fb0cf58b --- /dev/null +++ b/test/testdata/configs/nestif.yml @@ -0,0 +1,3 @@ +linters-settings: + nestif: + min-complexity: 1 diff --git a/test/testdata/configs/nolintlint.yml b/test/testdata/configs/nolintlint.yml new file mode 100644 index 000000000000..b0cc6ebd7ec4 --- /dev/null +++ b/test/testdata/configs/nolintlint.yml @@ -0,0 +1,4 @@ +linters-settings: + nolintlint: + require-explanation: true + require-specific: true diff --git a/test/testdata/configs/nolintlint_unused.yml b/test/testdata/configs/nolintlint_unused.yml new file mode 100644 index 000000000000..b92160a83fda --- /dev/null +++ b/test/testdata/configs/nolintlint_unused.yml @@ -0,0 +1,3 @@ +linters-settings: + nolintlint: + allow-unused: false diff --git a/test/testdata/configs/whitespace-fix.yml b/test/testdata/configs/whitespace-fix.yml new file mode 100644 index 000000000000..dad470cee82d --- /dev/null +++ b/test/testdata/configs/whitespace-fix.yml @@ -0,0 +1,4 @@ +linters-settings: + whitespace: + multi-if: true + multi-func: true diff --git a/test/testdata/configs/wsl.yml b/test/testdata/configs/wsl.yml new file mode 100644 index 000000000000..4197633eef95 --- /dev/null +++ b/test/testdata/configs/wsl.yml @@ -0,0 +1,3 @@ +linters-settings: + wsl: + allow-cuddle-declarations: false diff --git a/test/testdata/cyclop.go b/test/testdata/cyclop.go index 23870aba4eda..de93a9dab659 100644 --- a/test/testdata/cyclop.go +++ b/test/testdata/cyclop.go @@ -1,5 +1,5 @@ //golangcitest:args -Ecyclop -//golangcitest:config linters-settings.cyclop.max-complexity=15 +//golangcitest:config_path testdata/configs/cyclop.yml package testdata func cyclopComplexFunc(s string) { // ERROR "calculated cyclomatic complexity for function cyclopComplexFunc is 22, max is 15" diff --git a/test/testdata/dupl.go b/test/testdata/dupl.go index 109372f84355..863c334cd1cf 100644 --- a/test/testdata/dupl.go +++ b/test/testdata/dupl.go @@ -1,5 +1,5 @@ //golangcitest:args -Edupl -//golangcitest:config linters-settings.dupl.threshold=20 +//golangcitest:config_path testdata/configs/dupl.yml package testdata type DuplLogger struct{} diff --git a/test/testdata/errcheck_exclude.go b/test/testdata/errcheck_exclude.go index 69af590a75a6..b6ddd9872cfa 100644 --- a/test/testdata/errcheck_exclude.go +++ b/test/testdata/errcheck_exclude.go @@ -1,6 +1,5 @@ //golangcitest:args -Eerrcheck -//golangcitest:config linters-settings.errcheck.check-blank=true -//golangcitest:config linters-settings.errcheck.exclude=testdata/errcheck/exclude.txt +//golangcitest:config_path testdata/configs/errcheck_exclude.yml package testdata import ( diff --git a/test/testdata/errcheck_ignore_default.go b/test/testdata/errcheck_ignore_default.go index 961c9cdaabbe..e7a1466eb9da 100644 --- a/test/testdata/errcheck_ignore_default.go +++ b/test/testdata/errcheck_ignore_default.go @@ -1,5 +1,5 @@ //golangcitest:args -Eerrcheck -//golangcitest:config linters-settings.errcheck.check-blank=true +//golangcitest:config_path testdata/configs/errcheck_ignore_default.yml package testdata import ( diff --git a/test/testdata/errcheck_type_assertions.go b/test/testdata/errcheck_type_assertions.go index 9a581fb2273b..94a192ef276b 100644 --- a/test/testdata/errcheck_type_assertions.go +++ b/test/testdata/errcheck_type_assertions.go @@ -1,5 +1,5 @@ //golangcitest:args -Eerrcheck -//golangcitest:config linters-settings.errcheck.check-type-assertions=true +//golangcitest:config_path testdata/configs/errcheck_type_assertions.yml package testdata func ErrorTypeAssertion(filter map[string]interface{}) bool { diff --git a/test/testdata/fix/in/gofumpt.go b/test/testdata/fix/in/gofumpt.go index 1fc4a8d6ada6..83b6c9783ed3 100644 --- a/test/testdata/fix/in/gofumpt.go +++ b/test/testdata/fix/in/gofumpt.go @@ -1,5 +1,5 @@ //golangcitest:args -Egofumpt -//golangcitest:config linters-settings.gofumpt.extra-rules=true +//golangcitest:config_path testdata/configs/gofumpt-fix.yml package p import "fmt" diff --git a/test/testdata/fix/in/whitespace.go b/test/testdata/fix/in/whitespace.go index b720d3c3802a..be8050e22f26 100644 --- a/test/testdata/fix/in/whitespace.go +++ b/test/testdata/fix/in/whitespace.go @@ -1,6 +1,5 @@ //golangcitest:args -Ewhitespace -//golangcitest:config linters-settings.whitespace.multi-if=true -//golangcitest:config linters-settings.whitespace.multi-func=true +//golangcitest:config_path testdata/configs/whitespace-fix.yml package p import "fmt" diff --git a/test/testdata/fix/out/gofumpt.go b/test/testdata/fix/out/gofumpt.go index a0ca50b05e66..dd366b7cce41 100644 --- a/test/testdata/fix/out/gofumpt.go +++ b/test/testdata/fix/out/gofumpt.go @@ -1,5 +1,5 @@ //golangcitest:args -Egofumpt -//golangcitest:config linters-settings.gofumpt.extra-rules=true +//golangcitest:config_path testdata/configs/gofumpt-fix.yml package p import "fmt" diff --git a/test/testdata/fix/out/whitespace.go b/test/testdata/fix/out/whitespace.go index df6e3fa68a97..653a7343fb09 100644 --- a/test/testdata/fix/out/whitespace.go +++ b/test/testdata/fix/out/whitespace.go @@ -1,6 +1,5 @@ //golangcitest:args -Ewhitespace -//golangcitest:config linters-settings.whitespace.multi-if=true -//golangcitest:config linters-settings.whitespace.multi-func=true +//golangcitest:config_path testdata/configs/whitespace-fix.yml package p import "fmt" diff --git a/test/testdata/forbidigo_include_godoc_examples_test.go b/test/testdata/forbidigo_include_godoc_examples_test.go index 9812af1ce152..ea6fc3e055ea 100644 --- a/test/testdata/forbidigo_include_godoc_examples_test.go +++ b/test/testdata/forbidigo_include_godoc_examples_test.go @@ -1,5 +1,5 @@ //golangcitest:args -Eforbidigo -//golangcitest:config linters-settings.forbidigo.exclude-godoc-examples=false +//golangcitest:config_path testdata/configs/forbidigo_include_godoc_examples.yml package testdata import "fmt" diff --git a/test/testdata/funlen.go b/test/testdata/funlen.go index 5dbbf195d2f7..f8059dbcf578 100644 --- a/test/testdata/funlen.go +++ b/test/testdata/funlen.go @@ -1,6 +1,5 @@ //golangcitest:args -Efunlen -//golangcitest:config linters-settings.funlen.lines=20 -//golangcitest:config linters-settings.funlen.statements=10 +//golangcitest:config_path testdata/configs/funlen.yml package testdata func TooManyLines() { // ERROR `Function 'TooManyLines' is too long \(22 > 20\)` diff --git a/test/testdata/gocognit.go b/test/testdata/gocognit.go index 79a4a0f1ef6e..ffd582a30200 100644 --- a/test/testdata/gocognit.go +++ b/test/testdata/gocognit.go @@ -1,5 +1,5 @@ //golangcitest:args -Egocognit -//golangcitest:config linters-settings.gocognit.min-complexity=2 +//golangcitest:config_path testdata/configs/gocognit.yml package testdata func GoCognit_CC4_GetWords(number int) string { // ERROR "cognitive complexity 4 of func .* is high .*" diff --git a/test/testdata/goconst_calls_enabled.go b/test/testdata/goconst_calls_enabled.go index d813ad236a2d..83df4e78b7e1 100644 --- a/test/testdata/goconst_calls_enabled.go +++ b/test/testdata/goconst_calls_enabled.go @@ -1,5 +1,5 @@ //golangcitest:args -Egoconst -//golangcitest:config linters-settings.goconst.ignore-calls=false +//golangcitest:config_path testdata/configs/goconst_calls_enabled.yml package testdata import "fmt" diff --git a/test/testdata/goconst_dont_ignore_test.go b/test/testdata/goconst_dont_ignore_test.go index 51ebd97ae555..7282827047a1 100644 --- a/test/testdata/goconst_dont_ignore_test.go +++ b/test/testdata/goconst_dont_ignore_test.go @@ -1,5 +1,5 @@ //golangcitest:args -Egoconst -//golangcitest:config linters-settings.goconst.ignore-tests=false +//golangcitest:config_path testdata/configs/goconst_dont_ignore.yml package testdata import ( diff --git a/test/testdata/goconst_ignore_test.go b/test/testdata/goconst_ignore_test.go index 9ef9eb129a94..5180b62ab394 100644 --- a/test/testdata/goconst_ignore_test.go +++ b/test/testdata/goconst_ignore_test.go @@ -1,5 +1,5 @@ //golangcitest:args -Egoconst -//golangcitest:config linters-settings.goconst.ignore-tests=true +//golangcitest:config_path testdata/configs/goconst_ignore.yml package testdata import ( diff --git a/test/testdata/gocyclo.go b/test/testdata/gocyclo.go index ca5b85ca8b44..3fd1040ee596 100644 --- a/test/testdata/gocyclo.go +++ b/test/testdata/gocyclo.go @@ -1,5 +1,5 @@ //golangcitest:args -Egocyclo -//golangcitest:config linters-settings.gocyclo.min-complexity=20 +//golangcitest:config_path testdata/configs/gocyclo.yml package testdata import "net/http" diff --git a/test/testdata/godox.go b/test/testdata/godox.go index c86b9c26bff3..e6f2364d6583 100644 --- a/test/testdata/godox.go +++ b/test/testdata/godox.go @@ -1,5 +1,5 @@ //golangcitest:args -Egodox -//golangcitest:config linters-settings.godox.keywords=FIXME,TODO +//golangcitest:config_path testdata/configs/godox.yml package testdata func todoLeftInCode() { diff --git a/test/testdata/gofmt_no_simplify.go b/test/testdata/gofmt_no_simplify.go index 98267ad3abce..423e60488928 100644 --- a/test/testdata/gofmt_no_simplify.go +++ b/test/testdata/gofmt_no_simplify.go @@ -1,5 +1,5 @@ //golangcitest:args -Egofmt -//golangcitest:config linters-settings.gofmt.simplify=false +//golangcitest:config_path testdata/configs/gofmt_no_simplify.yml package testdata import "fmt" diff --git a/test/testdata/gofumpt_with_extra.go b/test/testdata/gofumpt_with_extra.go index 00c7f21e13d6..9fdab582c09d 100644 --- a/test/testdata/gofumpt_with_extra.go +++ b/test/testdata/gofumpt_with_extra.go @@ -1,5 +1,5 @@ //golangcitest:args -Egofumpt -//golangcitest:config linters-settings.gofumpt.extra-rules=true +//golangcitest:config_path testdata/configs/gofumpt_with_extra.yml package testdata import "fmt" diff --git a/test/testdata/goimports/goimports.go b/test/testdata/goimports/goimports.go index a614bb5921df..a94b76c24b19 100644 --- a/test/testdata/goimports/goimports.go +++ b/test/testdata/goimports/goimports.go @@ -1,5 +1,5 @@ //golangcitest:args -Egoimports -//golangcitest:config linters-settings.goimports.local-prefixes=github.com/golangci/golangci-lint +//golangcitest:config_path testdata/configs/goimports.yml package goimports import ( diff --git a/test/testdata/govet.go b/test/testdata/govet.go index 5d0b8f81e26d..53c0e35d7d71 100644 --- a/test/testdata/govet.go +++ b/test/testdata/govet.go @@ -1,5 +1,5 @@ //golangcitest:args -Egovet -//golangcitest:config linters-settings.govet.check-shadowing=true +//golangcitest:config_path testdata/configs/govet.yml package testdata import ( diff --git a/test/testdata/govet_fieldalignment.go b/test/testdata/govet_fieldalignment.go index 20e3790da3f3..e7d6ffce8566 100644 --- a/test/testdata/govet_fieldalignment.go +++ b/test/testdata/govet_fieldalignment.go @@ -1,5 +1,5 @@ //golangcitest:args -Egovet -//golangcitest:config linters-settings.govet.enable=fieldalignment +//golangcitest:config_path testdata/configs/govet_fieldalignment.yml package testdata type gvfaGood struct { diff --git a/test/testdata/govet_ifaceassert.go b/test/testdata/govet_ifaceassert.go index 3e2020ccd3e2..fc8910e3daee 100644 --- a/test/testdata/govet_ifaceassert.go +++ b/test/testdata/govet_ifaceassert.go @@ -1,5 +1,5 @@ //golangcitest:args -Egovet -//golangcitest:config linters-settings.govet.enable=ifaceassert +//golangcitest:config_path testdata/configs/govet_ifaceassert.yml package testdata import ( diff --git a/test/testdata/lll.go b/test/testdata/lll.go index e961c7b0f150..331e78d5aad6 100644 --- a/test/testdata/lll.go +++ b/test/testdata/lll.go @@ -1,5 +1,5 @@ //golangcitest:args -Elll -//golangcitest:config linters-settings.lll.tab-width=4 +//golangcitest:config_path testdata/configs/lll.yml package testdata func Lll() { diff --git a/test/testdata/makezero_always.go b/test/testdata/makezero_always.go index 622c49c5104c..89093e0fc7b0 100644 --- a/test/testdata/makezero_always.go +++ b/test/testdata/makezero_always.go @@ -1,5 +1,5 @@ //golangcitest:args -Emakezero -//golangcitest:config linters-settings.makezero.always=true +//golangcitest:config_path testdata/configs/makezero_always.yml package testdata import "math" diff --git a/test/testdata/nestif.go b/test/testdata/nestif.go index 219635545601..5dc7da326801 100644 --- a/test/testdata/nestif.go +++ b/test/testdata/nestif.go @@ -1,5 +1,5 @@ //golangcitest:args -Enestif -//golangcitest:config linters-settings.nestif.min-complexity=1 +//golangcitest:config_path testdata/configs/nestif.yml package testdata func _() { diff --git a/test/testdata/nolintlint.go b/test/testdata/nolintlint.go index 1043b9846d28..da5537f0a045 100644 --- a/test/testdata/nolintlint.go +++ b/test/testdata/nolintlint.go @@ -1,7 +1,6 @@ //golangcitest:args -Enolintlint -Emisspell //golangcitest:expected_linter nolintlint -//golangcitest:config linters-settings.nolintlint.require-explanation=true -//golangcitest:config linters-settings.nolintlint.require-specific=true +//golangcitest:config_path testdata/configs/nolintlint.yml package testdata import "fmt" diff --git a/test/testdata/nolintlint_unused.go b/test/testdata/nolintlint_unused.go index 96bc2a70cbfa..34c32ae994de 100644 --- a/test/testdata/nolintlint_unused.go +++ b/test/testdata/nolintlint_unused.go @@ -1,6 +1,6 @@ //golangcitest:args -Enolintlint -Evarcheck -//golangcitest:config linters-settings.nolintlint.allow-unused=false //golangcitest:expected_linter nolintlint +//golangcitest:config_path testdata/configs/nolintlint_unused.yml package testdata import "fmt" diff --git a/test/testdata/wsl.go b/test/testdata/wsl.go index 03b6988d4d70..75311c5c2fc8 100644 --- a/test/testdata/wsl.go +++ b/test/testdata/wsl.go @@ -1,5 +1,5 @@ //golangcitest:args -Ewsl -//golangcitest:config linters-settings.wsl.tests=1 +//golangcitest:config_path testdata/configs/wsl.yml package testdata import ( diff --git a/test/testshared/testshared.go b/test/testshared/testshared.go index 55b606d840bc..e3c55cd0ec28 100644 --- a/test/testshared/testshared.go +++ b/test/testshared/testshared.go @@ -153,8 +153,7 @@ func (r *LintRunner) RunCommandWithYamlConfig(cfg, command string, args ...strin defer os.Remove(cfgPath) } - cfg = strings.TrimSpace(cfg) - cfg = strings.ReplaceAll(cfg, "\t", " ") + cfg = strings.ReplaceAll(strings.TrimSpace(cfg), "\t", " ") err = os.WriteFile(cfgPath, []byte(cfg), os.ModePerm) assert.NoError(r.t, err)