From bc0607383bd091011c53551e12078cb2aa07447a Mon Sep 17 00:00:00 2001 From: M Schalk <30376729+schalkms@users.noreply.github.com> Date: Thu, 30 Dec 2021 16:42:26 +0100 Subject: [PATCH] Add test cases to RedundantSuspendModifier rule (#4430) This PR adds tests that run through previously uncovered paths of this rule. --- .../RedundantSuspendModifierSpec.kt | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/detekt-rules-coroutines/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/coroutines/RedundantSuspendModifierSpec.kt b/detekt-rules-coroutines/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/coroutines/RedundantSuspendModifierSpec.kt index a3ec7cc2264..8dc0088c283 100644 --- a/detekt-rules-coroutines/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/coroutines/RedundantSuspendModifierSpec.kt +++ b/detekt-rules-coroutines/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/coroutines/RedundantSuspendModifierSpec.kt @@ -63,6 +63,30 @@ object RedundantSuspendModifierSpec : Spek({ assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() } + it("does not report suspend function without body") { + val code = """ + interface SuspendInterface { + suspend fun empty() + } + """ + assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() + } + + it("does not report overridden suspend function") { + val code = """ + interface SuspendInterface { + suspend fun empty() + } + + class SuspendClass : SuspendInterface { + override suspend fun empty() { + println("hello world") + } + } + """ + assertThat(subject.compileAndLintWithContext(env, code)).isEmpty() + } + it("ignores when iterator is suspending") { val code = """ class SuspendingIterator {