← All recipes
Moderne licensed

Remove redundant defer ctrl.Finish()

Recipe IDorg.openrewrite.golang.migration.RemoveRedundantGomockFinishArtifactgithub.com/moderneinc/recipes-go

Remove defer ctrl.Finish() where the controller was built by gomock.NewController from a *testing.T, *testing.B, *testing.F or testing.TB. NewController registers the finish through Cleanup for any such reporter, so the deferred call only repeats it.

Single recipeProprietary

Usage

This recipe has no required configuration options. You’ll need the Moderne CLI configured before running the command below.

mod run . --recipe org.openrewrite.golang.migration.RemoveRedundantGomockFinish

If the recipe isn’t available locally, install it with:

mod config recipes go install github.com/moderneinc/recipes-go