Language
Kotlin 2.3.21
Rule
S3923 : All branches in a conditional structure should not have exactly the same implementation
Why it is a false-positive
In Kotlin, when several types in a sealed hierarchy have a common field, we can’t extract it in a single branch. It forces to duplicate the content of branches.
Kotlin should not issue an issue in this case.
Using
SonarQube Server v2026.3 (123014)
Example
sealed interface X
data object A: X
data class B(val s: String): X
data class C(val s: String): X
fun foo(s: String) = s + "foo"
fun main() {
val b: X = B("bar")
when (b) {
A -> ""
is B -> foo(b.s)
is C -> foo(b.s)
}
}