← All recipes
Moderne licensed

Replace self-referencing ternary with or

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

When a ternary's condition and true-branch name the same variable, rewrite `val if val else fallback as val or fallback` to avoid repeating the name.

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

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

mod config recipes pip install openrewrite-static-analysis