golangci-lint: Upgrade, fix issues (#397)
The golangci-lint being used was quite dated. This change upgrades to the latest version. Adds and updates exclusions based on new failures. Note on revive: I've included an opt-out for unused parameters for revive because turning `newThing(required bool)` to `newThing(_ bool)` is a loss of useful information. The changes to the Go files are to fix the following issues: ``` camelcase.go:16: File is not `gofmt`-ed with `-s` (gofmt) config_test.go:50:18: directive `//nolint: gosec` is unused for linter "gosec" (nolintlint) defaults_test.go:28:25: G601: Implicit memory aliasing in for loop. (gosec) doc.go:5: File is not `gofmt`-ed with `-s` (gofmt) kong.go:446:18: directive `//nolint: gosec` is unused for linter "gosec" (nolintlint) kong_test.go:503:20: G601: Implicit memory aliasing in for loop. (gosec) model.go:493:10: composites: reflect.ValueError struct literal uses unkeyed fields (govet) scanner.go:112: File is not `gofmt`-ed with `-s` (gofmt) ``` And to address broken nolint directives reported as follows by golangci-lint. ``` [.. skipped .. ] tag.go:65:1: directive `// nolint:gocyclo` should be written without leading space as `//nolint:gocyclo` (nolintlint) tag.go:206:51: directive `// nolint: gocyclo` should be written without leading space as `//nolint: gocyclo` (nolintlint) util_test.go:23:43: directive `// nolint: errcheck` should be written without leading space as `//nolint: errcheck` (nolintlint) util_test.go:51:22: directive `// nolint: errcheck` should be written without leading space as `//nolint: errcheck` (nolintlint) ```
This commit is contained in:
+7
-6
@@ -495,6 +495,7 @@ func TestHooks(t *testing.T) {
|
||||
p := mustNew(t, &cli, kong.Bind(ctx))
|
||||
|
||||
for _, test := range tests {
|
||||
test := test
|
||||
*ctx = hookContext{}
|
||||
cli.One = hookCmd{}
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
@@ -753,7 +754,7 @@ func TestEmbedInterface(t *testing.T) {
|
||||
_, err := p.Parse([]string{"--some-flag=foo", "--flag=yes"})
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, "foo", cli.SomeFlag)
|
||||
assert.Equal(t, "yes", cli.TestInterface.(*TestImpl).Flag) // nolint
|
||||
assert.Equal(t, "yes", cli.TestInterface.(*TestImpl).Flag) //nolint
|
||||
}
|
||||
|
||||
func TestExcludedField(t *testing.T) {
|
||||
@@ -1352,16 +1353,16 @@ func TestHydratePointerCommandsAndEmbeds(t *testing.T) {
|
||||
assert.Equal(t, &embed{Embed: true}, cli.Embed)
|
||||
}
|
||||
|
||||
// nolint
|
||||
//nolint:revive
|
||||
type testIgnoreFields struct {
|
||||
Foo struct {
|
||||
Bar bool
|
||||
Sub struct {
|
||||
SubFlag1 bool `kong:"name=subflag1"`
|
||||
XXX_SubFlag2 bool `kong:"name=subflag2"`
|
||||
XXX_SubFlag2 bool `kong:"name=subflag2"` //nolint:stylecheck
|
||||
} `kong:"cmd"`
|
||||
} `kong:"cmd"`
|
||||
XXX_Baz struct {
|
||||
XXX_Baz struct { //nolint:stylecheck
|
||||
Boo bool
|
||||
} `kong:"cmd,name=baz"`
|
||||
}
|
||||
@@ -1928,8 +1929,8 @@ func TestBoolPtrNil(t *testing.T) {
|
||||
|
||||
func TestUnsupportedPtr(t *testing.T) {
|
||||
type Foo struct {
|
||||
x int // nolint
|
||||
y int // nolint
|
||||
x int //nolint
|
||||
y int //nolint
|
||||
}
|
||||
|
||||
var cli struct {
|
||||
|
||||
Reference in New Issue
Block a user