revive icon indicating copy to clipboard operation
revive copied to clipboard

detect unnecessary gomock controller Finish call

Open hendrywiranto opened this issue 2 years ago • 4 comments
trafficstars

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

hendrywiranto avatar Nov 21 '23 16:11 hendrywiranto

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)

chavacava avatar Nov 26 '23 09:11 chavacava

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?

hendrywiranto avatar Nov 30 '23 04:11 hendrywiranto

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

chavacava avatar Nov 30 '23 13:11 chavacava

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!

hendrywiranto avatar Dec 02 '23 17:12 hendrywiranto