63 lines
1.2 KiB
Plaintext
63 lines
1.2 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
|
|
|
|
$str = null;
|
|
for ($i = 0; $i < count($array); $i++)
|
|
$str = $array[$i];
|
|
doTheThing($str); // Noncompliant; executed only on last array element
|
|
----
|
|
|
|
== Compliant Solution
|
|
|
|
----
|
|
if ($condition) {
|
|
firstActionInBlock();
|
|
secondAction();
|
|
}
|
|
thirdAction();
|
|
|
|
if($condition) { firstActionInBlock(); secondAction(); }
|
|
|
|
if($condition) {
|
|
firstActionInBlock();
|
|
secondAction();
|
|
}
|
|
|
|
$str = null;
|
|
for ($i = 0; $i < count($array); $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[]
|