33 lines
576 B
Plaintext
33 lines
576 B
Plaintext
![]() |
[source,kotlin,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) { // Noncompliant; duplicates first condition
|
||
|
doFirstThing()
|
||
|
doTheThing()
|
||
|
}
|
||
|
else {
|
||
|
doTheRest()
|
||
|
}
|
||
|
----
|
||
|
|
||
|
[source,kotlin,diff-id=2,diff-type=noncompliant]
|
||
|
----
|
||
|
when (x) {
|
||
|
1 -> {
|
||
|
doFirstThing()
|
||
|
doSomething()
|
||
|
}
|
||
|
2 -> doSomethingDifferent()
|
||
|
3 -> { // Noncompliant; duplicates case 1's implementation
|
||
|
doFirstThing()
|
||
|
doSomething()
|
||
|
}
|
||
|
else -> doTheRest()
|
||
|
}
|
||
|
----
|