← All recipes
Moderne licensed

Remove if/else with identical branches

Recipe IDorg.openrewrite.golang.codequality.AllBranchesIdenticalArtifactgithub.com/moderneinc/recipes-go

Replace an if/else chain where every branch has the same body with just the body, since the conditions have no effect on the outcome.

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.codequality.AllBranchesIdentical

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

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