Skip to content

Commit

Permalink
build(deps): bump github.com/Antonboom/nilnil from 0.1.9 to 1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Antonboom authored and ldez committed Oct 6, 2024
1 parent 9f4951f commit 170b25d
Show file tree
Hide file tree
Showing 11 changed files with 252 additions and 55 deletions.
9 changes: 6 additions & 3 deletions .golangci.next.reference.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2115,14 +2115,17 @@ linters-settings:
min-complexity: 4

nilnil:
# In addition, detect opposite situation (simultaneous return of non-nil error and valid value).
# Default: false
detect-opposite: true
# List of return types to check.
# Default: ["ptr", "func", "iface", "map", "chan", "uintptr", "unsafeptr"]
# Default: ["chan", "func", "iface", "map", "ptr", "uintptr", "unsafeptr"]
checked-types:
- ptr
- chan
- func
- iface
- map
- chan
- ptr
- uintptr
- unsafeptr

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.1.1
github.com/Antonboom/errname v1.0.0
github.com/Antonboom/nilnil v0.1.9
github.com/Antonboom/nilnil v1.0.0
github.com/Antonboom/testifylint v1.5.0
github.com/BurntSushi/toml v1.4.1-0.20240526193622-a339e1f7089c
github.com/Crocmagnon/fatcontext v0.5.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.

9 changes: 7 additions & 2 deletions jsonschema/golangci.next.jsonschema.json
Original file line number Diff line number Diff line change
Expand Up @@ -2188,13 +2188,18 @@
"type": "object",
"additionalProperties": false,
"properties": {
"detect-opposite": {
"type": "boolean",
"description": "In addition, detect opposite situation (simultaneous return of non-nil error and valid value).",
"default": false
},
"checked-types": {
"type": "array",
"description": "List of return types to check.",
"items": {
"enum": ["ptr", "func", "iface", "map", "chan", "uintptr", "unsafeptr"]
"enum": ["chan", "func", "iface", "map", "ptr", "uintptr", "unsafeptr"]
},
"default": ["ptr", "func", "iface", "map", "chan", "uintptr", "unsafeptr"]
"default": ["chan", "func", "iface", "map", "ptr", "uintptr", "unsafeptr"]
}
}
},
Expand Down
3 changes: 2 additions & 1 deletion pkg/config/linters_settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -733,7 +733,8 @@ type NestifSettings struct {
}

type NilNilSettings struct {
CheckedTypes []string `mapstructure:"checked-types"`
DetectOpposite bool `mapstructure:"detect-opposite"`
CheckedTypes []string `mapstructure:"checked-types"`
}

type NlreturnSettings struct {
Expand Down
11 changes: 6 additions & 5 deletions pkg/golinters/nilnil/nilnil.go
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
package nilnil

import (
"strings"

"github.com/Antonboom/nilnil/pkg/analyzer"
"golang.org/x/tools/go/analysis"

"github.com/golangci/golangci-lint/pkg/config"
"github.com/golangci/golangci-lint/pkg/goanalysis"
)

func New(cfg *config.NilNilSettings) *goanalysis.Linter {
func New(settings *config.NilNilSettings) *goanalysis.Linter {
a := analyzer.New()

cfgMap := make(map[string]map[string]any)
if cfg != nil && len(cfg.CheckedTypes) != 0 {
if settings != nil {
cfgMap[a.Name] = map[string]any{
"checked-types": strings.Join(cfg.CheckedTypes, ","),
"detect-opposite": settings.DetectOpposite,
}
if len(settings.CheckedTypes) != 0 {
cfgMap[a.Name]["checked-types"] = settings.CheckedTypes
}
}

Expand Down
Loading

0 comments on commit 170b25d

Please sign in to comment.