A safe call is followed by !!, which throws when the safe call gave null

tx0/kotlin:safe-call-then-not-nullrecommendedwarningreliability/null-safetydepth fastbug

What it finds

user?.name!! stops at the null user and then throws on the null that the safe call produced, so the ?. hides where the null came from without preventing the exception. Either the receiver can be null and the null case needs handling, or it cannot and . says so.

From the rule's source, safe_call_then_assert.rs.

Example from the rule's tests
fun city(user: User?): String {    val a = user?.address!!tx0 reports: user?.address!! throws when the safe call gives null    val b = user?.address()!!tx0 reports: user?.address()!! throws    val c = user!!.address    return a + b + c}
Highlighted lines are the ones tx0 reports, with its message under each; the other lines are left alone.

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:

tx0.toml
[rules]
"tx0/kotlin:safe-call-then-not-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:safe-call-then-not-null] reason="..."

tx0 explain tx0/kotlin:safe-call-then-not-null shows the same in the terminal. Found a false positive? Report it.