33 lines
592 B
Plaintext
33 lines
592 B
Plaintext
[source,php,diff-id=1,diff-type=noncompliant]
|
|
----
|
|
if ($a >= 0 && $a < 10) {
|
|
doFirst();
|
|
doTheThing();
|
|
}
|
|
else if ($a >= 10 && $a < 20) {
|
|
doTheOtherThing();
|
|
}
|
|
else if ($a >= 20 && $a < 50) {
|
|
doFirst();
|
|
doTheThing(); // Noncompliant; duplicates first condition
|
|
}
|
|
----
|
|
|
|
[source,php,diff-id=2,diff-type=noncompliant]
|
|
----
|
|
switch ($i) {
|
|
case 1:
|
|
doFirst();
|
|
doSomething();
|
|
break;
|
|
case 2:
|
|
doSomethingDifferent();
|
|
break;
|
|
case 3: // Noncompliant; duplicates case 1's implementation
|
|
doFirst();
|
|
doSomething();
|
|
break;
|
|
default:
|
|
doTheRest();
|
|
}
|
|
---- |