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

Expand `unused-parameter` to check anonymous functions #965

Closed StephenButtolph closed 5 months ago

StephenButtolph commented 5 months ago

Is your feature request related to a problem? Please describe.

The unused-parameter is phenomenally useful, however it doesn't seem to include anonymous functions. Had this linter included anonymous functions, we would have been able to catch a bug before it made its way into a recent release of ours.

Describe the solution you'd like

Anonymous functions should be tracked just like normal functions for unused variable usages.

In this example, a is unused. There could be a suggestion to use func(int) (or func(_ int) rather than func(a int).

Describe alternatives you've considered

Depending on how unused-parameter is implemented, it might make sense to have this be a separate rule entirely, like unused-receiver.

Additional context

Here is a bug fix that would have been prevented had this linter existed.

StephenButtolph commented 5 months ago

I'm working on a PR to add this to the unused-parameter rule.