Skip to content

Commit 24bcca2

Browse files
build(deps): bump github.com/polyfloyd/go-errorlint from 1.4.8 to 1.5.1 (#4690)
Co-authored-by: Fernandez Ludovic <[email protected]>
1 parent 0260ec8 commit 24bcca2

File tree

6 files changed

+77
-8
lines changed

6 files changed

+77
-8
lines changed

.golangci.next.reference.yml

+10
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,16 @@ linters-settings:
326326
# Check for plain error comparisons.
327327
# Default: true
328328
comparison: false
329+
# Allowed errors.
330+
# Default: []
331+
allowed-errors:
332+
- err: "io.EOF"
333+
fun: "example.com/pkg.Read"
334+
# Allowed error "wildcards".
335+
# Default: []
336+
allowed-errors-wildcard:
337+
- err: "example.com/pkg.ErrMagic"
338+
fun: "example.com/pkg.Magic"
329339

330340
exhaustive:
331341
# Program elements to check for exhaustiveness.

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ require (
8484
github.com/nishanths/predeclared v0.2.2
8585
github.com/nunnatsa/ginkgolinter v0.16.2
8686
github.com/pelletier/go-toml/v2 v2.2.2
87-
github.com/polyfloyd/go-errorlint v1.4.8
87+
github.com/polyfloyd/go-errorlint v1.5.1
8888
github.com/quasilyte/go-ruleguard/dsl v0.3.22
8989
github.com/ryancurrah/gomodguard v1.3.2
9090
github.com/ryanrolds/sqlclosecheck v0.5.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.next.jsonschema.json

+30
Original file line numberDiff line numberDiff line change
@@ -803,6 +803,36 @@
803803
"description": "Check for plain error comparisons",
804804
"type": "boolean",
805805
"default": true
806+
},
807+
"allowed-errors": {
808+
"type": "array",
809+
"items": {
810+
"type": "object",
811+
"additionalProperties": false,
812+
"properties": {
813+
"err": {
814+
"type": "string"
815+
},
816+
"fun": {
817+
"type": "string"
818+
}
819+
}
820+
}
821+
},
822+
"allowed-errors-wildcard": {
823+
"type": "array",
824+
"items": {
825+
"type": "object",
826+
"additionalProperties": false,
827+
"properties": {
828+
"err": {
829+
"type": "string"
830+
},
831+
"fun": {
832+
"type": "string"
833+
}
834+
}
835+
}
806836
}
807837
}
808838
},

pkg/config/linters_settings.go

+11-4
Original file line numberDiff line numberDiff line change
@@ -384,10 +384,17 @@ type ErrChkJSONSettings struct {
384384
}
385385

386386
type ErrorLintSettings struct {
387-
Errorf bool `mapstructure:"errorf"`
388-
ErrorfMulti bool `mapstructure:"errorf-multi"`
389-
Asserts bool `mapstructure:"asserts"`
390-
Comparison bool `mapstructure:"comparison"`
387+
Errorf bool `mapstructure:"errorf"`
388+
ErrorfMulti bool `mapstructure:"errorf-multi"`
389+
Asserts bool `mapstructure:"asserts"`
390+
Comparison bool `mapstructure:"comparison"`
391+
AllowedErrors []ErrorLintAllowPair `mapstructure:"allowed-errors"`
392+
AllowedErrorsWildcard []ErrorLintAllowPair `mapstructure:"allowed-errors-wildcard"`
393+
}
394+
395+
type ErrorLintAllowPair struct {
396+
Err string `mapstructure:"err"`
397+
Fun string `mapstructure:"fun"`
391398
}
392399

393400
type ExhaustiveSettings struct {

pkg/golinters/errorlint/errorlint.go

+23-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,21 @@ import (
99
)
1010

1111
func New(cfg *config.ErrorLintSettings) *goanalysis.Linter {
12-
a := errorlint.NewAnalyzer()
12+
var opts []errorlint.Option
13+
14+
if cfg != nil {
15+
ae := toAllowPairs(cfg.AllowedErrors)
16+
if len(ae) > 0 {
17+
opts = append(opts, errorlint.WithAllowedErrors(ae))
18+
}
19+
20+
aew := toAllowPairs(cfg.AllowedErrorsWildcard)
21+
if len(aew) > 0 {
22+
opts = append(opts, errorlint.WithAllowedWildcard(aew))
23+
}
24+
}
25+
26+
a := errorlint.NewAnalyzer(opts...)
1327

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

@@ -30,3 +44,11 @@ func New(cfg *config.ErrorLintSettings) *goanalysis.Linter {
3044
cfgMap,
3145
).WithLoadMode(goanalysis.LoadModeTypesInfo)
3246
}
47+
48+
func toAllowPairs(data []config.ErrorLintAllowPair) []errorlint.AllowPair {
49+
var pairs []errorlint.AllowPair
50+
for _, allowedError := range data {
51+
pairs = append(pairs, errorlint.AllowPair(allowedError))
52+
}
53+
return pairs
54+
}

0 commit comments

Comments
 (0)