← All recipes
Moderne licensed

Compare string to "" instead of checking len()

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

Replace `len(text) == 0 with text == "" and len(text) > 0 / len(text) != 0 with text != ""`, comparing the string directly rather than measuring its length.

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

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

mod config recipes pip install openrewrite-static-analysis