You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The second errors.Wrap() is incorrect, because it's not wrapping any error (but it's easy to copy/paste it as such).
This is quite hard to spot in code reviews because lines that return errors will always have errors.Wrap() and it looks ok at first glance, until you notice that in this case is err is always nil. Because errors.Wrap(nil, "something") always returns nil this one returns success, which is unintended.
Based on flow analysis, it should be possible to determine that err == nil in this case, and it would be really amazing if the linter could flag this pattern is as misuse.
The text was updated successfully, but these errors were encountered:
G'day, I think both of these cases could be implemented neatly within this linter as it already has the definition checking there.
As far as timeline, I can't give anything concrete, however I will start looking into this next as I get some time. If you want it ASAP, I'm quite responsive to PR's.
I found several cases in my codebase (kopia/kopia#747) that follow the following buggy pattern:
The second
errors.Wrap()
is incorrect, because it's not wrapping any error (but it's easy to copy/paste it as such).This is quite hard to spot in code reviews because lines that return errors will always have
errors.Wrap()
and it looks ok at first glance, until you notice that in this case iserr
is alwaysnil
. Becauseerrors.Wrap(nil, "something")
always returnsnil
this one returns success, which is unintended.Based on flow analysis, it should be possible to determine that
err == nil
in this case, and it would be really amazing if the linter could flag this pattern is as misuse.The text was updated successfully, but these errors were encountered: