Skip to content

Commit

Permalink
Move test to the correct scope
Browse files Browse the repository at this point in the history
  • Loading branch information
BraisGabin committed Nov 16, 2021
1 parent d4beaf4 commit 5b2e3e5
Showing 1 changed file with 27 additions and 27 deletions.
Expand Up @@ -344,37 +344,37 @@ class UnnecessaryLetSpec : Spek({
assertThat(findings).hasSize(1)
assertThat(findings).allMatch { it.message == MESSAGE_USE_IF }
}
}

it("reports when implicit parameter isn't used") {
val content = """
fun test(value: Int?) {
value?.let {
listOf(1).map { it }
}
it("reports when implicit parameter isn't used") {
val content = """
fun test(value: Int?) {
value?.let {
listOf(1).map { it }
}
"""
val findings = subject.compileAndLintWithContext(env, content)
assertThat(findings).hasSize(1)
assertThat(findings).allMatch { it.message == MESSAGE_USE_IF }
}
}
"""
val findings = subject.compileAndLintWithContext(env, content)
assertThat(findings).hasSize(1)
assertThat(findings).allMatch { it.message == MESSAGE_USE_IF }
}

it("does not report when an implicit parameter is used in an inner lambda") {
val content = """
fun callMe(callback: () -> Unit) {
callback()
}
fun test(value: Int?) {
value?.let {
callMe {
println(it)
}
}
it("does not report when an implicit parameter is used in an inner lambda") {
val content = """
fun callMe(callback: () -> Unit) {
callback()
}
fun test(value: Int?) {
value?.let {
callMe {
println(it)
}
}
"""
val findings = subject.compileAndLintWithContext(env, content)
assertThat(findings).isEmpty()
}
}
"""
val findings = subject.compileAndLintWithContext(env, content)
assertThat(findings).isEmpty()
}
}
})
Expand Down

0 comments on commit 5b2e3e5

Please sign in to comment.