Skip to content

build(deps): bump github.com/polyfloyd/go-errorlint from 1.4.8 to 1.5.1 #4690

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
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
10 changes: 10 additions & 0 deletions .golangci.next.reference.yml
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,16 @@ linters-settings:
# Check for plain error comparisons.
# Default: true
comparison: false
# Allowed errors.
# Default: []
allowed-errors:
- err: "io.EOF"
fun: "example.com/pkg.Read"
# Allowed error "wildcards".
# Default: []
allowed-errors-wildcard:
- err: "example.com/pkg.ErrMagic"
fun: "example.com/pkg.Magic"

exhaustive:
# Program elements to check for exhaustiveness.
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ require (
github.com/nishanths/predeclared v0.2.2
github.com/nunnatsa/ginkgolinter v0.16.2
github.com/pelletier/go-toml/v2 v2.2.2
github.com/polyfloyd/go-errorlint v1.4.8
github.com/polyfloyd/go-errorlint v1.5.1
github.com/quasilyte/go-ruleguard/dsl v0.3.22
github.com/ryancurrah/gomodguard v1.3.2
github.com/ryanrolds/sqlclosecheck v0.5.1
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.

30 changes: 30 additions & 0 deletions jsonschema/golangci.next.jsonschema.json
Original file line number Diff line number Diff line change
Expand Up @@ -803,6 +803,36 @@
"description": "Check for plain error comparisons",
"type": "boolean",
"default": true
},
"allowed-errors": {
"type": "array",
"items": {
"type": "object",
"additionalProperties": false,
"properties": {
"err": {
"type": "string"
},
"fun": {
"type": "string"
}
}
}
},
"allowed-errors-wildcard": {
"type": "array",
"items": {
"type": "object",
"additionalProperties": false,
"properties": {
"err": {
"type": "string"
},
"fun": {
"type": "string"
}
}
}
}
}
},
Expand Down
15 changes: 11 additions & 4 deletions pkg/config/linters_settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -384,10 +384,17 @@ type ErrChkJSONSettings struct {
}

type ErrorLintSettings struct {
Errorf bool `mapstructure:"errorf"`
ErrorfMulti bool `mapstructure:"errorf-multi"`
Asserts bool `mapstructure:"asserts"`
Comparison bool `mapstructure:"comparison"`
Errorf bool `mapstructure:"errorf"`
ErrorfMulti bool `mapstructure:"errorf-multi"`
Asserts bool `mapstructure:"asserts"`
Comparison bool `mapstructure:"comparison"`
AllowedErrors []ErrorLintAllowPair `mapstructure:"allowed-errors"`
AllowedErrorsWildcard []ErrorLintAllowPair `mapstructure:"allowed-errors-wildcard"`
}

type ErrorLintAllowPair struct {
Err string `mapstructure:"err"`
Fun string `mapstructure:"fun"`
}

type ExhaustiveSettings struct {
Expand Down
24 changes: 23 additions & 1 deletion pkg/golinters/errorlint/errorlint.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,21 @@ import (
)

func New(cfg *config.ErrorLintSettings) *goanalysis.Linter {
a := errorlint.NewAnalyzer()
var opts []errorlint.Option

if cfg != nil {
ae := toAllowPairs(cfg.AllowedErrors)
if len(ae) > 0 {
opts = append(opts, errorlint.WithAllowedErrors(ae))
}

aew := toAllowPairs(cfg.AllowedErrorsWildcard)
if len(aew) > 0 {
opts = append(opts, errorlint.WithAllowedWildcard(aew))
}
}

a := errorlint.NewAnalyzer(opts...)

cfgMap := map[string]map[string]any{}

Expand All @@ -30,3 +44,11 @@ func New(cfg *config.ErrorLintSettings) *goanalysis.Linter {
cfgMap,
).WithLoadMode(goanalysis.LoadModeTypesInfo)
}

func toAllowPairs(data []config.ErrorLintAllowPair) []errorlint.AllowPair {
var pairs []errorlint.AllowPair
for _, allowedError := range data {
pairs = append(pairs, errorlint.AllowPair(allowedError))
}
return pairs
}
Loading