Skip to content

Commit 7c87a9e

Browse files
authored
build(deps): bump github.com/Antonboom/nilnil from 0.1.8 to 0.1.9 (#4716)
1 parent 8fe47a9 commit 7c87a9e

File tree

5 files changed

+155
-14
lines changed

5 files changed

+155
-14
lines changed

.golangci.next.reference.yml

+4-2
Original file line numberDiff line numberDiff line change
@@ -1387,14 +1387,16 @@ linters-settings:
13871387
min-complexity: 4
13881388

13891389
nilnil:
1390-
# Checks that there is no simultaneous return of `nil` error and an invalid value.
1391-
# Default: ["ptr", "func", "iface", "map", "chan"]
1390+
# List of return types to check.
1391+
# Default: ["ptr", "func", "iface", "map", "chan", "uintptr", "unsafeptr"]
13921392
checked-types:
13931393
- ptr
13941394
- func
13951395
- iface
13961396
- map
13971397
- chan
1398+
- uintptr
1399+
- unsafeptr
13981400

13991401
nlreturn:
14001402
# Size of the block (including return statement that is still "OK")

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ require (
88
github.com/4meepo/tagalign v1.3.4
99
github.com/Abirdcfly/dupword v0.0.14
1010
github.com/Antonboom/errname v0.1.13
11-
github.com/Antonboom/nilnil v0.1.8
11+
github.com/Antonboom/nilnil v0.1.9
1212
github.com/Antonboom/testifylint v1.2.0
1313
github.com/BurntSushi/toml v1.3.2
1414
github.com/Crocmagnon/fatcontext v0.2.2

go.sum

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

jsonschema/golangci.next.jsonschema.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -2082,11 +2082,11 @@
20822082
"properties": {
20832083
"checked-types": {
20842084
"type": "array",
2085-
"description": "Order of return types to check.",
2085+
"description": "List of return types to check.",
20862086
"items": {
2087-
"enum": ["ptr", "func", "iface", "map", "chan"]
2087+
"enum": ["ptr", "func", "iface", "map", "chan", "uintptr", "unsafeptr"]
20882088
},
2089-
"default": ["ptr", "func", "iface", "map", "chan"]
2089+
"default": ["ptr", "func", "iface", "map", "chan", "uintptr", "unsafeptr"]
20902090
}
20912091
}
20922092
},

pkg/golinters/nilnil/testdata/nilnil.go

+145-6
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@
22
package testdata
33

44
import (
5+
"bytes"
6+
"go/token"
57
"io"
8+
"net/http"
9+
"os"
610
"unsafe"
711
)
812

@@ -24,6 +28,26 @@ func anonymousStructPtr() (*struct{ ID string }, error) {
2428
return nil, nil // want "return both the `nil` error and invalid value: use a sentinel error instead"
2529
}
2630

31+
func unsafePtr() (unsafe.Pointer, error) {
32+
return nil, nil // want "return both the `nil` error and invalid value: use a sentinel error instead"
33+
}
34+
35+
func uintPtr() (uintptr, error) {
36+
return 0, nil // want "return both the `nil` error and invalid value: use a sentinel error instead"
37+
}
38+
39+
func uintPtr0b() (uintptr, error) {
40+
return 0b0, nil // want "return both the `nil` error and invalid value: use a sentinel error instead"
41+
}
42+
43+
func uintPtr0x() (uintptr, error) {
44+
return 0x00, nil // want "return both the `nil` error and invalid value: use a sentinel error instead"
45+
}
46+
47+
func uintPtr0o() (uintptr, error) {
48+
return 0o000, nil // want "return both the `nil` error and invalid value: use a sentinel error instead"
49+
}
50+
2751
func chBi() (chan int, error) {
2852
return nil, nil // want "return both the `nil` error and invalid value: use a sentinel error instead"
2953
}
@@ -48,6 +72,10 @@ func iface() (interface{}, error) {
4872
return nil, nil // want "return both the `nil` error and invalid value: use a sentinel error instead"
4973
}
5074

75+
func anyType() (any, error) {
76+
return nil, nil // want "return both the `nil` error and invalid value: use a sentinel error instead"
77+
}
78+
5179
func m1() (map[int]int, error) {
5280
return nil, nil // want "return both the `nil` error and invalid value: use a sentinel error instead"
5381
}
@@ -56,6 +84,12 @@ func m2() (map[int]*User, error) {
5684
return nil, nil // want "return both the `nil` error and invalid value: use a sentinel error instead"
5785
}
5886

87+
type mapAlias = map[int]*User
88+
89+
func m3() (mapAlias, error) {
90+
return nil, nil // want "return both the `nil` error and invalid value: use a sentinel error instead"
91+
}
92+
5993
type Storage struct{}
6094

6195
func (s *Storage) GetUser() (*User, error) {
@@ -119,6 +153,39 @@ func deeplyNested() {
119153
}
120154
}
121155

156+
type MyError interface {
157+
error
158+
Code() string
159+
}
160+
161+
func myError() (*User, MyError) {
162+
return nil, nil // want "return both the `nil` error and invalid value: use a sentinel error instead"
163+
}
164+
165+
// Types.
166+
167+
func structPtrTypeExtPkg() (*os.File, error) {
168+
return nil, nil // want "return both the `nil` error and invalid value: use a sentinel error instead"
169+
}
170+
171+
func primitivePtrTypeExtPkg() (*token.Token, error) {
172+
return nil, nil // want "return both the `nil` error and invalid value: use a sentinel error instead"
173+
}
174+
175+
func funcTypeExtPkg() (http.HandlerFunc, error) {
176+
return nil, nil // want "return both the `nil` error and invalid value: use a sentinel error instead"
177+
}
178+
179+
func ifaceTypeExtPkg() (io.Closer, error) {
180+
return nil, nil // want "return both the `nil` error and invalid value: use a sentinel error instead"
181+
}
182+
183+
type closerAlias = io.Closer
184+
185+
func ifaceTypeAliasedExtPkg() (closerAlias, error) {
186+
return nil, nil // want "return both the `nil` error and invalid value: use a sentinel error instead"
187+
}
188+
122189
type (
123190
StructPtrType *User
124191
PrimitivePtrType *int
@@ -147,21 +214,93 @@ func ifaceType() (Checker, error) {
147214
return nil, nil // want "return both the `nil` error and invalid value: use a sentinel error instead"
148215
}
149216

217+
type checkerAlias = Checker
218+
219+
func ifaceTypeAliased() (checkerAlias, error) {
220+
return nil, nil // want "return both the `nil` error and invalid value: use a sentinel error instead"
221+
}
222+
223+
type (
224+
IntegerType int
225+
PtrIntegerType *IntegerType
226+
)
227+
228+
func ptrIntegerType() (PtrIntegerType, error) {
229+
return nil, nil // want "return both the `nil` error and invalid value: use a sentinel error instead"
230+
}
231+
232+
// Not checked at all.
233+
150234
func withoutArgs() {}
151235
func withoutError1() *User { return nil }
152236
func withoutError2() (*User, *User) { return nil, nil }
153237
func withoutError3() (*User, *User, *User) { return nil, nil, nil }
154238
func withoutError4() (*User, *User, *User, *User) { return nil, nil, nil, nil }
155239

156-
// Unsupported.
157-
158240
func invalidOrder() (error, *User) { return nil, nil }
159241
func withError3rd() (*User, bool, error) { return nil, false, nil }
160242
func withError4th() (*User, *User, *User, error) { return nil, nil, nil, nil }
161-
func unsafePtr() (unsafe.Pointer, error) { return nil, nil }
162-
func uintPtr() (uintptr, error) { return 0, nil }
163-
func slice() ([]int, error) { return nil, nil }
164-
func ifaceExtPkg() (io.Closer, error) { return nil, nil }
243+
244+
func slice() ([]int, error) { return nil, nil }
245+
246+
func strNil() (string, error) { return "nil", nil }
247+
func strEmpty() (string, error) { return "", nil }
248+
249+
// Valid.
250+
251+
func primitivePtrTypeValid() (*int, error) {
252+
if false {
253+
return nil, io.EOF
254+
}
255+
return new(int), nil
256+
}
257+
258+
func structPtrTypeValid() (*User, error) {
259+
if false {
260+
return nil, io.EOF
261+
}
262+
return new(User), nil
263+
}
264+
265+
func unsafePtrValid() (unsafe.Pointer, error) {
266+
if false {
267+
return nil, io.EOF
268+
}
269+
var i int
270+
return unsafe.Pointer(&i), nil
271+
}
272+
273+
func uintPtrValid() (uintptr, error) {
274+
if false {
275+
return 0, io.EOF
276+
}
277+
return 0xc82000c290, nil
278+
}
279+
280+
func channelTypeValid() (ChannelType, error) {
281+
if false {
282+
return nil, io.EOF
283+
}
284+
return make(ChannelType), nil
285+
}
286+
287+
func funcTypeValid() (FuncType, error) {
288+
if false {
289+
return nil, io.EOF
290+
}
291+
return func(i int) int {
292+
return 0
293+
}, nil
294+
}
295+
296+
func ifaceTypeValid() (io.Reader, error) {
297+
if false {
298+
return nil, io.EOF
299+
}
300+
return new(bytes.Buffer), nil
301+
}
302+
303+
// Unsupported.
165304

166305
func implicitNil1() (*User, error) {
167306
err := (error)(nil)

0 commit comments

Comments
 (0)