dev: replace golangcitest:config by golangcitest:config_path (#3099)
This commit is contained in:
parent
9da04f5070
commit
f7fba37cc9
@ -7,7 +7,6 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
"gopkg.in/yaml.v3"
|
|
||||||
|
|
||||||
"github.com/golangci/golangci-lint/pkg/exitcodes"
|
"github.com/golangci/golangci-lint/pkg/exitcodes"
|
||||||
"github.com/golangci/golangci-lint/test/testshared"
|
"github.com/golangci/golangci-lint/test/testshared"
|
||||||
@ -56,15 +55,12 @@ func TestFix(t *testing.T) {
|
|||||||
|
|
||||||
args = append(args, rc.args...)
|
args = append(args, rc.args...)
|
||||||
|
|
||||||
cfg, err := yaml.Marshal(rc.config)
|
|
||||||
require.NoError(t, err)
|
|
||||||
|
|
||||||
var runResult *testshared.RunResult
|
var runResult *testshared.RunResult
|
||||||
if rc.configPath != "" {
|
if rc.configPath != "" {
|
||||||
args = append(args, "-c", rc.configPath)
|
args = append(args, "-c", rc.configPath)
|
||||||
runResult = testshared.NewLintRunner(t).RunCommand("run", args...)
|
runResult = testshared.NewLintRunner(t).RunCommand("run", args...)
|
||||||
} else {
|
} else {
|
||||||
runResult = testshared.NewLintRunner(t).RunWithYamlConfig(string(cfg), args...)
|
runResult = testshared.NewLintRunner(t).RunWithYamlConfig("", args...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// nolintlint test uses non existing linters (bob, alice)
|
// nolintlint test uses non existing linters (bob, alice)
|
||||||
|
@ -14,7 +14,6 @@ import (
|
|||||||
|
|
||||||
hcversion "github.com/hashicorp/go-version"
|
hcversion "github.com/hashicorp/go-version"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
"gopkg.in/yaml.v3"
|
|
||||||
|
|
||||||
"github.com/golangci/golangci-lint/pkg/exitcodes"
|
"github.com/golangci/golangci-lint/pkg/exitcodes"
|
||||||
"github.com/golangci/golangci-lint/test/testshared"
|
"github.com/golangci/golangci-lint/test/testshared"
|
||||||
@ -82,7 +81,7 @@ func TestGoimportsLocal(t *testing.T) {
|
|||||||
|
|
||||||
args = append(args, rc.args...)
|
args = append(args, rc.args...)
|
||||||
|
|
||||||
cfg, err := yaml.Marshal(rc.config)
|
cfg, err := os.ReadFile(rc.configPath)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
testshared.NewLintRunner(t).RunWithYamlConfig(string(cfg), args...).
|
testshared.NewLintRunner(t).RunWithYamlConfig(string(cfg), args...).
|
||||||
@ -175,25 +174,6 @@ func TestFileOutput(t *testing.T) {
|
|||||||
require.Contains(t, string(b), `"Issues":[`)
|
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) {
|
func testOneSource(t *testing.T, sourcePath string) {
|
||||||
args := []string{
|
args := []string{
|
||||||
"run",
|
"run",
|
||||||
@ -210,25 +190,16 @@ func testOneSource(t *testing.T, sourcePath string) {
|
|||||||
t.Skipf("Skipped: %s", sourcePath)
|
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"} {
|
for _, addArg := range []string{"", "-Etypecheck"} {
|
||||||
caseArgs := append([]string{}, args...)
|
caseArgs := append([]string{}, args...)
|
||||||
caseArgs = append(caseArgs, rc.args...)
|
caseArgs = append(caseArgs, rc.args...)
|
||||||
if addArg != "" {
|
if addArg != "" {
|
||||||
caseArgs = append(caseArgs, addArg)
|
caseArgs = append(caseArgs, addArg)
|
||||||
}
|
}
|
||||||
if cfgPath == "" {
|
if rc.configPath == "" {
|
||||||
caseArgs = append(caseArgs, "--no-config")
|
caseArgs = append(caseArgs, "--no-config")
|
||||||
} else {
|
} else {
|
||||||
caseArgs = append(caseArgs, "-c", cfgPath)
|
caseArgs = append(caseArgs, "-c", rc.configPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
caseArgs = append(caseArgs, sourcePath)
|
caseArgs = append(caseArgs, sourcePath)
|
||||||
@ -241,41 +212,17 @@ func testOneSource(t *testing.T, sourcePath string) {
|
|||||||
|
|
||||||
type runContext struct {
|
type runContext struct {
|
||||||
args []string
|
args []string
|
||||||
config map[string]interface{}
|
|
||||||
configPath string
|
configPath string
|
||||||
expectedLinter 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) {
|
func skipMultilineComment(scanner *bufio.Scanner) {
|
||||||
for line := scanner.Text(); !strings.Contains(line, "*/") && scanner.Scan(); {
|
for line := scanner.Text(); !strings.Contains(line, "*/") && scanner.Scan(); {
|
||||||
line = scanner.Text()
|
line = scanner.Text()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//nolint:gocyclo,funlen
|
//nolint:gocyclo
|
||||||
func extractRunContextFromComments(t *testing.T, sourcePath string) *runContext {
|
func extractRunContextFromComments(t *testing.T, sourcePath string) *runContext {
|
||||||
f, err := os.Open(sourcePath)
|
f, err := os.Open(sourcePath)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
@ -324,14 +271,6 @@ func extractRunContextFromComments(t *testing.T, sourcePath string) *runContext
|
|||||||
rc.args = strings.Split(after, " ")
|
rc.args = strings.Split(after, " ")
|
||||||
continue
|
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":
|
case "//golangcitest:config_path":
|
||||||
require.NotEmpty(t, after)
|
require.NotEmpty(t, after)
|
||||||
rc.configPath = after
|
rc.configPath = after
|
||||||
@ -394,10 +333,7 @@ func TestTparallel(t *testing.T) {
|
|||||||
|
|
||||||
args = append(args, rc.args...)
|
args = append(args, rc.args...)
|
||||||
|
|
||||||
cfg, err := yaml.Marshal(rc.config)
|
testshared.NewLintRunner(t).RunWithYamlConfig("", args...).
|
||||||
require.NoError(t, err)
|
|
||||||
|
|
||||||
testshared.NewLintRunner(t).RunWithYamlConfig(string(cfg), args...).
|
|
||||||
ExpectHasIssue(
|
ExpectHasIssue(
|
||||||
"testdata/tparallel/missing_toplevel_test.go:7:6: TestTopLevel should call t.Parallel on the top level as well as its subtests\n",
|
"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...)
|
args = append(args, rc.args...)
|
||||||
|
|
||||||
cfg, err := yaml.Marshal(rc.config)
|
testshared.NewLintRunner(t).RunWithYamlConfig("", args...).
|
||||||
require.NoError(t, err)
|
|
||||||
|
|
||||||
testshared.NewLintRunner(t).RunWithYamlConfig(string(cfg), args...).
|
|
||||||
ExpectHasIssue(
|
ExpectHasIssue(
|
||||||
"testdata/tparallel/missing_subtest_test.go:7:6: TestSubtests's subtests should call t.Parallel\n",
|
"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...)
|
args = append(args, rc.args...)
|
||||||
|
|
||||||
cfg, err := yaml.Marshal(rc.config)
|
testshared.NewLintRunner(t).RunWithYamlConfig("", args...).ExpectNoIssues()
|
||||||
require.NoError(t, err)
|
|
||||||
|
|
||||||
testshared.NewLintRunner(t).RunWithYamlConfig(string(cfg), args...).ExpectNoIssues()
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
3
test/testdata/configs/cyclop.yml
vendored
Normal file
3
test/testdata/configs/cyclop.yml
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
linters-settings:
|
||||||
|
cyclop:
|
||||||
|
max-complexity: 15
|
3
test/testdata/configs/dupl.yml
vendored
Normal file
3
test/testdata/configs/dupl.yml
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
linters-settings:
|
||||||
|
dupl:
|
||||||
|
threshold: 20
|
4
test/testdata/configs/errcheck_exclude.yml
vendored
Normal file
4
test/testdata/configs/errcheck_exclude.yml
vendored
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
linters-settings:
|
||||||
|
errcheck:
|
||||||
|
check-blank: true
|
||||||
|
exclude: testdata/errcheck/exclude.txt
|
3
test/testdata/configs/errcheck_ignore_default.yml
vendored
Normal file
3
test/testdata/configs/errcheck_ignore_default.yml
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
linters-settings:
|
||||||
|
errcheck:
|
||||||
|
check-blank: true
|
3
test/testdata/configs/errcheck_type_assertions.yml
vendored
Normal file
3
test/testdata/configs/errcheck_type_assertions.yml
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
linters-settings:
|
||||||
|
errcheck:
|
||||||
|
check-type-assertions: true
|
4
test/testdata/configs/forbidigo_include_godoc_examples.yml
vendored
Normal file
4
test/testdata/configs/forbidigo_include_godoc_examples.yml
vendored
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
linters-settings:
|
||||||
|
forbidigo:
|
||||||
|
exclude-godoc-examples: false
|
||||||
|
|
4
test/testdata/configs/funlen.yml
vendored
Normal file
4
test/testdata/configs/funlen.yml
vendored
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
linters-settings:
|
||||||
|
funlen:
|
||||||
|
lines: 20
|
||||||
|
statements: 10
|
3
test/testdata/configs/gocognit.yml
vendored
Normal file
3
test/testdata/configs/gocognit.yml
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
linters-settings:
|
||||||
|
gocognit:
|
||||||
|
min-complexity: 2
|
3
test/testdata/configs/goconst_calls_enabled.yml
vendored
Normal file
3
test/testdata/configs/goconst_calls_enabled.yml
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
linters-settings:
|
||||||
|
goconst:
|
||||||
|
ignore-calls: false
|
3
test/testdata/configs/goconst_dont_ignore.yml
vendored
Normal file
3
test/testdata/configs/goconst_dont_ignore.yml
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
linters-settings:
|
||||||
|
goconst:
|
||||||
|
ignore-tests: false
|
3
test/testdata/configs/goconst_ignore.yml
vendored
Normal file
3
test/testdata/configs/goconst_ignore.yml
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
linters-settings:
|
||||||
|
goconst:
|
||||||
|
ignore-tests: true
|
3
test/testdata/configs/gocyclo.yml
vendored
Normal file
3
test/testdata/configs/gocyclo.yml
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
linters-settings:
|
||||||
|
gocyclo:
|
||||||
|
min-complexity: 20
|
5
test/testdata/configs/godox.yml
vendored
Normal file
5
test/testdata/configs/godox.yml
vendored
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
linters-settings:
|
||||||
|
godox:
|
||||||
|
keywords:
|
||||||
|
- FIXME
|
||||||
|
- TODO
|
3
test/testdata/configs/gofmt_no_simplify.yml
vendored
Normal file
3
test/testdata/configs/gofmt_no_simplify.yml
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
linters-settings:
|
||||||
|
gofmt:
|
||||||
|
simplify: false
|
3
test/testdata/configs/gofumpt-fix.yml
vendored
Normal file
3
test/testdata/configs/gofumpt-fix.yml
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
linters-settings:
|
||||||
|
gofumpt:
|
||||||
|
extra-rules: true
|
3
test/testdata/configs/gofumpt_with_extra.yml
vendored
Normal file
3
test/testdata/configs/gofumpt_with_extra.yml
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
linters-settings:
|
||||||
|
gofumpt:
|
||||||
|
extra-rules: true
|
3
test/testdata/configs/goimports.yml
vendored
Normal file
3
test/testdata/configs/goimports.yml
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
linters-settings:
|
||||||
|
goimports:
|
||||||
|
local-prefixes: github.com/golangci/golangci-lint
|
3
test/testdata/configs/govet.yml
vendored
Normal file
3
test/testdata/configs/govet.yml
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
linters-settings:
|
||||||
|
govet:
|
||||||
|
check-shadowing: true
|
3
test/testdata/configs/govet_fieldalignment.yml
vendored
Normal file
3
test/testdata/configs/govet_fieldalignment.yml
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
linters-settings:
|
||||||
|
govet:
|
||||||
|
enable: fieldalignment
|
3
test/testdata/configs/govet_ifaceassert.yml
vendored
Normal file
3
test/testdata/configs/govet_ifaceassert.yml
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
linters-settings:
|
||||||
|
govet:
|
||||||
|
enable: ifaceassert
|
3
test/testdata/configs/lll.yml
vendored
Normal file
3
test/testdata/configs/lll.yml
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
linters-settings:
|
||||||
|
lll:
|
||||||
|
tab-width: 4
|
3
test/testdata/configs/makezero_always.yml
vendored
Normal file
3
test/testdata/configs/makezero_always.yml
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
linters-settings:
|
||||||
|
makezero:
|
||||||
|
always: true
|
3
test/testdata/configs/nestif.yml
vendored
Normal file
3
test/testdata/configs/nestif.yml
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
linters-settings:
|
||||||
|
nestif:
|
||||||
|
min-complexity: 1
|
4
test/testdata/configs/nolintlint.yml
vendored
Normal file
4
test/testdata/configs/nolintlint.yml
vendored
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
linters-settings:
|
||||||
|
nolintlint:
|
||||||
|
require-explanation: true
|
||||||
|
require-specific: true
|
3
test/testdata/configs/nolintlint_unused.yml
vendored
Normal file
3
test/testdata/configs/nolintlint_unused.yml
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
linters-settings:
|
||||||
|
nolintlint:
|
||||||
|
allow-unused: false
|
4
test/testdata/configs/whitespace-fix.yml
vendored
Normal file
4
test/testdata/configs/whitespace-fix.yml
vendored
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
linters-settings:
|
||||||
|
whitespace:
|
||||||
|
multi-if: true
|
||||||
|
multi-func: true
|
3
test/testdata/configs/wsl.yml
vendored
Normal file
3
test/testdata/configs/wsl.yml
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
linters-settings:
|
||||||
|
wsl:
|
||||||
|
allow-cuddle-declarations: false
|
2
test/testdata/cyclop.go
vendored
2
test/testdata/cyclop.go
vendored
@ -1,5 +1,5 @@
|
|||||||
//golangcitest:args -Ecyclop
|
//golangcitest:args -Ecyclop
|
||||||
//golangcitest:config linters-settings.cyclop.max-complexity=15
|
//golangcitest:config_path testdata/configs/cyclop.yml
|
||||||
package testdata
|
package testdata
|
||||||
|
|
||||||
func cyclopComplexFunc(s string) { // ERROR "calculated cyclomatic complexity for function cyclopComplexFunc is 22, max is 15"
|
func cyclopComplexFunc(s string) { // ERROR "calculated cyclomatic complexity for function cyclopComplexFunc is 22, max is 15"
|
||||||
|
2
test/testdata/dupl.go
vendored
2
test/testdata/dupl.go
vendored
@ -1,5 +1,5 @@
|
|||||||
//golangcitest:args -Edupl
|
//golangcitest:args -Edupl
|
||||||
//golangcitest:config linters-settings.dupl.threshold=20
|
//golangcitest:config_path testdata/configs/dupl.yml
|
||||||
package testdata
|
package testdata
|
||||||
|
|
||||||
type DuplLogger struct{}
|
type DuplLogger struct{}
|
||||||
|
3
test/testdata/errcheck_exclude.go
vendored
3
test/testdata/errcheck_exclude.go
vendored
@ -1,6 +1,5 @@
|
|||||||
//golangcitest:args -Eerrcheck
|
//golangcitest:args -Eerrcheck
|
||||||
//golangcitest:config linters-settings.errcheck.check-blank=true
|
//golangcitest:config_path testdata/configs/errcheck_exclude.yml
|
||||||
//golangcitest:config linters-settings.errcheck.exclude=testdata/errcheck/exclude.txt
|
|
||||||
package testdata
|
package testdata
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
2
test/testdata/errcheck_ignore_default.go
vendored
2
test/testdata/errcheck_ignore_default.go
vendored
@ -1,5 +1,5 @@
|
|||||||
//golangcitest:args -Eerrcheck
|
//golangcitest:args -Eerrcheck
|
||||||
//golangcitest:config linters-settings.errcheck.check-blank=true
|
//golangcitest:config_path testdata/configs/errcheck_ignore_default.yml
|
||||||
package testdata
|
package testdata
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
2
test/testdata/errcheck_type_assertions.go
vendored
2
test/testdata/errcheck_type_assertions.go
vendored
@ -1,5 +1,5 @@
|
|||||||
//golangcitest:args -Eerrcheck
|
//golangcitest:args -Eerrcheck
|
||||||
//golangcitest:config linters-settings.errcheck.check-type-assertions=true
|
//golangcitest:config_path testdata/configs/errcheck_type_assertions.yml
|
||||||
package testdata
|
package testdata
|
||||||
|
|
||||||
func ErrorTypeAssertion(filter map[string]interface{}) bool {
|
func ErrorTypeAssertion(filter map[string]interface{}) bool {
|
||||||
|
2
test/testdata/fix/in/gofumpt.go
vendored
2
test/testdata/fix/in/gofumpt.go
vendored
@ -1,5 +1,5 @@
|
|||||||
//golangcitest:args -Egofumpt
|
//golangcitest:args -Egofumpt
|
||||||
//golangcitest:config linters-settings.gofumpt.extra-rules=true
|
//golangcitest:config_path testdata/configs/gofumpt-fix.yml
|
||||||
package p
|
package p
|
||||||
|
|
||||||
import "fmt"
|
import "fmt"
|
||||||
|
3
test/testdata/fix/in/whitespace.go
vendored
3
test/testdata/fix/in/whitespace.go
vendored
@ -1,6 +1,5 @@
|
|||||||
//golangcitest:args -Ewhitespace
|
//golangcitest:args -Ewhitespace
|
||||||
//golangcitest:config linters-settings.whitespace.multi-if=true
|
//golangcitest:config_path testdata/configs/whitespace-fix.yml
|
||||||
//golangcitest:config linters-settings.whitespace.multi-func=true
|
|
||||||
package p
|
package p
|
||||||
|
|
||||||
import "fmt"
|
import "fmt"
|
||||||
|
2
test/testdata/fix/out/gofumpt.go
vendored
2
test/testdata/fix/out/gofumpt.go
vendored
@ -1,5 +1,5 @@
|
|||||||
//golangcitest:args -Egofumpt
|
//golangcitest:args -Egofumpt
|
||||||
//golangcitest:config linters-settings.gofumpt.extra-rules=true
|
//golangcitest:config_path testdata/configs/gofumpt-fix.yml
|
||||||
package p
|
package p
|
||||||
|
|
||||||
import "fmt"
|
import "fmt"
|
||||||
|
3
test/testdata/fix/out/whitespace.go
vendored
3
test/testdata/fix/out/whitespace.go
vendored
@ -1,6 +1,5 @@
|
|||||||
//golangcitest:args -Ewhitespace
|
//golangcitest:args -Ewhitespace
|
||||||
//golangcitest:config linters-settings.whitespace.multi-if=true
|
//golangcitest:config_path testdata/configs/whitespace-fix.yml
|
||||||
//golangcitest:config linters-settings.whitespace.multi-func=true
|
|
||||||
package p
|
package p
|
||||||
|
|
||||||
import "fmt"
|
import "fmt"
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
//golangcitest:args -Eforbidigo
|
//golangcitest:args -Eforbidigo
|
||||||
//golangcitest:config linters-settings.forbidigo.exclude-godoc-examples=false
|
//golangcitest:config_path testdata/configs/forbidigo_include_godoc_examples.yml
|
||||||
package testdata
|
package testdata
|
||||||
|
|
||||||
import "fmt"
|
import "fmt"
|
||||||
|
3
test/testdata/funlen.go
vendored
3
test/testdata/funlen.go
vendored
@ -1,6 +1,5 @@
|
|||||||
//golangcitest:args -Efunlen
|
//golangcitest:args -Efunlen
|
||||||
//golangcitest:config linters-settings.funlen.lines=20
|
//golangcitest:config_path testdata/configs/funlen.yml
|
||||||
//golangcitest:config linters-settings.funlen.statements=10
|
|
||||||
package testdata
|
package testdata
|
||||||
|
|
||||||
func TooManyLines() { // ERROR `Function 'TooManyLines' is too long \(22 > 20\)`
|
func TooManyLines() { // ERROR `Function 'TooManyLines' is too long \(22 > 20\)`
|
||||||
|
2
test/testdata/gocognit.go
vendored
2
test/testdata/gocognit.go
vendored
@ -1,5 +1,5 @@
|
|||||||
//golangcitest:args -Egocognit
|
//golangcitest:args -Egocognit
|
||||||
//golangcitest:config linters-settings.gocognit.min-complexity=2
|
//golangcitest:config_path testdata/configs/gocognit.yml
|
||||||
package testdata
|
package testdata
|
||||||
|
|
||||||
func GoCognit_CC4_GetWords(number int) string { // ERROR "cognitive complexity 4 of func .* is high .*"
|
func GoCognit_CC4_GetWords(number int) string { // ERROR "cognitive complexity 4 of func .* is high .*"
|
||||||
|
2
test/testdata/goconst_calls_enabled.go
vendored
2
test/testdata/goconst_calls_enabled.go
vendored
@ -1,5 +1,5 @@
|
|||||||
//golangcitest:args -Egoconst
|
//golangcitest:args -Egoconst
|
||||||
//golangcitest:config linters-settings.goconst.ignore-calls=false
|
//golangcitest:config_path testdata/configs/goconst_calls_enabled.yml
|
||||||
package testdata
|
package testdata
|
||||||
|
|
||||||
import "fmt"
|
import "fmt"
|
||||||
|
2
test/testdata/goconst_dont_ignore_test.go
vendored
2
test/testdata/goconst_dont_ignore_test.go
vendored
@ -1,5 +1,5 @@
|
|||||||
//golangcitest:args -Egoconst
|
//golangcitest:args -Egoconst
|
||||||
//golangcitest:config linters-settings.goconst.ignore-tests=false
|
//golangcitest:config_path testdata/configs/goconst_dont_ignore.yml
|
||||||
package testdata
|
package testdata
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
2
test/testdata/goconst_ignore_test.go
vendored
2
test/testdata/goconst_ignore_test.go
vendored
@ -1,5 +1,5 @@
|
|||||||
//golangcitest:args -Egoconst
|
//golangcitest:args -Egoconst
|
||||||
//golangcitest:config linters-settings.goconst.ignore-tests=true
|
//golangcitest:config_path testdata/configs/goconst_ignore.yml
|
||||||
package testdata
|
package testdata
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
2
test/testdata/gocyclo.go
vendored
2
test/testdata/gocyclo.go
vendored
@ -1,5 +1,5 @@
|
|||||||
//golangcitest:args -Egocyclo
|
//golangcitest:args -Egocyclo
|
||||||
//golangcitest:config linters-settings.gocyclo.min-complexity=20
|
//golangcitest:config_path testdata/configs/gocyclo.yml
|
||||||
package testdata
|
package testdata
|
||||||
|
|
||||||
import "net/http"
|
import "net/http"
|
||||||
|
2
test/testdata/godox.go
vendored
2
test/testdata/godox.go
vendored
@ -1,5 +1,5 @@
|
|||||||
//golangcitest:args -Egodox
|
//golangcitest:args -Egodox
|
||||||
//golangcitest:config linters-settings.godox.keywords=FIXME,TODO
|
//golangcitest:config_path testdata/configs/godox.yml
|
||||||
package testdata
|
package testdata
|
||||||
|
|
||||||
func todoLeftInCode() {
|
func todoLeftInCode() {
|
||||||
|
2
test/testdata/gofmt_no_simplify.go
vendored
2
test/testdata/gofmt_no_simplify.go
vendored
@ -1,5 +1,5 @@
|
|||||||
//golangcitest:args -Egofmt
|
//golangcitest:args -Egofmt
|
||||||
//golangcitest:config linters-settings.gofmt.simplify=false
|
//golangcitest:config_path testdata/configs/gofmt_no_simplify.yml
|
||||||
package testdata
|
package testdata
|
||||||
|
|
||||||
import "fmt"
|
import "fmt"
|
||||||
|
2
test/testdata/gofumpt_with_extra.go
vendored
2
test/testdata/gofumpt_with_extra.go
vendored
@ -1,5 +1,5 @@
|
|||||||
//golangcitest:args -Egofumpt
|
//golangcitest:args -Egofumpt
|
||||||
//golangcitest:config linters-settings.gofumpt.extra-rules=true
|
//golangcitest:config_path testdata/configs/gofumpt_with_extra.yml
|
||||||
package testdata
|
package testdata
|
||||||
|
|
||||||
import "fmt"
|
import "fmt"
|
||||||
|
2
test/testdata/goimports/goimports.go
vendored
2
test/testdata/goimports/goimports.go
vendored
@ -1,5 +1,5 @@
|
|||||||
//golangcitest:args -Egoimports
|
//golangcitest:args -Egoimports
|
||||||
//golangcitest:config linters-settings.goimports.local-prefixes=github.com/golangci/golangci-lint
|
//golangcitest:config_path testdata/configs/goimports.yml
|
||||||
package goimports
|
package goimports
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
2
test/testdata/govet.go
vendored
2
test/testdata/govet.go
vendored
@ -1,5 +1,5 @@
|
|||||||
//golangcitest:args -Egovet
|
//golangcitest:args -Egovet
|
||||||
//golangcitest:config linters-settings.govet.check-shadowing=true
|
//golangcitest:config_path testdata/configs/govet.yml
|
||||||
package testdata
|
package testdata
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
2
test/testdata/govet_fieldalignment.go
vendored
2
test/testdata/govet_fieldalignment.go
vendored
@ -1,5 +1,5 @@
|
|||||||
//golangcitest:args -Egovet
|
//golangcitest:args -Egovet
|
||||||
//golangcitest:config linters-settings.govet.enable=fieldalignment
|
//golangcitest:config_path testdata/configs/govet_fieldalignment.yml
|
||||||
package testdata
|
package testdata
|
||||||
|
|
||||||
type gvfaGood struct {
|
type gvfaGood struct {
|
||||||
|
2
test/testdata/govet_ifaceassert.go
vendored
2
test/testdata/govet_ifaceassert.go
vendored
@ -1,5 +1,5 @@
|
|||||||
//golangcitest:args -Egovet
|
//golangcitest:args -Egovet
|
||||||
//golangcitest:config linters-settings.govet.enable=ifaceassert
|
//golangcitest:config_path testdata/configs/govet_ifaceassert.yml
|
||||||
package testdata
|
package testdata
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
2
test/testdata/lll.go
vendored
2
test/testdata/lll.go
vendored
@ -1,5 +1,5 @@
|
|||||||
//golangcitest:args -Elll
|
//golangcitest:args -Elll
|
||||||
//golangcitest:config linters-settings.lll.tab-width=4
|
//golangcitest:config_path testdata/configs/lll.yml
|
||||||
package testdata
|
package testdata
|
||||||
|
|
||||||
func Lll() {
|
func Lll() {
|
||||||
|
2
test/testdata/makezero_always.go
vendored
2
test/testdata/makezero_always.go
vendored
@ -1,5 +1,5 @@
|
|||||||
//golangcitest:args -Emakezero
|
//golangcitest:args -Emakezero
|
||||||
//golangcitest:config linters-settings.makezero.always=true
|
//golangcitest:config_path testdata/configs/makezero_always.yml
|
||||||
package testdata
|
package testdata
|
||||||
|
|
||||||
import "math"
|
import "math"
|
||||||
|
2
test/testdata/nestif.go
vendored
2
test/testdata/nestif.go
vendored
@ -1,5 +1,5 @@
|
|||||||
//golangcitest:args -Enestif
|
//golangcitest:args -Enestif
|
||||||
//golangcitest:config linters-settings.nestif.min-complexity=1
|
//golangcitest:config_path testdata/configs/nestif.yml
|
||||||
package testdata
|
package testdata
|
||||||
|
|
||||||
func _() {
|
func _() {
|
||||||
|
3
test/testdata/nolintlint.go
vendored
3
test/testdata/nolintlint.go
vendored
@ -1,7 +1,6 @@
|
|||||||
//golangcitest:args -Enolintlint -Emisspell
|
//golangcitest:args -Enolintlint -Emisspell
|
||||||
//golangcitest:expected_linter nolintlint
|
//golangcitest:expected_linter nolintlint
|
||||||
//golangcitest:config linters-settings.nolintlint.require-explanation=true
|
//golangcitest:config_path testdata/configs/nolintlint.yml
|
||||||
//golangcitest:config linters-settings.nolintlint.require-specific=true
|
|
||||||
package testdata
|
package testdata
|
||||||
|
|
||||||
import "fmt"
|
import "fmt"
|
||||||
|
2
test/testdata/nolintlint_unused.go
vendored
2
test/testdata/nolintlint_unused.go
vendored
@ -1,6 +1,6 @@
|
|||||||
//golangcitest:args -Enolintlint -Evarcheck
|
//golangcitest:args -Enolintlint -Evarcheck
|
||||||
//golangcitest:config linters-settings.nolintlint.allow-unused=false
|
|
||||||
//golangcitest:expected_linter nolintlint
|
//golangcitest:expected_linter nolintlint
|
||||||
|
//golangcitest:config_path testdata/configs/nolintlint_unused.yml
|
||||||
package testdata
|
package testdata
|
||||||
|
|
||||||
import "fmt"
|
import "fmt"
|
||||||
|
2
test/testdata/wsl.go
vendored
2
test/testdata/wsl.go
vendored
@ -1,5 +1,5 @@
|
|||||||
//golangcitest:args -Ewsl
|
//golangcitest:args -Ewsl
|
||||||
//golangcitest:config linters-settings.wsl.tests=1
|
//golangcitest:config_path testdata/configs/wsl.yml
|
||||||
package testdata
|
package testdata
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -153,8 +153,7 @@ func (r *LintRunner) RunCommandWithYamlConfig(cfg, command string, args ...strin
|
|||||||
defer os.Remove(cfgPath)
|
defer os.Remove(cfgPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
cfg = strings.TrimSpace(cfg)
|
cfg = strings.ReplaceAll(strings.TrimSpace(cfg), "\t", " ")
|
||||||
cfg = strings.ReplaceAll(cfg, "\t", " ")
|
|
||||||
|
|
||||||
err = os.WriteFile(cfgPath, []byte(cfg), os.ModePerm)
|
err = os.WriteFile(cfgPath, []byte(cfg), os.ModePerm)
|
||||||
assert.NoError(r.t, err)
|
assert.NoError(r.t, err)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user