2023-05-03 11:06:20 +02:00
== Why is this an issue?
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 18:08:03 +02:00
2023-05-03 11:06:20 +02:00
=== Noncompliant code example
2021-04-28 16:49:39 +02:00
2022-02-04 17:28:24 +01:00
[source,python]
2021-04-28 16:49:39 +02:00
----
narg=len(sys.argv)
if narg == 1:
print('@Usage: input_filename nelements nintervals')
break
----
2021-04-28 18:08:03 +02:00
2023-05-03 11:06:20 +02:00
=== Compliant solution
2021-04-28 16:49:39 +02:00
2022-02-04 17:28:24 +01:00
[source,python]
2021-04-28 16:49:39 +02:00
----
if narg == 1:
print('@Usage: input_filename nelements nintervals')
sys.exit()
----
2021-04-28 18:08:03 +02:00
2021-06-02 20:44:38 +02:00
2021-06-03 09:05:38 +02:00
ifdef::env-github,rspecator-view[]
2021-09-20 15:38:42 +02:00
'''
== Implementation Specification
(visible only on this page)
2023-05-25 14:18:12 +02:00
=== Message
Remove this "xxx" statement
2021-09-20 15:38:42 +02:00
2021-06-08 15:52:13 +02:00
'''
2021-06-02 20:44:38 +02:00
== Comments And Links
(visible only on this page)
2023-05-25 14:18:12 +02:00
=== is related to: S910
=== on 4 Nov 2014, 15:59:14 Ann Campbell wrote:
pylint:E0103
=== on 9 May 2016, 15:41:47 Evgeny Mandrikov wrote:
I don't know any C/{cpp} compiler, which will allow to use "continue" outside of loop and "break" outside of switch and loop, hence not applicable.
=== on 9 May 2016, 15:44:26 Evgeny Mandrikov wrote:
Note that PC-Lint error codes from 1 to 199 for C and from 1001 to 1199 for {cpp} are syntax errors.
=== on 16 May 2016, 17:06:00 Ann Campbell wrote:
\[~evgeny.mandrikov] I guess this means that PC-Lint doesn't expect compilable code?
=== on 16 May 2016, 17:14:19 Evgeny Mandrikov wrote:
\[~ann.campbell.2] I suppose that it expects for proper analysis in general, but when this is not the case it generates more precise "parse error".
=== on 16 May 2016, 17:50:32 Ann Campbell wrote:
For the record PC-Lint rules in these ranges are Syntax errors: 1-199, 1001-1199.
2021-06-03 09:05:38 +02:00
endif::env-github,rspecator-view[]