-
Notifications
You must be signed in to change notification settings - Fork 265
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
rule.unhandled-error
does not work for nested methods
#350
Comments
Hi @jBugman, thanks for reporting this issue. I will work on it this week. |
Hi @jBugman, I've tryed to reproduce the bug with import (
"fmt"
)
type r struct {
s s
}
type s struct{}
func (s *s) returnsError() error {
return fmt.Errorf("handle it!")
}
func unhandledError3() {
myS := &s{}
myS.returnsError()
myR := &r{myS}
myR.s.returnsError()
} But
|
Hi, @chavacava as it turns out that example works for me also. But I modified it to something more realistic and it doesn't anymore. Looks like imported structures break something. main.go package main
import (
"./pkg"
)
type r struct {
s pkg.S
}
func main() {
myS := &pkg.S{}
myS.ReturnsError()
myR := &r{*myS}
myR.s.ReturnsError()
} pkg/pkg.go package pkg
import "fmt"
type S struct{}
func (s *S) ReturnsError() error {
return fmt.Errorf("handle it!")
}
|
It seems that the problem is not related to imported structures, import (
"net/http"
)
func foo() {
(&http.Request{}).MultipartForm.RemoveAll()
} |
The rule needs type information to identify functions returning values of type error, that is why at the beginning of the rule execution over a file, it performs type-checking on the package. package main
import (
"gopkg.in/src-d/go-git.v4"
)
func main() {
r := &git.Remote{}
r.Push(nil)
} I get the following error when type-checking:
Even if the code successfully compiles with |
Describe the bug
Consider some abstract function/method
ReturnsError() error
There are three general cases how it could be called
ReturnsError()
— catches okstruct.ReturnsError()
— catches okstruct.field.ReturnsError()
— ignored by reviveTo Reproduce
This is with revive v1.0.1
Expected behavior
Rule should work for all described cases.
The text was updated successfully, but these errors were encountered: