Code quality
Recipe ID
org.openrewrite.python.codequality.CodeQualityArtifactopenrewrite-migrate-pythonApply all Python code quality recipes that change code: simplify boolean expressions, merge and collapse if chains, and remove dead conditions and writes. Search-only recipes, which mark code for review, are not included.
Composite recipepythoncode-qualityProprietary
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.codequality.CodeQualityIf the recipe isn’t available locally, install it with:
mod config recipes pip install openrewrite-migrate-python
mod config recipes jar install org.openrewrite.recipe:rewrite-migrate-python:RELEASE
mod config recipes jar install org.openrewrite:rewrite-python:RELEASEDefinition
This recipe runs the following recipes in order.
- Simplify boolean literal comparisons
org.openrewrite.python.codequality.SimplifyBooleanLiteral - Boolean checks should not be inverted
org.openrewrite.python.codequality.BooleanChecksNotInverted - Simplify redundant logical expressions
org.openrewrite.python.codequality.SimplifyRedundantLogicalExpression - Remove duplicate conditions in if/elif chains
org.openrewrite.python.codequality.RemoveDuplicateConditions - Remove conditional with identical branches
org.openrewrite.python.codequality.AllBranchesIdentical - Merge consecutive branches with identical bodies
org.openrewrite.python.codequality.MergeIdenticalBranches - Merge collapsible if statements
org.openrewrite.python.codequality.CollapsibleIfStatements - Remove self-assignments
org.openrewrite.python.codequality.RemoveSelfAssignment - Remove unconditional value overwrites
org.openrewrite.python.codequality.RemoveUnconditionalValueOverwrite