
Inline adoc files when they are included exactly once. Also fix language tags because this inlining gives us better information on what language the code is written in.
53 lines
926 B
Plaintext
53 lines
926 B
Plaintext
== Why is this an issue?
|
|
|
|
A ``++Do ... Loop++`` without a ``++While++`` or ``++Until++`` condition must be terminated by an unstructured ``++Exit Do++`` statement. It is safer and more readable to use structured loops instead.
|
|
|
|
|
|
=== Noncompliant code example
|
|
|
|
[source,vbnet]
|
|
----
|
|
Module Module1
|
|
Sub Main()
|
|
Dim i = 1
|
|
|
|
Do ' Non-Compliant
|
|
If i = 10 Then
|
|
Exit Do
|
|
End If
|
|
|
|
Console.WriteLine(i)
|
|
|
|
i = i + 1
|
|
Loop
|
|
End Sub
|
|
End Module
|
|
----
|
|
|
|
|
|
=== Compliant solution
|
|
|
|
[source,vbnet]
|
|
----
|
|
Module Module1
|
|
Sub Main()
|
|
For i = 1 To 9 ' Compliant
|
|
Console.WriteLine(i)
|
|
Next
|
|
End Sub
|
|
End Module
|
|
----
|
|
|
|
ifdef::env-github,rspecator-view[]
|
|
|
|
'''
|
|
== Implementation Specification
|
|
(visible only on this page)
|
|
|
|
=== Message
|
|
|
|
Use a structured loop instead.
|
|
|
|
|
|
endif::env-github,rspecator-view[]
|