← All recipes
Moderne licensed

Flatten for/else when the loop has no break

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

A for/else where the loop body never breaks is misleading -- the else runs every time. This moves the else body after the loop.

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

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

mod config recipes pip install openrewrite-static-analysis