-
Notifications
You must be signed in to change notification settings - Fork 284
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
Allow to ignoring "unhandled errors" by their type and method #671
Comments
I know that this might be a breaking change, because "fmt.Print" could also mean variable "fmt" and function "Print" instead of import identifier "fmt". |
Currently, revive supported the ignore list but it used AST subtree to match var b1 strings.Builder
b1.WriteString This will be trivial when the variable names were different, so I'm wondering
|
@chavacava How do you think about the above solution? |
Trying to handle all cases by matching strings will necessarily be an incomplete and uncomfortable solution. For example, using string matching to ignore the following call var b1 strings.Builder
b1.WriteString will require to add var b1 strings.Builder
var b2 strings.Builder
b1.WriteString
b2.WriteString we need to add The root of the problem is lack of type information. We need to know the actual full canonical method name of |
Yes, I didn't explain it clearly, we are on the same page. |
I think this issue seems to be resolved by #757. |
Is your feature request related to a problem? Please describe.
When one is using the method "WriteString" of the type "strings::Builder" and does not handle the error it is flagged because all errors must be handled. However, This method never returns an error. Hence, it makes sense to ignore it (even by default).
The problem with revive is, that it does not allow to ignore methods with their type, since one can only ignore them with their variable name. So instead of "strings.Builder.WriteString" (or another annoation) to ignore it, i need to write "b.WriteString" (in our code this is one instance) which however, would include implementations that do return an error.
Describe the solution you'd like
Allow to define "strings.Builder.WriteString" (or "strings::Builder.WriteString") to allow to ignore the method "WriteString" of the type "Builder" in the package "strings".
The text was updated successfully, but these errors were encountered: