File tree 4 files changed +47
-1
lines changed
4 files changed +47
-1
lines changed Original file line number Diff line number Diff line change @@ -40,6 +40,16 @@ ignoreSigs:
40
40
- .WithMessagef(
41
41
- .WithStack(
42
42
43
+
44
+ # An array of strings specifying additional substrings of signatures to ignore.
45
+ # Unlike ignoreSigs, this option extends the default set (or the set specified
46
+ # in ignoreSigs) without replacing it entirely. This allows you to add specific
47
+ # signatures to the ignore list while retaining the defaults or any items in
48
+ # ignoreSigs.
49
+ extraIgnoreSigs :
50
+ - .CustomError(
51
+ - .SpecificWrap(
52
+
43
53
# An array of strings which specify regular expressions of signatures to ignore.
44
54
# This is similar to the ignoreSigs configuration above, but gives slightly more
45
55
# flexibility.
Original file line number Diff line number Diff line change
1
+ extraIgnoreSigs :
2
+ - json.Marshal(
3
+
4
+ ignoreSigs :
5
+ - errors.New(
Original file line number Diff line number Diff line change
1
+ package main
2
+
3
+ import (
4
+ "encoding/json"
5
+ "errors"
6
+ )
7
+
8
+ func main () {
9
+ do ()
10
+ }
11
+
12
+ func do () error {
13
+ // no issue with function in 'extraIgnoreSigs'
14
+ _ , err := json .Marshal (struct {}{})
15
+ if err != nil {
16
+ return err
17
+ }
18
+
19
+ // expect issue for function that is not ignored
20
+ res := struct {}{}
21
+ if err := json .Unmarshal ([]byte ("{}" ), & res ); err != nil {
22
+ return err // want `error returned from external package is unwrapped`
23
+ }
24
+
25
+ // no issue with function in 'ignoreSigs'
26
+ return errors .New ("Some error" )
27
+ }
Original file line number Diff line number Diff line change @@ -44,6 +44,10 @@ type WrapcheckConfig struct {
44
44
// list to your config.
45
45
IgnoreSigs []string `mapstructure:"ignoreSigs" yaml:"ignoreSigs"`
46
46
47
+ // ExtraIgnoreSigs defines an additional list of signatures to ignore, on
48
+ // top of IgnoreSigs.
49
+ ExtraIgnoreSigs []string `mapstructure:"extraIgnoreSigs" yaml:"extraIgnoreSigs"`
50
+
47
51
// IgnoreSigRegexps defines a list of regular expressions which if matched
48
52
// to the signature of the function call returning the error, will be ignored. This
49
53
// allows you to specify functions that wrapcheck will not report as
@@ -276,7 +280,7 @@ func reportUnwrapped(
276
280
277
281
// Check for ignored signatures
278
282
fnSig := pass .TypesInfo .ObjectOf (sel .Sel ).String ()
279
- if contains (cfg .IgnoreSigs , fnSig ) {
283
+ if contains (cfg .IgnoreSigs , fnSig ) || contains ( cfg . ExtraIgnoreSigs , fnSig ) {
280
284
return
281
285
} else if containsMatch (regexpsSig , fnSig ) {
282
286
return
You can’t perform that action at this time.
0 commit comments