← All recipes
Moderne licensed

Replace .find() check with in / not in

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

Rewrite `.find() return-value checks as membership tests: text.find(sub) == -1 becomes sub not in text and text.find(sub) != -1 becomes sub in text`.

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

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

mod config recipes pip install openrewrite-static-analysis