← All recipes
Moderne licensed

Remove duplicate conditions in if/elif chains

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

Remove elif branches whose condition is identical to an earlier branch in the same if/elif chain, since the duplicate branch is dead code that can never execute.

Single recipepythoncode-qualityRSPEC-S1862Proprietary

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.RemoveDuplicateConditions

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

mod config recipes pip install openrewrite-migrate-python