Remove Redundant Continue
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.
Sourcery refactoring id: remove-redundant-continue
Section titled “Sourcery refactoring id: remove-redundant-continue”Description:
Section titled “Description:”Remove redundant continue statement
Before:
Section titled “Before:”mylist2 = []for i in mylist: if i != 2: mylist2.append(i) else: continueAfter:
Section titled “After:”mylist2 = []for i in mylist: if i != 2: mylist2.append(i)Explanation:
Section titled “Explanation:”If a continue is not followed by any other statements in a for or while
loop then it is not necessary, so can be removed. Removing unnecessary lines
declutters the code and makes it easier to understand. This refactoring will
only be triggered if it unlocks further improvements.