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
302 stars 27 forks source link

Support Gorm-style error checking #32

Open cdignam-segment opened 2 years ago

cdignam-segment commented 2 years ago

Gorm uses non-standard error format to support it's chainable API. It would be nice if there was a way to configure wrapcheck to match a *.\.Error regex

tx := tx.Find(&customer)
if tx.Error != nil {
    return nil, tx.Error // wrapcheck should warn here
}

abc := tx.Find(&customer)
if abc.Error != nil {
    return nil, abc.Error // wrapcheck should warn here
}
tomarrell commented 2 years ago

That should be possible, will just need a bit of a tweak to the AST matcher. I'll take a look when I get some time. If you want it sooner, I'm happy to review a PR.

davideme commented 4 months ago

@tomarrell any update on this? I would love to have support for Gorm

tomarrell commented 4 months ago

@davideme Hey, sorry, I've not got a large amount of time outside my day-job in order to tackle this. I would be able to review a PR, or give some guidance if you wanted to give it a shot.