rspec/rules/S1716/python/rule.adoc

25 lines
611 B
Plaintext
Raw Normal View History

2021-04-28 16:49:39 +02:00
``++break++`` and ``++continue++`` are unstructured control flow statements which make code harder to read. Additionally, more recent versions of Python raise a SyntaxError when modules containing ``++break++`` or ``++continue++`` outside of a loop are imported.
Therefore, these statements should not be used outside of loops.
2021-04-28 16:49:39 +02:00
== Noncompliant Code Example
----
narg=len(sys.argv)
if narg == 1:
print('@Usage: input_filename nelements nintervals')
break
----
2021-04-28 16:49:39 +02:00
== Compliant Solution
----
if narg == 1:
print('@Usage: input_filename nelements nintervals')
sys.exit()
----