tomarrell / wrapcheck

A Go linter to check that errors from external packages are wrapped
https://blog.tomarrell.com/post/introducing_wrapcheck_linter_for_go
MIT License
291 stars 26 forks source link

Support for errors.Wrap(f) #9

Closed joy4eg closed 3 years ago

joy4eg commented 3 years ago

Hello,

In our project we use golangci-lint and have a lot of similar code:

func foo() (object, error)
  err := doSomething()
  if err != nil {
    return nil, errors.Wrapf(err, "action failed for %v", anyAdditionalInfo)
  }
}

Starting from version golangci-lint 1.39.0 built from 9aea4aee on 2021-03-26T08:02:53Z all those lines cannot pass wrapcheck:

foo/bar:42:16: error returned from external package is unwrapped (wrapcheck)
                         return nil, errors.Wrapf(err, "action failed for %v", anyAdditionalInfo)

Is that a false positive error ? Or am I missing something ?

Thanks.

tomarrell commented 3 years ago

Hey, thanks a lot. Yes this is due to this package not being considered by the set of exceptions. I'm currently working on adding pkg/errors and allowing for customisable exceptions so that you can add your own.

I'll mark this as a duplicate of #8 so that you can follow along with progress there.

Cheers!

peczenyj commented 3 years ago

Hey, did you re-tag this development as v1.0.0 ?

I can see some weird outputs when running golangci-lint v1.39.0 and it should use v1.0.0 but it generates different outputs... in fact I am having trouble with errors.Wrapf false alarms...

Is it possible release, perhaps, a 1.0.1 ?

tomarrell commented 3 years ago

G'day @peczenyj, yes it was retagged in order to hopefully resolve the warnings for those using github.com/pkg/errors as a stopgap. Would you be able to paste the errors your seeing in the output?

I'd be happy to release a v1.0.1, but I'm not sure it'd be picked up until the next release of golangci-lint. Could you also try reinstalling golangci-lint from scratch and let me know if that solves your issues?

joy4eg commented 3 years ago

@tomarrell The thing is, that releases of golangci-lint still holds the old v1.0.0 here - https://github.com/golangci/golangci-lint/releases/tag/v1.39.0 And a lot of systems (like github actions) still have that old-new version :)

peczenyj commented 3 years ago

Em ter., 30/03/2021 às 18:41, Tom Arrell @.***> escreveu:

G'day @peczenyj https://github.com/peczenyj, yes it was retagged in order to hopefully resolve the warnings for those using github.com/pkg/errors as a stopgap. Would you be able to paste the errors your seeing in the output?

The linter warns about errors.Wrapf as the golangci-liny holds the old v1.0.0

I can ignore such warnings until everything is fixed

I'd be happy to release a v1.0.1, but I'm not sure it'd be picked up until the next release of golangci-lint. Could you also try reinstalling golangci-lint from scratch and let me know if that solves your issues?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/tomarrell/wrapcheck/issues/9#issuecomment-810411551, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAOQLRGP2GJBRS6DV32LY3TGH5KNANCNFSM42AAZY6Q .

-- Tiago B. Peczenyj

http://about.me/peczenyj