← All recipes
Moderne licensed

Flip empty `if`-body by negating the condition

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

When the `if branch is just pass and an else` exists, invert the test and promote the else body to the if body.

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

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

mod config recipes pip install openrewrite-static-analysis