58 lines
1.0 KiB
Plaintext
58 lines
1.0 KiB
Plaintext
include::../description.adoc[]
|
|
|
|
== Noncompliant Code Example
|
|
|
|
----
|
|
if (condition)
|
|
FirstActionInBlock();
|
|
SecondAction(); // Noncompliant; executed unconditionally
|
|
ThirdAction();
|
|
|
|
if(condition) FirstActionInBlock(); SecondAction(); // Noncompliant; secondAction executed unconditionally
|
|
|
|
if(condition) FirstActionInBlock(); // Noncompliant
|
|
SecondAction(); // Executed unconditionally
|
|
|
|
string str = null;
|
|
for (int i = 0; i < array.Length; i++)
|
|
str = array[i];
|
|
DoTheThing(str); // Noncompliant; executed only on last array element
|
|
----
|
|
|
|
== Compliant Solution
|
|
|
|
----
|
|
if (condition)
|
|
{
|
|
FirstActionInBlock();
|
|
SecondAction();
|
|
}
|
|
ThirdAction();
|
|
|
|
string str = null;
|
|
for (int i = 0; i < array.Length; i++)
|
|
{
|
|
str = array[i];
|
|
DoTheThing(str);
|
|
}
|
|
----
|
|
|
|
include::../see.adoc[]
|
|
|
|
ifdef::env-github,rspecator-view[]
|
|
|
|
'''
|
|
== Implementation Specification
|
|
(visible only on this page)
|
|
|
|
include::../message.adoc[]
|
|
|
|
include::../highlighting.adoc[]
|
|
|
|
'''
|
|
== Comments And Links
|
|
(visible only on this page)
|
|
|
|
include::../comments-and-links.adoc[]
|
|
endif::env-github,rspecator-view[]
|