← All recipes
Moderne licensed

Substitute constant collection condition with boolean

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

When a list, tuple, dict, or set literal is used as an `if or while condition, replace it with True (non-empty) or False` (empty) to state the intent directly.

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

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

mod config recipes pip install openrewrite-static-analysis