Skip to content

Commit ddccb04

Browse files
Antonboomldez
andauthored
build(deps): bump github.com/Antonboom/nilnil from 1.0.1 to 1.1.0 (#5560)
Co-authored-by: Fernandez Ludovic <[email protected]>
1 parent 758666c commit ddccb04

9 files changed

+43
-4
lines changed

.golangci.next.reference.yml

+5
Original file line numberDiff line numberDiff line change
@@ -1964,7 +1964,12 @@ linters:
19641964
min-complexity: 4
19651965

19661966
nilnil:
1967+
# To check functions with only two return values (`return nil, nil`).
1968+
# If disabled then returns like `return nil, nil, ..., nil` are supported.
1969+
# Default: true
1970+
only-two: false
19671971
# In addition, detect opposite situation (simultaneous return of non-nil error and valid value).
1972+
# E.g, `return clone, fh.indexer.Update(clone)` will be considered as invalid.
19681973
# Default: false
19691974
detect-opposite: true
19701975
# List of return types to check.

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ require (
88
github.com/4meepo/tagalign v1.4.2
99
github.com/Abirdcfly/dupword v0.1.3
1010
github.com/Antonboom/errname v1.1.0
11-
github.com/Antonboom/nilnil v1.0.1
11+
github.com/Antonboom/nilnil v1.1.0
1212
github.com/Antonboom/testifylint v1.6.0
1313
github.com/BurntSushi/toml v1.4.1-0.20240526193622-a339e1f7089c
1414
github.com/Crocmagnon/fatcontext v0.7.1

go.sum

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

jsonschema/golangci.jsonschema.json

+5
Original file line numberDiff line numberDiff line change
@@ -2510,6 +2510,11 @@
25102510
"type": "object",
25112511
"additionalProperties": false,
25122512
"properties": {
2513+
"only-two": {
2514+
"type": "boolean",
2515+
"description": "To check functions with only two return values.",
2516+
"default": true
2517+
},
25132518
"detect-opposite": {
25142519
"type": "boolean",
25152520
"description": "In addition, detect opposite situation (simultaneous return of non-nil error and valid value).",

jsonschema/golangci.next.jsonschema.json

+5
Original file line numberDiff line numberDiff line change
@@ -2510,6 +2510,11 @@
25102510
"type": "object",
25112511
"additionalProperties": false,
25122512
"properties": {
2513+
"only-two": {
2514+
"type": "boolean",
2515+
"description": "To check functions with only two return values.",
2516+
"default": true
2517+
},
25132518
"detect-opposite": {
25142519
"type": "boolean",
25152520
"description": "In addition, detect opposite situation (simultaneous return of non-nil error and valid value).",

pkg/config/linters_settings.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -664,6 +664,7 @@ type NestifSettings struct {
664664
}
665665

666666
type NilNilSettings struct {
667+
OnlyTwo *bool `mapstructure:"only-two"`
667668
DetectOpposite bool `mapstructure:"detect-opposite"`
668669
CheckedTypes []string `mapstructure:"checked-types"`
669670
}
@@ -849,7 +850,6 @@ type TestifylintSettings struct {
849850
Formatter TestifylintFormatter `mapstructure:"formatter"`
850851
GoRequire TestifylintGoRequire `mapstructure:"go-require"`
851852
RequireError TestifylintRequireError `mapstructure:"require-error"`
852-
RequireStringMsg bool `mapstructure:"require-string-msg"`
853853
SuiteExtraAssertCall TestifylintSuiteExtraAssertCall `mapstructure:"suite-extra-assert-call"`
854854
}
855855

pkg/golinters/nilnil/nilnil.go

+3
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ func New(settings *config.NilNilSettings) *goanalysis.Linter {
1616
cfg[a.Name] = map[string]any{
1717
"detect-opposite": settings.DetectOpposite,
1818
}
19+
if b := settings.OnlyTwo; b != nil {
20+
cfg[a.Name]["only-two"] = *b
21+
}
1922
if len(settings.CheckedTypes) != 0 {
2023
cfg[a.Name]["checked-types"] = settings.CheckedTypes
2124
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
//golangcitest:args -Enilnil
2+
//golangcitest:config_path testdata/nilnil_multiple_nils.yml
3+
package testdata
4+
5+
func withoutArgs() {}
6+
func withoutError1() *User { return nil }
7+
func withoutError2() (*User, *User) { return nil, nil }
8+
func withoutError3() (*User, *User, *User) { return nil, nil, nil }
9+
func withoutError4() (*User, *User, *User, *User) { return nil, nil, nil, nil }
10+
11+
func invalidOrder() (error, *User) { return nil, nil }
12+
func withError3rd() (*User, bool, error) { return nil, false, nil } // want "return both a `nil` error and an invalid value: use a sentinel error instead"
13+
func withError4th() (*User, *User, *User, error) { return nil, nil, nil, nil } // want "return both a `nil` error and an invalid value: use a sentinel error instead"
14+
15+
type User struct{}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
version: "2"
2+
3+
linters:
4+
settings:
5+
nilnil:
6+
only-two: false

0 commit comments

Comments
 (0)