From 735d9c26a09132a865eb2a4db8445a387434628e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Brais=20Gab=C3=ADn?= Date: Sat, 23 Jul 2022 12:47:01 +0200 Subject: [PATCH] Don't use hasSourceLocations --- .../rules/complexity/ComplexMethodSpec.kt | 6 ++--- .../detekt/rules/complexity/LargeClassSpec.kt | 2 +- .../rules/bugs/UnreachableCatchBlockSpec.kt | 2 +- .../detekt/rules/naming/FunctionNamingSpec.kt | 4 ++-- .../detekt/rules/naming/VariableNamingSpec.kt | 4 ++-- .../rules/style/ForbiddenMethodCallSpec.kt | 2 +- .../detekt/rules/style/MagicNumberSpec.kt | 8 +++---- .../detekt/rules/style/MaxLineLengthSpec.kt | 2 +- .../detekt/rules/style/MayBeConstSpec.kt | 22 ++++++++--------- .../rules/style/ObjectLiteralToLambdaSpec.kt | 24 +++++++++---------- .../rules/style/OptionalWhenBracesSpec.kt | 4 ++-- .../style/ProtectedMemberInFinalClassSpec.kt | 4 ++-- .../rules/style/UnusedPrivateMemberSpec.kt | 2 +- 13 files changed, 43 insertions(+), 43 deletions(-) diff --git a/detekt-rules-complexity/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/complexity/ComplexMethodSpec.kt b/detekt-rules-complexity/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/complexity/ComplexMethodSpec.kt index e66fc783ab7..c5027ee7eba 100644 --- a/detekt-rules-complexity/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/complexity/ComplexMethodSpec.kt +++ b/detekt-rules-complexity/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/complexity/ComplexMethodSpec.kt @@ -129,7 +129,7 @@ class ComplexMethodSpec { ) val subject = ComplexMethod(config) - assertThat(subject.lint(path)).hasSourceLocations(SourceLocation(43, 5)) + assertThat(subject.lint(path)).hasStartSourceLocations(SourceLocation(43, 5)) } @Test @@ -137,7 +137,7 @@ class ComplexMethodSpec { val config = TestConfig(mapOf("threshold" to "4")) val subject = ComplexMethod(config) - assertThat(subject.lint(path)).hasSourceLocations( + assertThat(subject.lint(path)).hasStartSourceLocations( SourceLocation(6, 5), SourceLocation(15, 5), SourceLocation(25, 5), @@ -235,7 +235,7 @@ class ComplexMethodSpec { private fun assertExpectedComplexityValue(code: String, config: TestConfig, expectedValue: Int) { val findings = ComplexMethod(config).lint(code) - assertThat(findings).hasSourceLocations(SourceLocation(1, 5)) + assertThat(findings).hasStartSourceLocations(SourceLocation(1, 5)) assertThat(findings.first()) .isThresholded() diff --git a/detekt-rules-complexity/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/complexity/LargeClassSpec.kt b/detekt-rules-complexity/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/complexity/LargeClassSpec.kt index e8cc3e4b6f0..641b90d38ce 100644 --- a/detekt-rules-complexity/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/complexity/LargeClassSpec.kt +++ b/detekt-rules-complexity/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/complexity/LargeClassSpec.kt @@ -16,7 +16,7 @@ class LargeClassSpec { fun `should detect only the nested large class which exceeds threshold 70`() { val findings = subject(threshold = 70).lint(resourceAsPath("NestedClasses.kt")) assertThat(findings).hasSize(1) - assertThat(findings).hasSourceLocations(SourceLocation(12, 15)) + assertThat(findings).hasStartSourceLocations(SourceLocation(12, 15)) } @Test diff --git a/detekt-rules-errorprone/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/UnreachableCatchBlockSpec.kt b/detekt-rules-errorprone/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/UnreachableCatchBlockSpec.kt index 98e6a584f32..45d9454246b 100644 --- a/detekt-rules-errorprone/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/UnreachableCatchBlockSpec.kt +++ b/detekt-rules-errorprone/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/UnreachableCatchBlockSpec.kt @@ -54,7 +54,7 @@ class UnreachableCatchBlockSpec(private val env: KotlinCoreEnvironment) { """ val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(2) - assertThat(findings).hasSourceLocations( + assertThat(findings).hasStartSourceLocations( SourceLocation(4, 7), SourceLocation(5, 7) ) diff --git a/detekt-rules-naming/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/naming/FunctionNamingSpec.kt b/detekt-rules-naming/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/naming/FunctionNamingSpec.kt index e9c0e445a76..fbd4dbb6958 100644 --- a/detekt-rules-naming/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/naming/FunctionNamingSpec.kt +++ b/detekt-rules-naming/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/naming/FunctionNamingSpec.kt @@ -96,7 +96,7 @@ class FunctionNamingSpec { interface I { fun SHOULD_BE_FLAGGED() } """ val config = TestConfig(mapOf(FunctionNaming.IGNORE_OVERRIDDEN to "false")) - assertThat(FunctionNaming(config).compileAndLint(code)).hasSourceLocations( + assertThat(FunctionNaming(config).compileAndLint(code)).hasStartSourceLocations( SourceLocation(2, 18), SourceLocation(4, 19) ) @@ -107,6 +107,6 @@ class FunctionNamingSpec { val code = """ fun `7his is a function name _`() = Unit """ - assertThat(FunctionNaming().compileAndLint(code)).hasSourceLocations(SourceLocation(1, 5)) + assertThat(FunctionNaming().compileAndLint(code)).hasStartSourceLocations(SourceLocation(1, 5)) } } diff --git a/detekt-rules-naming/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/naming/VariableNamingSpec.kt b/detekt-rules-naming/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/naming/VariableNamingSpec.kt index 0c9e783e631..78c33c6982d 100644 --- a/detekt-rules-naming/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/naming/VariableNamingSpec.kt +++ b/detekt-rules-naming/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/naming/VariableNamingSpec.kt @@ -18,7 +18,7 @@ class VariableNamingSpec { } """ assertThat(VariableNaming().compileAndLint(code)) - .hasSourceLocations( + .hasStartSourceLocations( SourceLocation(2, 17), SourceLocation(3, 9), SourceLocation(4, 9) @@ -68,7 +68,7 @@ class VariableNamingSpec { """ val config = TestConfig(mapOf(IGNORE_OVERRIDDEN to "false")) assertThat(VariableNaming(config).compileAndLint(code)) - .hasSourceLocations( + .hasStartSourceLocations( SourceLocation(2, 18), SourceLocation(5, 18) ) diff --git a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/ForbiddenMethodCallSpec.kt b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/ForbiddenMethodCallSpec.kt index c5485f58ea1..a32decb4ed0 100644 --- a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/ForbiddenMethodCallSpec.kt +++ b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/ForbiddenMethodCallSpec.kt @@ -26,7 +26,7 @@ class ForbiddenMethodCallSpec(val env: KotlinCoreEnvironment) { assertThat(findings) .hasSize(2) - .hasSourceLocations( + .hasStartSourceLocations( SourceLocation(2, 5), SourceLocation(3, 5), ) diff --git a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/MagicNumberSpec.kt b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/MagicNumberSpec.kt index 3075bed107d..9a17346044f 100644 --- a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/MagicNumberSpec.kt +++ b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/MagicNumberSpec.kt @@ -321,7 +321,7 @@ class MagicNumberSpec { fun `should be reported`() { val findings = MagicNumber().lint(code) assertThat(findings) - .hasSourceLocations( + .hasStartSourceLocations( SourceLocation(1, 17), SourceLocation(1, 21), SourceLocation(1, 24), @@ -345,7 +345,7 @@ class MagicNumberSpec { @Test fun `should be reported`() { val findings = MagicNumber().lint(code) - assertThat(findings).hasSourceLocations( + assertThat(findings).hasStartSourceLocations( SourceLocation(3, 9), SourceLocation(3, 21), SourceLocation(4, 9), @@ -486,7 +486,7 @@ class MagicNumberSpec { val findings = MagicNumber(config).lint(code) assertThat(findings) - .hasSourceLocations( + .hasStartSourceLocations( SourceLocation(1, 17), SourceLocation(3, 24), SourceLocation(4, 33), @@ -616,7 +616,7 @@ class MagicNumberSpec { val findings = MagicNumber(config).lint(code) assertThat(findings) - .hasSourceLocations( + .hasStartSourceLocations( SourceLocation(4, 35), SourceLocation(5, 43) ) diff --git a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/MaxLineLengthSpec.kt b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/MaxLineLengthSpec.kt index fb2abb65d99..b9a814dca7f 100644 --- a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/MaxLineLengthSpec.kt +++ b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/MaxLineLengthSpec.kt @@ -258,7 +258,7 @@ class MaxLineLengthSpec { rule.visit(fileContent) assertThat(rule.findings).hasSize(1) - assertThat(rule.findings).hasSourceLocations(SourceLocation(6, 5)) + assertThat(rule.findings).hasStartSourceLocations(SourceLocation(6, 5)) } } } diff --git a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/MayBeConstSpec.kt b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/MayBeConstSpec.kt index f3786d258b5..97dd7c3da6f 100644 --- a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/MayBeConstSpec.kt +++ b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/MayBeConstSpec.kt @@ -87,7 +87,7 @@ class MayBeConstSpec { val x = 1 """ subject.compileAndLint(code) - assertThat(subject.findings).hasSize(1).hasSourceLocations( + assertThat(subject.findings).hasSize(1).hasStartSourceLocations( SourceLocation(1, 5) ) } @@ -98,7 +98,7 @@ class MayBeConstSpec { @JvmField val x = 1 """ subject.compileAndLint(code) - assertThat(subject.findings).hasSize(1).hasSourceLocations( + assertThat(subject.findings).hasSize(1).hasStartSourceLocations( SourceLocation(1, 15) ) } @@ -111,7 +111,7 @@ class MayBeConstSpec { } """ subject.compileAndLint(code) - assertThat(subject.findings).hasSize(1).hasSourceLocations( + assertThat(subject.findings).hasSize(1).hasStartSourceLocations( SourceLocation(2, 19) ) } @@ -126,7 +126,7 @@ class MayBeConstSpec { } """ subject.compileAndLint(code) - assertThat(subject.findings).hasSize(1).hasSourceLocations( + assertThat(subject.findings).hasSize(1).hasStartSourceLocations( SourceLocation(3, 13) ) } @@ -143,7 +143,7 @@ class MayBeConstSpec { } """ subject.compileAndLint(code) - assertThat(subject.findings).hasSize(1).hasSourceLocations( + assertThat(subject.findings).hasSize(1).hasStartSourceLocations( SourceLocation(3, 9) ) } @@ -159,7 +159,7 @@ class MayBeConstSpec { } """ subject.compileAndLint(code) - assertThat(subject.findings).hasSize(1).hasSourceLocations( + assertThat(subject.findings).hasSize(1).hasStartSourceLocations( SourceLocation(4, 13) ) } @@ -173,7 +173,7 @@ class MayBeConstSpec { } """ subject.compileAndLint(code) - assertThat(subject.findings).hasSize(1).hasSourceLocations( + assertThat(subject.findings).hasSize(1).hasStartSourceLocations( SourceLocation(3, 9) ) } @@ -187,7 +187,7 @@ class MayBeConstSpec { } """ subject.compileAndLint(code) - assertThat(subject.findings).hasSize(1).hasSourceLocations( + assertThat(subject.findings).hasSize(1).hasStartSourceLocations( SourceLocation(3, 9) ) } @@ -203,7 +203,7 @@ class MayBeConstSpec { } """ subject.compileAndLint(code) - assertThat(subject.findings).hasSize(1).hasSourceLocations( + assertThat(subject.findings).hasSize(1).hasStartSourceLocations( SourceLocation(5, 9) ) } @@ -217,7 +217,7 @@ class MayBeConstSpec { } """ subject.compileAndLint(code) - assertThat(subject.findings).hasSize(1).hasSourceLocations( + assertThat(subject.findings).hasSize(1).hasStartSourceLocations( SourceLocation(3, 17) ) } @@ -363,7 +363,7 @@ class MayBeConstSpec { } """ subject.compileAndLint(code) - assertThat(subject.findings).hasSize(3).hasSourceLocations( + assertThat(subject.findings).hasSize(3).hasStartSourceLocations( SourceLocation(4, 13), SourceLocation(7, 17), SourceLocation(11, 13) diff --git a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/ObjectLiteralToLambdaSpec.kt b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/ObjectLiteralToLambdaSpec.kt index 7452591d296..ca0b3e89673 100644 --- a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/ObjectLiteralToLambdaSpec.kt +++ b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/ObjectLiteralToLambdaSpec.kt @@ -33,7 +33,7 @@ class ObjectLiteralToLambdaSpec { subject.compileAndLintWithContext(env, code) .assert() .hasSize(1) - .hasSourceLocations(SourceLocation(4, 9)) + .hasStartSourceLocations(SourceLocation(4, 9)) } @Test @@ -52,7 +52,7 @@ class ObjectLiteralToLambdaSpec { subject.compileAndLintWithContext(env, code) .assert() .hasSize(1) - .hasSourceLocations(SourceLocation(5, 5)) + .hasStartSourceLocations(SourceLocation(5, 5)) } @Test @@ -73,7 +73,7 @@ class ObjectLiteralToLambdaSpec { subject.compileAndLintWithContext(env, code) .assert() .hasSize(1) - .hasSourceLocations(SourceLocation(6, 9)) + .hasStartSourceLocations(SourceLocation(6, 9)) } @Test @@ -91,7 +91,7 @@ class ObjectLiteralToLambdaSpec { subject.compileAndLintWithContext(env, code) .assert() .hasSize(1) - .hasSourceLocations(SourceLocation(4, 9)) + .hasStartSourceLocations(SourceLocation(4, 9)) } @Test @@ -109,7 +109,7 @@ class ObjectLiteralToLambdaSpec { subject.compileAndLintWithContext(env, code) .assert() .hasSize(1) - .hasSourceLocations(SourceLocation(5, 9)) + .hasStartSourceLocations(SourceLocation(5, 9)) } @Test @@ -130,7 +130,7 @@ class ObjectLiteralToLambdaSpec { subject.compileAndLintWithContext(env, code) .assert() .hasSize(1) - .hasSourceLocations(SourceLocation(7, 5)) + .hasStartSourceLocations(SourceLocation(7, 5)) } @Test @@ -146,7 +146,7 @@ class ObjectLiteralToLambdaSpec { subject.compileAndLintWithContext(env, code) .assert() .hasSize(1) - .hasSourceLocations(SourceLocation(4, 9)) + .hasStartSourceLocations(SourceLocation(4, 9)) } } @@ -337,7 +337,7 @@ class ObjectLiteralToLambdaSpec { subject.compileAndLintWithContext(env, code) .assert() .hasSize(1) - .hasSourceLocations(SourceLocation(1, 9)) + .hasStartSourceLocations(SourceLocation(1, 9)) } @Test @@ -353,7 +353,7 @@ class ObjectLiteralToLambdaSpec { subject.compileAndLintWithContext(env, code) .assert() .hasSize(1) - .hasSourceLocations(SourceLocation(2, 9)) + .hasStartSourceLocations(SourceLocation(2, 9)) } @Test @@ -466,7 +466,7 @@ class ObjectLiteralToLambdaSpec { subject.compileAndLintWithContext(env, code) .assert() .hasSize(1) - .hasSourceLocations(SourceLocation(6, 5)) + .hasStartSourceLocations(SourceLocation(6, 5)) } @Test @@ -489,7 +489,7 @@ class ObjectLiteralToLambdaSpec { subject.compileAndLintWithContext(env, code) .assert() .hasSize(1) - .hasSourceLocations(SourceLocation(7, 9)) + .hasStartSourceLocations(SourceLocation(7, 9)) } @Test @@ -534,7 +534,7 @@ class ObjectLiteralToLambdaSpec { subject.compileAndLintWithContext(env, code) .assert() .hasSize(1) - .hasSourceLocations(SourceLocation(5, 19)) + .hasStartSourceLocations(SourceLocation(5, 19)) } } } diff --git a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/OptionalWhenBracesSpec.kt b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/OptionalWhenBracesSpec.kt index 05991eed958..72171b78680 100644 --- a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/OptionalWhenBracesSpec.kt +++ b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/OptionalWhenBracesSpec.kt @@ -66,7 +66,7 @@ class OptionalWhenBracesSpec { """ assertThat(subject.compileAndLint(code)) .hasSize(2) - .hasSourceLocations(SourceLocation(7, 17), SourceLocation(10, 17)) + .hasStartSourceLocations(SourceLocation(7, 17), SourceLocation(10, 17)) } @Test @@ -87,7 +87,7 @@ class OptionalWhenBracesSpec { """ assertThat(subject.compileAndLint(code)) .hasSize(1) - .hasSourceLocations(SourceLocation(3, 9)) + .hasStartSourceLocations(SourceLocation(3, 9)) } @Nested diff --git a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/ProtectedMemberInFinalClassSpec.kt b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/ProtectedMemberInFinalClassSpec.kt index 1bc59f6c582..4ff47a08ef0 100644 --- a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/ProtectedMemberInFinalClassSpec.kt +++ b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/ProtectedMemberInFinalClassSpec.kt @@ -77,7 +77,7 @@ class ProtectedMemberInFinalClassSpec { """ val findings = subject.compileAndLint(code) assertThat(findings).hasSize(2) - assertThat(findings).hasSourceLocations( + assertThat(findings).hasStartSourceLocations( SourceLocation(2, 5), SourceLocation(3, 9) ) @@ -96,7 +96,7 @@ class ProtectedMemberInFinalClassSpec { """ val findings = subject.compileAndLint(code) assertThat(findings).hasSize(3) - assertThat(findings).hasSourceLocations( + assertThat(findings).hasStartSourceLocations( SourceLocation(2, 5), SourceLocation(2, 5), SourceLocation(4, 13) diff --git a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/UnusedPrivateMemberSpec.kt b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/UnusedPrivateMemberSpec.kt index e8b7078e96a..b81acf5ea82 100644 --- a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/UnusedPrivateMemberSpec.kt +++ b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/UnusedPrivateMemberSpec.kt @@ -1320,7 +1320,7 @@ class UnusedPrivateMemberSpec(val env: KotlinCoreEnvironment) { } """ val findings = subject.compileAndLintWithContext(env, code) - assertThat(findings).hasSize(1).hasSourceLocations( + assertThat(findings).hasSize(1).hasStartSourceLocations( SourceLocation(3, 30) ) }