Skip to content

Commit 45289f4

Browse files
SONARKT-644 Fix FP in S6311 when no Dispatcher is used explicitly
1 parent e6b18c3 commit 45289f4

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

kotlin-checks-test-sources/src/main/kotlin/checks/SuspendingFunCallerDispatcherCheckSample.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ class SuspendingFunCallerDispatcherCheckSample(val injectable: CoroutineDispatch
4141
launch(Dispatchers.IO) { // Compliant
4242
Thread.sleep(500L)
4343
}
44+
45+
async { // Compliant, no Dispatcher is used explicitly
46+
complex()
47+
}
4448
}
4549
}
4650

sonar-kotlin-checks/src/main/java/org/sonarsource/kotlin/checks/SuspendingFunCallerDispatcherCheck.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ class SuspendingFunCallerDispatcherCheck : CallAbstractCheck() {
4343
&& callExpressions.all {
4444
(it.resolveToCall()?.singleFunctionCallOrNull()?.partiallyAppliedSymbol?.signature?.symbol as? KaNamedFunctionSymbol)?.isSuspend == true
4545
}
46+
&& arguments.size == 2
4647
) {
4748
val argExpr = arguments.elementAt(0)
4849
kotlinFileContext.reportIssue(argExpr, "Remove this dispatcher. It is pointless when used with only suspending functions.")

0 commit comments

Comments
 (0)