38 lines
856 B
Plaintext
Raw Normal View History

== Why is this an issue?
2021-01-27 13:42:22 +01:00
A ``++for++`` loop with a stop condition that can never be reached, such as one with a counter that moves in the wrong direction, will run infinitely. While there are occasions when an infinite loop is intended, the convention is to construct such loops as ``++while++`` loops. More typically, an infinite ``++for++`` loop is a bug.
2020-06-30 12:48:07 +02:00
=== Noncompliant code example
2020-06-30 12:48:07 +02:00
2022-02-04 17:28:24 +01:00
[source,javascript]
2020-06-30 12:48:07 +02:00
----
for (var i = 0; i < strings.length; i--) { // Noncompliant;
//...
}
----
=== Compliant solution
2020-06-30 12:48:07 +02:00
2022-02-04 17:28:24 +01:00
[source,javascript]
2020-06-30 12:48:07 +02:00
----
for (var i = 0; i < strings.length; i++) {
//...
}
----
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
include::../message.adoc[]
'''
== Comments And Links
(visible only on this page)
include::comments-and-links.adoc[]
endif::env-github,rspecator-view[]