← All recipes
Moderne licensed

Collapse nested `if into a single and` condition

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

When two `if statements are nested with no else on either, join their conditions with and` and flatten the 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.MergeNestedIfs

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

mod config recipes pip install openrewrite-static-analysis