build(deps): bump github.com/Antonboom/nilnil from 0.1.8 to 0.1.9 (#4716)

This commit is contained in:
Anton Telyshev 2024-05-11 03:30:23 +03:00 committed by GitHub
parent 8fe47a93c9
commit 7c87a9e6ae
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 155 additions and 14 deletions

View File

@ -1387,14 +1387,16 @@ linters-settings:
min-complexity: 4 min-complexity: 4
nilnil: nilnil:
# Checks that there is no simultaneous return of `nil` error and an invalid value. # List of return types to check.
# Default: ["ptr", "func", "iface", "map", "chan"] # Default: ["ptr", "func", "iface", "map", "chan", "uintptr", "unsafeptr"]
checked-types: checked-types:
- ptr - ptr
- func - func
- iface - iface
- map - map
- chan - chan
- uintptr
- unsafeptr
nlreturn: nlreturn:
# Size of the block (including return statement that is still "OK") # Size of the block (including return statement that is still "OK")

2
go.mod
View File

@ -8,7 +8,7 @@ require (
github.com/4meepo/tagalign v1.3.4 github.com/4meepo/tagalign v1.3.4
github.com/Abirdcfly/dupword v0.0.14 github.com/Abirdcfly/dupword v0.0.14
github.com/Antonboom/errname v0.1.13 github.com/Antonboom/errname v0.1.13
github.com/Antonboom/nilnil v0.1.8 github.com/Antonboom/nilnil v0.1.9
github.com/Antonboom/testifylint v1.2.0 github.com/Antonboom/testifylint v1.2.0
github.com/BurntSushi/toml v1.3.2 github.com/BurntSushi/toml v1.3.2
github.com/Crocmagnon/fatcontext v0.2.2 github.com/Crocmagnon/fatcontext v0.2.2

4
go.sum generated
View File

@ -41,8 +41,8 @@ github.com/Abirdcfly/dupword v0.0.14 h1:3U4ulkc8EUo+CaT105/GJ1BQwtgyj6+VaBVbAX11
github.com/Abirdcfly/dupword v0.0.14/go.mod h1:VKDAbxdY8YbKUByLGg8EETzYSuC4crm9WwI6Y3S0cLI= github.com/Abirdcfly/dupword v0.0.14/go.mod h1:VKDAbxdY8YbKUByLGg8EETzYSuC4crm9WwI6Y3S0cLI=
github.com/Antonboom/errname v0.1.13 h1:JHICqsewj/fNckzrfVSe+T33svwQxmjC+1ntDsHOVvM= github.com/Antonboom/errname v0.1.13 h1:JHICqsewj/fNckzrfVSe+T33svwQxmjC+1ntDsHOVvM=
github.com/Antonboom/errname v0.1.13/go.mod h1:uWyefRYRN54lBg6HseYCFhs6Qjcy41Y3Jl/dVhA87Ns= github.com/Antonboom/errname v0.1.13/go.mod h1:uWyefRYRN54lBg6HseYCFhs6Qjcy41Y3Jl/dVhA87Ns=
github.com/Antonboom/nilnil v0.1.8 h1:97QG7xrLq4TBK2U9aFq/I8Mcgz67pwMIiswnTA9gIn0= github.com/Antonboom/nilnil v0.1.9 h1:eKFMejSxPSA9eLSensFmjW2XTgTwJMjZ8hUHtV4s/SQ=
github.com/Antonboom/nilnil v0.1.8/go.mod h1:iGe2rYwCq5/Me1khrysB4nwI7swQvjclR8/YRPl5ihQ= github.com/Antonboom/nilnil v0.1.9/go.mod h1:iGe2rYwCq5/Me1khrysB4nwI7swQvjclR8/YRPl5ihQ=
github.com/Antonboom/testifylint v1.2.0 h1:015bxD8zc5iY8QwTp4+RG9I4kIbqwvGX9TrBbb7jGdM= github.com/Antonboom/testifylint v1.2.0 h1:015bxD8zc5iY8QwTp4+RG9I4kIbqwvGX9TrBbb7jGdM=
github.com/Antonboom/testifylint v1.2.0/go.mod h1:rkmEqjqVnHDRNsinyN6fPSLnoajzFwsCcguJgwADBkw= github.com/Antonboom/testifylint v1.2.0/go.mod h1:rkmEqjqVnHDRNsinyN6fPSLnoajzFwsCcguJgwADBkw=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=

View File

@ -2082,11 +2082,11 @@
"properties": { "properties": {
"checked-types": { "checked-types": {
"type": "array", "type": "array",
"description": "Order of return types to check.", "description": "List of return types to check.",
"items": { "items": {
"enum": ["ptr", "func", "iface", "map", "chan"] "enum": ["ptr", "func", "iface", "map", "chan", "uintptr", "unsafeptr"]
}, },
"default": ["ptr", "func", "iface", "map", "chan"] "default": ["ptr", "func", "iface", "map", "chan", "uintptr", "unsafeptr"]
} }
} }
}, },

View File

@ -2,7 +2,11 @@
package testdata package testdata
import ( import (
"bytes"
"go/token"
"io" "io"
"net/http"
"os"
"unsafe" "unsafe"
) )
@ -24,6 +28,26 @@ func anonymousStructPtr() (*struct{ ID string }, error) {
return nil, nil // want "return both the `nil` error and invalid value: use a sentinel error instead" return nil, nil // want "return both the `nil` error and invalid value: use a sentinel error instead"
} }
func unsafePtr() (unsafe.Pointer, error) {
return nil, nil // want "return both the `nil` error and invalid value: use a sentinel error instead"
}
func uintPtr() (uintptr, error) {
return 0, nil // want "return both the `nil` error and invalid value: use a sentinel error instead"
}
func uintPtr0b() (uintptr, error) {
return 0b0, nil // want "return both the `nil` error and invalid value: use a sentinel error instead"
}
func uintPtr0x() (uintptr, error) {
return 0x00, nil // want "return both the `nil` error and invalid value: use a sentinel error instead"
}
func uintPtr0o() (uintptr, error) {
return 0o000, nil // want "return both the `nil` error and invalid value: use a sentinel error instead"
}
func chBi() (chan int, error) { func chBi() (chan int, error) {
return nil, nil // want "return both the `nil` error and invalid value: use a sentinel error instead" return nil, nil // want "return both the `nil` error and invalid value: use a sentinel error instead"
} }
@ -48,6 +72,10 @@ func iface() (interface{}, error) {
return nil, nil // want "return both the `nil` error and invalid value: use a sentinel error instead" return nil, nil // want "return both the `nil` error and invalid value: use a sentinel error instead"
} }
func anyType() (any, error) {
return nil, nil // want "return both the `nil` error and invalid value: use a sentinel error instead"
}
func m1() (map[int]int, error) { func m1() (map[int]int, error) {
return nil, nil // want "return both the `nil` error and invalid value: use a sentinel error instead" return nil, nil // want "return both the `nil` error and invalid value: use a sentinel error instead"
} }
@ -56,6 +84,12 @@ func m2() (map[int]*User, error) {
return nil, nil // want "return both the `nil` error and invalid value: use a sentinel error instead" return nil, nil // want "return both the `nil` error and invalid value: use a sentinel error instead"
} }
type mapAlias = map[int]*User
func m3() (mapAlias, error) {
return nil, nil // want "return both the `nil` error and invalid value: use a sentinel error instead"
}
type Storage struct{} type Storage struct{}
func (s *Storage) GetUser() (*User, error) { func (s *Storage) GetUser() (*User, error) {
@ -119,6 +153,39 @@ func deeplyNested() {
} }
} }
type MyError interface {
error
Code() string
}
func myError() (*User, MyError) {
return nil, nil // want "return both the `nil` error and invalid value: use a sentinel error instead"
}
// Types.
func structPtrTypeExtPkg() (*os.File, error) {
return nil, nil // want "return both the `nil` error and invalid value: use a sentinel error instead"
}
func primitivePtrTypeExtPkg() (*token.Token, error) {
return nil, nil // want "return both the `nil` error and invalid value: use a sentinel error instead"
}
func funcTypeExtPkg() (http.HandlerFunc, error) {
return nil, nil // want "return both the `nil` error and invalid value: use a sentinel error instead"
}
func ifaceTypeExtPkg() (io.Closer, error) {
return nil, nil // want "return both the `nil` error and invalid value: use a sentinel error instead"
}
type closerAlias = io.Closer
func ifaceTypeAliasedExtPkg() (closerAlias, error) {
return nil, nil // want "return both the `nil` error and invalid value: use a sentinel error instead"
}
type ( type (
StructPtrType *User StructPtrType *User
PrimitivePtrType *int PrimitivePtrType *int
@ -147,21 +214,93 @@ func ifaceType() (Checker, error) {
return nil, nil // want "return both the `nil` error and invalid value: use a sentinel error instead" return nil, nil // want "return both the `nil` error and invalid value: use a sentinel error instead"
} }
type checkerAlias = Checker
func ifaceTypeAliased() (checkerAlias, error) {
return nil, nil // want "return both the `nil` error and invalid value: use a sentinel error instead"
}
type (
IntegerType int
PtrIntegerType *IntegerType
)
func ptrIntegerType() (PtrIntegerType, error) {
return nil, nil // want "return both the `nil` error and invalid value: use a sentinel error instead"
}
// Not checked at all.
func withoutArgs() {} func withoutArgs() {}
func withoutError1() *User { return nil } func withoutError1() *User { return nil }
func withoutError2() (*User, *User) { return nil, nil } func withoutError2() (*User, *User) { return nil, nil }
func withoutError3() (*User, *User, *User) { return nil, nil, nil } func withoutError3() (*User, *User, *User) { return nil, nil, nil }
func withoutError4() (*User, *User, *User, *User) { return nil, nil, nil, nil } func withoutError4() (*User, *User, *User, *User) { return nil, nil, nil, nil }
// Unsupported.
func invalidOrder() (error, *User) { return nil, nil } func invalidOrder() (error, *User) { return nil, nil }
func withError3rd() (*User, bool, error) { return nil, false, nil } func withError3rd() (*User, bool, error) { return nil, false, nil }
func withError4th() (*User, *User, *User, error) { return nil, nil, nil, nil } func withError4th() (*User, *User, *User, error) { return nil, nil, nil, nil }
func unsafePtr() (unsafe.Pointer, error) { return nil, nil }
func uintPtr() (uintptr, error) { return 0, nil }
func slice() ([]int, error) { return nil, nil } func slice() ([]int, error) { return nil, nil }
func ifaceExtPkg() (io.Closer, error) { return nil, nil }
func strNil() (string, error) { return "nil", nil }
func strEmpty() (string, error) { return "", nil }
// Valid.
func primitivePtrTypeValid() (*int, error) {
if false {
return nil, io.EOF
}
return new(int), nil
}
func structPtrTypeValid() (*User, error) {
if false {
return nil, io.EOF
}
return new(User), nil
}
func unsafePtrValid() (unsafe.Pointer, error) {
if false {
return nil, io.EOF
}
var i int
return unsafe.Pointer(&i), nil
}
func uintPtrValid() (uintptr, error) {
if false {
return 0, io.EOF
}
return 0xc82000c290, nil
}
func channelTypeValid() (ChannelType, error) {
if false {
return nil, io.EOF
}
return make(ChannelType), nil
}
func funcTypeValid() (FuncType, error) {
if false {
return nil, io.EOF
}
return func(i int) int {
return 0
}, nil
}
func ifaceTypeValid() (io.Reader, error) {
if false {
return nil, io.EOF
}
return new(bytes.Buffer), nil
}
// Unsupported.
func implicitNil1() (*User, error) { func implicitNil1() (*User, error) {
err := (error)(nil) err := (error)(nil)