← All recipes
Moderne licensed

Remove if/else with identical branches

Recipe IDOpenRewrite.Recipes.CSharp.CodeQuality.Redundancy.AllBranchesIdenticalArtifactOpenRewrite.Recipes.CSharp.CodeQuality

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 recipecsharpredundancycode-qualityProprietary

Usage

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

mod run . --recipe OpenRewrite.Recipes.CSharp.CodeQuality.Redundancy.AllBranchesIdentical

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

mod config recipes nuget install OpenRewrite.Recipes.CSharp.CodeQuality