?: null gives null when the value is already null
What it finds
value ?: null is value: the right side is used only when the left is null, and it is null too. The operator was likely meant to give a default.
From the rule's source, elvis_null.rs.
fun pick(value: String?, fallback: String?): String? { val a = value ?: nulltx0 reports: value ?: null is the same as value val b = value ?: fallback return a ?: b} Turn it on, off or suppress it
The rule runs from the recommended tier up. To turn it on in a lower tier, give it a level in tx0.toml:
[rules]
"tx0/kotlin:elvis-returns-null" = "warning"To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:
// tx0: ignore[tx0/kotlin:elvis-returns-null] reason="..."tx0 explain tx0/kotlin:elvis-returns-null shows the same in the terminal. Found a false positive? Report it.