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