dead.fish
11/17/2026, 12:54 PMResult<T> extension called onFailureOrRethrowCancellation which exactly does what the name suggests, allowing the handling of anything that is not a CancellationException. Now of course Detekt does not know about this method, so when it checks our runCatching code and sees a suspending method call, it still flags SuspendFunSwallowedCancellation. Would there be any way to let Detekt “learn” that this method “does the right thing” (TM), e.g. by annotating it somehow?Brais Gabin
11/18/2026, 10:59 AMBrais Gabin
11/18/2026, 10:59 AMinline fun R runCatchingSuspend(block: () -> R): ResultR {
@Suppress("SuspendFunSwallowedCancellation")
return runCatching(block)
.onFailure { if (it is CancellationException) throw it }
}Brais Gabin
11/18/2026, 11:00 AMrunCatching but runCatchingSuspend. (The name isn’t good). And detekt is completely fine with this.