mgechev / revive

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

detect unnecessary gomock controller Finish call #940

Closed hendrywiranto closed 1 month ago

hendrywiranto commented 10 months ago

Is your feature request related to a problem? Please describe. As highlighted in https://pkg.go.dev/github.com/golang/mock/gomock#NewController:

New in go1.14+, if you are passing a *testing.T into this function you no longer need to call ctrl.Finish() in your test methods.

Describe the solution you'd like A linting rule that can flag when we're unnecessarily calling .Finish to gomock controller, when using a Go version of 1.14+.

Describe alternatives you've considered Submit a new linter to golangci-lint but it seems like 1 linter for this functionality only is overkill

Additional context Hello, does this linter support checking of a library usage too? If yes, I would like to open a PR for this

chavacava commented 10 months ago

Hi @hendrywiranto, thanks for the proposal.

IMO the use case addressed by the proposed rule is quite niche. I'm not convinced it fits in the revive's intent of being general. I propose to keep this issue open and let users decide if the rule should be added. Menawhile, if you need this rule for your day-to-day work, you can implement it and use revive as a library (https://github.com/mgechev/revive#using-revive-as-a-library)

hendrywiranto commented 10 months ago

Hi @chavacava Thanks for the reply! Understandable 👍 Thanks for the suggestion too, I will look into that Should we close this issue or keep it open?

chavacava commented 10 months ago

I propose to keep the issue open and see if some other users manifest interest in the rule you propose. Thanks again!

hendrywiranto commented 10 months ago

I propose to keep the issue open and see if some other users manifest interest in the rule you propose. Thanks again!

I see no worries, thanks for responding!