← All recipes
Moderne licensed

Merge consecutive branches with identical bodies

Recipe IDorg.openrewrite.python.codequality.MergeIdenticalBranchesArtifactopenrewrite-migrate-python

Combine consecutive if/elif branches that have the same body into a single branch with conditions joined by or.

Single recipepythoncode-qualityRSPEC-S1871Proprietary

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.python.codequality.MergeIdenticalBranches

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

mod config recipes pip install openrewrite-migrate-python