diff --git a/.golangci.next.reference.yml b/.golangci.next.reference.yml index f708e27716ad..9779fd04556d 100644 --- a/.golangci.next.reference.yml +++ b/.golangci.next.reference.yml @@ -3587,6 +3587,15 @@ linters-settings: multi-func: true wrapcheck: + # An array of strings specifying additional substrings of signatures to ignore. + # Unlike 'ignoreSigs', this option extends the default set (or the set specified in 'ignoreSigs') without replacing it entirely. + # This allows you to add specific signatures to the ignore list + # while retaining the defaults or any items in 'ignoreSigs'. + # Default: [] + extra-ignore-sigs: + - .CustomError( + - .SpecificWrap( + # An array of strings that specify substrings of signatures to ignore. # If this set, it will override the default set of ignored signatures. # See https://github.com/tomarrell/wrapcheck#configuration for more information. diff --git a/go.mod b/go.mod index 910f725baa5e..182bfe88b29e 100644 --- a/go.mod +++ b/go.mod @@ -111,7 +111,7 @@ require ( github.com/tetafro/godot v1.4.18 github.com/timakin/bodyclose v0.0.0-20230421092635-574207250966 github.com/timonwong/loggercheck v0.10.1 - github.com/tomarrell/wrapcheck/v2 v2.9.0 + github.com/tomarrell/wrapcheck/v2 v2.10.0 github.com/tommy-muehle/go-mnd/v2 v2.5.1 github.com/ultraware/funlen v0.1.0 github.com/ultraware/whitespace v0.1.1 diff --git a/go.sum b/go.sum index b820b947100c..5722f0023b68 100644 --- a/go.sum +++ b/go.sum @@ -553,8 +553,8 @@ github.com/tklauser/go-sysconf v0.3.12 h1:0QaGUFOdQaIVdPgfITYzaTegZvdCjmYO52cSFA github.com/tklauser/go-sysconf v0.3.12/go.mod h1:Ho14jnntGE1fpdOqQEEaiKRpvIavV0hSfmBq8nJbHYI= github.com/tklauser/numcpus v0.6.1 h1:ng9scYS7az0Bk4OZLvrNXNSAO2Pxr1XXRAPyjhIx+Fk= github.com/tklauser/numcpus v0.6.1/go.mod h1:1XfjsgE2zo8GVw7POkMbHENHzVg3GzmoZ9fESEdAacY= -github.com/tomarrell/wrapcheck/v2 v2.9.0 h1:801U2YCAjLhdN8zhZ/7tdjB3EnAoRlJHt/s+9hijLQ4= -github.com/tomarrell/wrapcheck/v2 v2.9.0/go.mod h1:g9vNIyhb5/9TQgumxQyOEqDHsmGYcGsVMOx/xGkqdMo= +github.com/tomarrell/wrapcheck/v2 v2.10.0 h1:SzRCryzy4IrAH7bVGG4cK40tNUhmVmMDuJujy4XwYDg= +github.com/tomarrell/wrapcheck/v2 v2.10.0/go.mod h1:g9vNIyhb5/9TQgumxQyOEqDHsmGYcGsVMOx/xGkqdMo= github.com/tommy-muehle/go-mnd/v2 v2.5.1 h1:NowYhSdyE/1zwK9QCLeRb6USWdoif80Ie+v+yU8u1Zw= github.com/tommy-muehle/go-mnd/v2 v2.5.1/go.mod h1:WsUAkMJMYww6l/ufffCD3m+P7LEvr8TnZn9lwVDlgzw= github.com/ultraware/funlen v0.1.0 h1:BuqclbkY6pO+cvxoq7OsktIXZpgBSkYTQtmwhAK81vI= diff --git a/jsonschema/golangci.next.jsonschema.json b/jsonschema/golangci.next.jsonschema.json index 4546614f20f9..50d694ec31cd 100644 --- a/jsonschema/golangci.next.jsonschema.json +++ b/jsonschema/golangci.next.jsonschema.json @@ -3417,6 +3417,17 @@ "type": "object", "additionalProperties": false, "properties": { + "extra-ignore-sigs": { + "description": "An array of strings specifying additional substrings of signatures to ignore.", + "default": [ + ".CustomError(", + ".SpecificWrap(" + ], + "type": "array", + "items": { + "type": "string" + } + }, "ignoreSigs": { "description": "An array of strings which specify substrings of signatures to ignore.", "default": [ diff --git a/pkg/config/linters_settings.go b/pkg/config/linters_settings.go index cd72c6b1b491..51ff661de4fe 100644 --- a/pkg/config/linters_settings.go +++ b/pkg/config/linters_settings.go @@ -984,6 +984,7 @@ type WhitespaceSettings struct { } type WrapcheckSettings struct { + ExtraIgnoreSigs []string `mapstructure:"extra-ignore-sigs"` // TODO(ldez): v2 the options must be renamed to use hyphen. IgnoreSigs []string `mapstructure:"ignoreSigs"` IgnoreSigRegexps []string `mapstructure:"ignoreSigRegexps"` diff --git a/pkg/golinters/wrapcheck/wrapcheck.go b/pkg/golinters/wrapcheck/wrapcheck.go index 96ec2eeae047..b2f5ec742098 100644 --- a/pkg/golinters/wrapcheck/wrapcheck.go +++ b/pkg/golinters/wrapcheck/wrapcheck.go @@ -11,6 +11,8 @@ import ( func New(settings *config.WrapcheckSettings) *goanalysis.Linter { cfg := wrapcheck.NewDefaultConfig() if settings != nil { + cfg.ExtraIgnoreSigs = settings.ExtraIgnoreSigs + if len(settings.IgnoreSigs) != 0 { cfg.IgnoreSigs = settings.IgnoreSigs }