← All recipes
Moderne licensed

Drop `else after early-exit if` branch

Recipe IDorg.openrewrite.python.cleanup.RemoveUnnecessaryElseArtifactopenrewrite-static-analysis

When the `if body always exits via return, raise, continue, or break, remove the else` and dedent its contents.

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.python.cleanup.RemoveUnnecessaryElse

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

mod config recipes pip install openrewrite-static-analysis