rspec/rules/S2252/why.adoc
2023-07-03 14:45:25 +02:00

12 lines
533 B
Plaintext

== Why is this an issue?
A {for-link}[`{for-keyword}`] loop is a fundamental programming construct used to execute a block of code repeatedly. However, if the loop's condition is false before the first iteration, the loop will never execute.
include::{language}/noncompliant-code.adoc[]
Rewrite the loop to ensure the condition evaluates to `true` at least once.
include::{language}/compliant-code.adoc[]
This bug has the potential to cause unexpected outcomes as the loop might contain critical code that needs to be executed.