mgechev / revive

🔥 ~6x faster, stricter, configurable, extensible, and beautiful drop-in replacement for golint
https://revive.run
MIT License
4.69k stars 269 forks source link

`unhandled-error`: error message function name does not match name used for exclusions #961

Closed mmcloughlin closed 6 months ago

mmcloughlin commented 6 months ago

Problem

The problem I have just encountered was attempting to encode an exclusion for the following lint error:

internal/api/function.go:76:2: unhandled-error: Unhandled error in call to function w.Flush (revive)
    w.Flush()

It is not clear from the error message that the function name used when processing ignored regular expressions from the configuration is in fact text/tabwriter.Writer.Flush not w.Flush. I did eventually figure out the right function name but I previously guessed wrong that it might be tabwriter.Writer.Flush or Writer.Flush. I think this error message could be friendlier to users.

Proposed Solution

I suggest that the function name in the error message should match the one used for exclusions. In particular, in this case the error message should be:

internal/api/function.go:76:2: unhandled-error: Unhandled error in call to function text/tabwriter.Writer.Flush (revive)
    w.Flush()