From 4b88d3177ba857759b0aae459506efcdd775bf50 Mon Sep 17 00:00:00 2001 From: M Schalk <30376729+schalkms@users.noreply.github.com> Date: Mon, 27 Dec 2021 04:44:58 +0100 Subject: [PATCH] Improve test description in ForEachOnRangeSpec.kt (#4402) --- .../rules/performance/ForEachOnRangeSpec.kt | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/detekt-rules-performance/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/performance/ForEachOnRangeSpec.kt b/detekt-rules-performance/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/performance/ForEachOnRangeSpec.kt index f5a5234a8f5..51d086fa1b1 100644 --- a/detekt-rules-performance/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/performance/ForEachOnRangeSpec.kt +++ b/detekt-rules-performance/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/performance/ForEachOnRangeSpec.kt @@ -7,9 +7,11 @@ import org.spekframework.spek2.style.specification.describe class ForEachOnRangeSpec : Spek({ + val subject by memoized { ForEachOnRange() } + describe("ForEachOnRange rule") { - context("a kt file with using a forEach on a range") { + context("using a forEach on a range") { val code = """ fun test() { (1..10).forEach { @@ -28,25 +30,25 @@ class ForEachOnRangeSpec : Spek({ """ it("should report the forEach usage") { - val findings = ForEachOnRange().compileAndLint(code) + val findings = subject.compileAndLint(code) assertThat(findings).hasSize(4) } } - context("a kt file with using any other method on a range") { + context("using any other method on a range") { val code = """ fun test() { (1..10).isEmpty() } """ - it("should report not report any issues") { - val findings = ForEachOnRange().compileAndLint(code) + it("should not report any issues") { + val findings = subject.compileAndLint(code) assertThat(findings).isEmpty() } } - context("a kt file with using a forEach on a list") { + context("using a forEach on a list") { val code = """ fun test() { listOf(1, 2, 3).forEach { @@ -55,8 +57,8 @@ class ForEachOnRangeSpec : Spek({ } """ - it("should report not report any issues") { - val findings = ForEachOnRange().compileAndLint(code) + it("should not report any issues") { + val findings = subject.compileAndLint(code) assertThat(findings).isEmpty() } }