Skip to main content

Sonar: Removed break or continue statement out of loop

sonar:python/break-or-continue-out-of-loop-S1716​

ImportanceReview GuidanceRequires Scanning Tool
LowMerge After ReviewYes (Sonar)

This codemod acts upon the following Sonar rules: python:S1716.

Any break or continue statements that are not inside a for or while loop will result in a SyntaxError. This codemod will remove them.

Our changes look something like this:

def f():
print('not in a loop')
- break

If you have feedback on this codemod, please let us know!

F.A.Q.​

Why is this codemod marked as Merge After Review?​

While this change will make the code consistent, it is likely that the break or continue statement is a symptom of an error in program logic.

Codemod Settings​

N/A

References​