-
Notifications
You must be signed in to change notification settings - Fork 33
Description
When an interface is embedded, the reported interface name isn't what you need to ignore. Concretely, extend wrapcheck/testdata/config_ignoreInterfaceRegexps/main.go with the following, and run the test.
type embedder interface {
errorer
}
func embed(fn embedder) error {
var str string
return fn.Decode(&str) // errorer interface ignored as per `ignoreInterfaceRegexps`
}Unexpectedly, you'll see the following:
--- FAIL: TestAnalyzer (5.40s)
--- FAIL: TestAnalyzer/config_ignoreInterfaceRegexps (0.25s)
analysistest.go:452: /home/murman/src/wrapcheck/wrapcheck/testdata/config_ignoreInterfaceRegexps/main.go:33:9: unexpected diagnostic: error returned from interface method should be wrapped: sig: func (_/home/murman/src/wrapcheck/wrapcheck/testdata/config_ignoreInterfaceRegexps.errorer).Decode(v interface{}) error
Note that the ignores include errorer and the reported interface is config_ignoreInterfaceRegexps.errorer. However to suppress this you actually need to suppress embedder.
I believe this comes down to the difference between name and fnSig in reportUnwrapped, which come from sel.Sel and sel.X respectively, but the path forward is unclear to me.
wrapcheck/wrapcheck/wrapcheck.go
Lines 257 to 260 in 2133185
| name := types.TypeString(pass.TypesInfo.TypeOf(sel.X), func(p *types.Package) string { return p.Name() }) | |
| if containsMatch(regexpsInter, name) { | |
| } else { | |
| pass.Reportf(tokenPos, "error returned from interface method should be wrapped: sig: %s", fnSig) |