Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions .golangci.next.reference.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1387,14 +1387,16 @@ linters-settings:
min-complexity: 4

nilnil:
# Checks that there is no simultaneous return of `nil` error and an invalid value.
# Default: ["ptr", "func", "iface", "map", "chan"]
# List of return types to check.
# Default: ["ptr", "func", "iface", "map", "chan", "uintptr", "unsafeptr"]
checked-types:
- ptr
- func
- iface
- map
- chan
- uintptr
- unsafeptr

nlreturn:
# Size of the block (including return statement that is still "OK")
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ require (
github.com/4meepo/tagalign v1.3.4
github.com/Abirdcfly/dupword v0.0.14
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/BurntSushi/toml v1.3.2
github.com/Crocmagnon/fatcontext v0.2.2
Expand Down
4 changes: 2 additions & 2 deletions go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions jsonschema/golangci.next.jsonschema.json
Original file line number Diff line number Diff line change
Expand Up @@ -2082,11 +2082,11 @@
"properties": {
"checked-types": {
"type": "array",
"description": "Order of return types to check.",
"description": "List of return types to check.",
"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"]
}
}
},
Expand Down
151 changes: 145 additions & 6 deletions pkg/golinters/nilnil/testdata/nilnil.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@
package testdata

import (
"bytes"
"go/token"
"io"
"net/http"
"os"
"unsafe"
)

Expand All @@ -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"
}

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) {
return nil, nil // want "return both the `nil` error and invalid value: use a sentinel error instead"
}
Expand All @@ -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"
}

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) {
return nil, nil // want "return both the `nil` error and invalid value: use a sentinel error instead"
}
Expand All @@ -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"
}

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{}

func (s *Storage) GetUser() (*User, error) {
Expand Down Expand Up @@ -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 (
StructPtrType *User
PrimitivePtrType *int
Expand Down Expand Up @@ -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"
}

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 withoutError1() *User { return nil }
func withoutError2() (*User, *User) { return nil, nil }
func withoutError3() (*User, *User, *User) { return nil, nil, nil }
func withoutError4() (*User, *User, *User, *User) { return nil, nil, nil, nil }

// Unsupported.

func invalidOrder() (error, *User) { return nil, nil }
func withError3rd() (*User, bool, error) { return nil, false, 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 ifaceExtPkg() (io.Closer, error) { return nil, nil }

func slice() ([]int, 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) {
err := (error)(nil)
Expand Down