Skip to content

Swap Nested Ifs

Documentation Index

Fetch the complete documentation index at: https://docs.sourcery.ai/llms.txt

Use this file to discover all available pages before exploring further.

Swaps the order of nested if statements

if a:
if b:
return c
if b:
if a:
return c

This refactoring identity will not improve code quality on its own, but can be part of a series of steps that will improve quality. Sourcery will only suggest this refactoring where it unlocks further improvements.