From 6245074357886d0dd66fe72f713c62cf52d52e7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Brais=20Gab=C3=ADn?= Date: Sat, 23 Jul 2022 12:48:56 +0200 Subject: [PATCH] Don't use hasSourceLocation --- .../detekt/formatting/IndentationSpec.kt | 2 +- .../detekt/formatting/WrappingSpec.kt | 2 +- .../complexity/NestedScopeFunctionsSpec.kt | 2 +- .../rules/empty/EmptyFunctionBlockSpec.kt | 8 +-- .../rules/bugs/CastToNullableTypeSpec.kt | 2 +- .../bugs/DoubleMutabilityForCollectionSpec.kt | 66 +++++++++---------- .../rules/bugs/IgnoredReturnValueSpec.kt | 20 +++--- .../rules/bugs/UnreachableCatchBlockSpec.kt | 4 +- .../rules/bugs/UnusedUnaryOperatorSpec.kt | 4 +- .../detekt/rules/naming/FunctionNamingSpec.kt | 4 +- .../naming/MatchingDeclarationNameSpec.kt | 14 ++-- .../rules/naming/NoNameShadowingSpec.kt | 2 +- .../rules/naming/ObjectPropertyNamingSpec.kt | 4 +- .../rules/style/ForbiddenMethodCallSpec.kt | 17 +++-- .../rules/style/ForbiddenSuppressSpec.kt | 12 ++-- .../detekt/rules/style/MagicNumberSpec.kt | 24 +++---- .../rules/style/NewLineAtEndOfFileSpec.kt | 2 +- .../style/ProtectedMemberInFinalClassSpec.kt | 14 ++-- .../style/RedundantHigherOrderMapUsageSpec.kt | 4 +- .../style/UnnecessaryAbstractClassSpec.kt | 8 +-- .../rules/style/UnusedPrivateClassSpec.kt | 8 +-- .../rules/style/UnusedPrivateMemberSpec.kt | 6 +- .../detekt/rules/style/UseCheckOrErrorSpec.kt | 14 ++-- .../rules/style/UseIfEmptyOrIfBlankSpec.kt | 8 +-- .../rules/style/UseIsNullOrEmptySpec.kt | 2 +- .../detekt/rules/style/UseOrEmptySpec.kt | 2 +- .../detekt/rules/style/UseRequireSpec.kt | 8 +-- .../detekt/test/FindingsAssertions.kt | 2 +- 28 files changed, 132 insertions(+), 133 deletions(-) diff --git a/detekt-formatting/src/test/kotlin/io/gitlab/arturbosch/detekt/formatting/IndentationSpec.kt b/detekt-formatting/src/test/kotlin/io/gitlab/arturbosch/detekt/formatting/IndentationSpec.kt index 4132f564fc0..dde037d753e 100644 --- a/detekt-formatting/src/test/kotlin/io/gitlab/arturbosch/detekt/formatting/IndentationSpec.kt +++ b/detekt-formatting/src/test/kotlin/io/gitlab/arturbosch/detekt/formatting/IndentationSpec.kt @@ -34,7 +34,7 @@ class IndentationSpec { @Test fun `places finding location to the indentation`() { subject.lint(code).assert() - .hasSourceLocation(2, 1) + .hasStartSourceLocation(2, 1) .hasTextLocations(13 to 14) } } diff --git a/detekt-formatting/src/test/kotlin/io/gitlab/arturbosch/detekt/formatting/WrappingSpec.kt b/detekt-formatting/src/test/kotlin/io/gitlab/arturbosch/detekt/formatting/WrappingSpec.kt index 47235379254..fce2fa2241b 100644 --- a/detekt-formatting/src/test/kotlin/io/gitlab/arturbosch/detekt/formatting/WrappingSpec.kt +++ b/detekt-formatting/src/test/kotlin/io/gitlab/arturbosch/detekt/formatting/WrappingSpec.kt @@ -31,7 +31,7 @@ class WrappingSpec { subject.lint(code).assert() .hasSize(1) - .hasSourceLocation(1, 12) + .hasStartSourceLocation(1, 12) .hasTextLocations(11 to 12) } } diff --git a/detekt-rules-complexity/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/complexity/NestedScopeFunctionsSpec.kt b/detekt-rules-complexity/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/complexity/NestedScopeFunctionsSpec.kt index df1817d52b5..583ab5dd918 100644 --- a/detekt-rules-complexity/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/complexity/NestedScopeFunctionsSpec.kt +++ b/detekt-rules-complexity/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/complexity/NestedScopeFunctionsSpec.kt @@ -116,7 +116,7 @@ class NestedScopeFunctionsSpec(private val env: KotlinCoreEnvironment) { } private fun expectSourceLocation(location: Pair) { - assertThat(actual).hasSourceLocation(location.first, location.second) + assertThat(actual).hasStartSourceLocation(location.first, location.second) } private fun expectFunctionInMsg(scopeFunction: String) { diff --git a/detekt-rules-empty/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/empty/EmptyFunctionBlockSpec.kt b/detekt-rules-empty/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/empty/EmptyFunctionBlockSpec.kt index 1c1ad463f84..5254750568f 100644 --- a/detekt-rules-empty/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/empty/EmptyFunctionBlockSpec.kt +++ b/detekt-rules-empty/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/empty/EmptyFunctionBlockSpec.kt @@ -21,7 +21,7 @@ class EmptyFunctionBlockSpec { protected fun stuff() {} } """ - assertThat(subject.compileAndLint(code)).hasSourceLocation(2, 27) + assertThat(subject.compileAndLint(code)).hasStartSourceLocation(2, 27) } @Test @@ -51,7 +51,7 @@ class EmptyFunctionBlockSpec { fun b() {} } """ - assertThat(subject.compileAndLint(code)).hasSourceLocation(2, 13) + assertThat(subject.compileAndLint(code)).hasStartSourceLocation(2, 13) } @Nested @@ -89,7 +89,7 @@ class EmptyFunctionBlockSpec { @Test fun `should not flag overridden functions`() { val config = TestConfig(mapOf(IGNORE_OVERRIDDEN_FUNCTIONS to "true")) - assertThat(EmptyFunctionBlock(config).compileAndLint(code)).hasSourceLocation(1, 13) + assertThat(EmptyFunctionBlock(config).compileAndLint(code)).hasStartSourceLocation(1, 13) } } @@ -115,7 +115,7 @@ class EmptyFunctionBlockSpec { @Test fun `should not flag overridden functions with commented body`() { - assertThat(subject.compileAndLint(code)).hasSourceLocation(12, 31) + assertThat(subject.compileAndLint(code)).hasStartSourceLocation(12, 31) } @Test diff --git a/detekt-rules-errorprone/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/CastToNullableTypeSpec.kt b/detekt-rules-errorprone/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/CastToNullableTypeSpec.kt index 0e8cfde05ae..9be0ba15c30 100644 --- a/detekt-rules-errorprone/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/CastToNullableTypeSpec.kt +++ b/detekt-rules-errorprone/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/CastToNullableTypeSpec.kt @@ -16,7 +16,7 @@ class CastToNullableTypeSpec { """ val findings = subject.compileAndLint(code) assertThat(findings).hasSize(1) - assertThat(findings).hasSourceLocation(2, 22) + assertThat(findings).hasStartSourceLocation(2, 22) assertThat(findings[0]).hasMessage("Use the safe cast ('as? String') instead of 'as String?'.") } diff --git a/detekt-rules-errorprone/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/DoubleMutabilityForCollectionSpec.kt b/detekt-rules-errorprone/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/DoubleMutabilityForCollectionSpec.kt index 40dace89da9..d2c201441c7 100644 --- a/detekt-rules-errorprone/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/DoubleMutabilityForCollectionSpec.kt +++ b/detekt-rules-errorprone/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/DoubleMutabilityForCollectionSpec.kt @@ -30,7 +30,7 @@ class DoubleMutabilityForCollectionSpec(private val env: KotlinCoreEnvironment) """ val result = subject.compileAndLintWithContext(env, code) assertThat(result).hasSize(1) - assertThat(result).hasSourceLocation(2, 5) + assertThat(result).hasStartSourceLocation(2, 5) } @Test @@ -42,7 +42,7 @@ class DoubleMutabilityForCollectionSpec(private val env: KotlinCoreEnvironment) """ val result = subject.compileAndLintWithContext(env, code) assertThat(result).hasSize(1) - assertThat(result).hasSourceLocation(2, 5) + assertThat(result).hasStartSourceLocation(2, 5) } @Test @@ -54,7 +54,7 @@ class DoubleMutabilityForCollectionSpec(private val env: KotlinCoreEnvironment) """ val result = subject.compileAndLintWithContext(env, code) assertThat(result).hasSize(1) - assertThat(result).hasSourceLocation(2, 5) + assertThat(result).hasStartSourceLocation(2, 5) } @Test @@ -66,7 +66,7 @@ class DoubleMutabilityForCollectionSpec(private val env: KotlinCoreEnvironment) """ val result = subject.compileAndLintWithContext(env, code) assertThat(result).hasSize(1) - assertThat(result).hasSourceLocation(2, 5) + assertThat(result).hasStartSourceLocation(2, 5) } @Test @@ -78,7 +78,7 @@ class DoubleMutabilityForCollectionSpec(private val env: KotlinCoreEnvironment) """ val result = subject.compileAndLintWithContext(env, code) assertThat(result).hasSize(1) - assertThat(result).hasSourceLocation(2, 5) + assertThat(result).hasStartSourceLocation(2, 5) } @Test @@ -90,7 +90,7 @@ class DoubleMutabilityForCollectionSpec(private val env: KotlinCoreEnvironment) """ val result = subject.compileAndLintWithContext(env, code) assertThat(result).hasSize(1) - assertThat(result).hasSourceLocation(2, 5) + assertThat(result).hasStartSourceLocation(2, 5) } @Test @@ -102,7 +102,7 @@ class DoubleMutabilityForCollectionSpec(private val env: KotlinCoreEnvironment) """ val result = subject.compileAndLintWithContext(env, code) assertThat(result).hasSize(1) - assertThat(result).hasSourceLocation(2, 5) + assertThat(result).hasStartSourceLocation(2, 5) } @Test @@ -114,7 +114,7 @@ class DoubleMutabilityForCollectionSpec(private val env: KotlinCoreEnvironment) """ val result = subject.compileAndLintWithContext(env, code) assertThat(result).hasSize(1) - assertThat(result).hasSourceLocation(2, 5) + assertThat(result).hasStartSourceLocation(2, 5) } @Test @@ -135,7 +135,7 @@ class DoubleMutabilityForCollectionSpec(private val env: KotlinCoreEnvironment) """ val result = rule.compileAndLintWithContext(env, code) assertThat(result).hasSize(1) - assertThat(result).hasSourceLocation(3, 5) + assertThat(result).hasStartSourceLocation(3, 5) } @Test @@ -157,7 +157,7 @@ class DoubleMutabilityForCollectionSpec(private val env: KotlinCoreEnvironment) """ val result = rule.compileAndLintWithContext(env, code) assertThat(result).hasSize(1) - assertThat(result).hasSourceLocation(4, 5) + assertThat(result).hasStartSourceLocation(4, 5) } @Test @@ -180,7 +180,7 @@ class DoubleMutabilityForCollectionSpec(private val env: KotlinCoreEnvironment) """ val result = rule.compileAndLintWithContext(env, code) assertThat(result).hasSize(1) - assertThat(result).hasSourceLocation(5, 5) + assertThat(result).hasStartSourceLocation(5, 5) } } @@ -357,7 +357,7 @@ class DoubleMutabilityForCollectionSpec(private val env: KotlinCoreEnvironment) """ val result = subject.compileAndLintWithContext(env, code) assertThat(result).hasSize(1) - assertThat(result).hasSourceLocation(1, 1) + assertThat(result).hasStartSourceLocation(1, 1) } @Test @@ -367,7 +367,7 @@ class DoubleMutabilityForCollectionSpec(private val env: KotlinCoreEnvironment) """ val result = subject.compileAndLintWithContext(env, code) assertThat(result).hasSize(1) - assertThat(result).hasSourceLocation(1, 1) + assertThat(result).hasStartSourceLocation(1, 1) } @Test @@ -377,7 +377,7 @@ class DoubleMutabilityForCollectionSpec(private val env: KotlinCoreEnvironment) """ val result = subject.compileAndLintWithContext(env, code) assertThat(result).hasSize(1) - assertThat(result).hasSourceLocation(1, 1) + assertThat(result).hasStartSourceLocation(1, 1) } @Test @@ -387,7 +387,7 @@ class DoubleMutabilityForCollectionSpec(private val env: KotlinCoreEnvironment) """ val result = subject.compileAndLintWithContext(env, code) assertThat(result).hasSize(1) - assertThat(result).hasSourceLocation(1, 1) + assertThat(result).hasStartSourceLocation(1, 1) } @Test @@ -397,7 +397,7 @@ class DoubleMutabilityForCollectionSpec(private val env: KotlinCoreEnvironment) """ val result = subject.compileAndLintWithContext(env, code) assertThat(result).hasSize(1) - assertThat(result).hasSourceLocation(1, 1) + assertThat(result).hasStartSourceLocation(1, 1) } @Test @@ -407,7 +407,7 @@ class DoubleMutabilityForCollectionSpec(private val env: KotlinCoreEnvironment) """ val result = subject.compileAndLintWithContext(env, code) assertThat(result).hasSize(1) - assertThat(result).hasSourceLocation(1, 1) + assertThat(result).hasStartSourceLocation(1, 1) } @Test @@ -417,7 +417,7 @@ class DoubleMutabilityForCollectionSpec(private val env: KotlinCoreEnvironment) """ val result = subject.compileAndLintWithContext(env, code) assertThat(result).hasSize(1) - assertThat(result).hasSourceLocation(1, 1) + assertThat(result).hasStartSourceLocation(1, 1) } @Test @@ -427,7 +427,7 @@ class DoubleMutabilityForCollectionSpec(private val env: KotlinCoreEnvironment) """ val result = subject.compileAndLintWithContext(env, code) assertThat(result).hasSize(1) - assertThat(result).hasSourceLocation(1, 1) + assertThat(result).hasStartSourceLocation(1, 1) } @Test @@ -446,7 +446,7 @@ class DoubleMutabilityForCollectionSpec(private val env: KotlinCoreEnvironment) """ val result = rule.compileAndLintWithContext(env, code) assertThat(result).hasSize(1) - assertThat(result).hasSourceLocation(2, 1) + assertThat(result).hasStartSourceLocation(2, 1) } @Test @@ -466,7 +466,7 @@ class DoubleMutabilityForCollectionSpec(private val env: KotlinCoreEnvironment) """ val result = rule.compileAndLintWithContext(env, code) assertThat(result).hasSize(1) - assertThat(result).hasSourceLocation(3, 1) + assertThat(result).hasStartSourceLocation(3, 1) } @Test @@ -487,7 +487,7 @@ class DoubleMutabilityForCollectionSpec(private val env: KotlinCoreEnvironment) """ val result = rule.compileAndLintWithContext(env, code) assertThat(result).hasSize(1) - assertThat(result).hasSourceLocation(4, 1) + assertThat(result).hasStartSourceLocation(4, 1) } } @@ -642,7 +642,7 @@ class DoubleMutabilityForCollectionSpec(private val env: KotlinCoreEnvironment) """ val result = subject.compileAndLintWithContext(env, code) assertThat(result).hasSize(1) - assertThat(result).hasSourceLocation(2, 5) + assertThat(result).hasStartSourceLocation(2, 5) } @Test @@ -654,7 +654,7 @@ class DoubleMutabilityForCollectionSpec(private val env: KotlinCoreEnvironment) """ val result = subject.compileAndLintWithContext(env, code) assertThat(result).hasSize(1) - assertThat(result).hasSourceLocation(2, 5) + assertThat(result).hasStartSourceLocation(2, 5) } @Test @@ -666,7 +666,7 @@ class DoubleMutabilityForCollectionSpec(private val env: KotlinCoreEnvironment) """ val result = subject.compileAndLintWithContext(env, code) assertThat(result).hasSize(1) - assertThat(result).hasSourceLocation(2, 5) + assertThat(result).hasStartSourceLocation(2, 5) } @Test @@ -678,7 +678,7 @@ class DoubleMutabilityForCollectionSpec(private val env: KotlinCoreEnvironment) """ val result = subject.compileAndLintWithContext(env, code) assertThat(result).hasSize(1) - assertThat(result).hasSourceLocation(2, 5) + assertThat(result).hasStartSourceLocation(2, 5) } @Test @@ -690,7 +690,7 @@ class DoubleMutabilityForCollectionSpec(private val env: KotlinCoreEnvironment) """ val result = subject.compileAndLintWithContext(env, code) assertThat(result).hasSize(1) - assertThat(result).hasSourceLocation(2, 5) + assertThat(result).hasStartSourceLocation(2, 5) } @Test @@ -702,7 +702,7 @@ class DoubleMutabilityForCollectionSpec(private val env: KotlinCoreEnvironment) """ val result = subject.compileAndLintWithContext(env, code) assertThat(result).hasSize(1) - assertThat(result).hasSourceLocation(2, 5) + assertThat(result).hasStartSourceLocation(2, 5) } @Test @@ -714,7 +714,7 @@ class DoubleMutabilityForCollectionSpec(private val env: KotlinCoreEnvironment) """ val result = subject.compileAndLintWithContext(env, code) assertThat(result).hasSize(1) - assertThat(result).hasSourceLocation(2, 5) + assertThat(result).hasStartSourceLocation(2, 5) } @Test @@ -726,7 +726,7 @@ class DoubleMutabilityForCollectionSpec(private val env: KotlinCoreEnvironment) """ val result = subject.compileAndLintWithContext(env, code) assertThat(result).hasSize(1) - assertThat(result).hasSourceLocation(2, 5) + assertThat(result).hasStartSourceLocation(2, 5) } @Test @@ -747,7 +747,7 @@ class DoubleMutabilityForCollectionSpec(private val env: KotlinCoreEnvironment) """ val result = rule.compileAndLintWithContext(env, code) assertThat(result).hasSize(1) - assertThat(result).hasSourceLocation(3, 5) + assertThat(result).hasStartSourceLocation(3, 5) } @Test @@ -769,7 +769,7 @@ class DoubleMutabilityForCollectionSpec(private val env: KotlinCoreEnvironment) """ val result = rule.compileAndLintWithContext(env, code) assertThat(result).hasSize(1) - assertThat(result).hasSourceLocation(4, 5) + assertThat(result).hasStartSourceLocation(4, 5) } @Test @@ -792,7 +792,7 @@ class DoubleMutabilityForCollectionSpec(private val env: KotlinCoreEnvironment) """ val result = rule.compileAndLintWithContext(env, code) assertThat(result).hasSize(1) - assertThat(result).hasSourceLocation(5, 5) + assertThat(result).hasStartSourceLocation(5, 5) } } diff --git a/detekt-rules-errorprone/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/IgnoredReturnValueSpec.kt b/detekt-rules-errorprone/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/IgnoredReturnValueSpec.kt index 41693016a9e..f78eaeff2f0 100644 --- a/detekt-rules-errorprone/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/IgnoredReturnValueSpec.kt +++ b/detekt-rules-errorprone/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/IgnoredReturnValueSpec.kt @@ -206,7 +206,7 @@ class IgnoredReturnValueSpec(private val env: KotlinCoreEnvironment) { val findings = subject.lintWithContext(env, code, annotationClass) assertThat(findings).hasSize(1) - assertThat(findings).hasSourceLocation(7, 5) + assertThat(findings).hasStartSourceLocation(7, 5) assertThat(findings[0]).hasMessage("The call listOfChecked is returning a value that is ignored.") } @@ -227,7 +227,7 @@ class IgnoredReturnValueSpec(private val env: KotlinCoreEnvironment) { """ val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) - assertThat(findings).hasSourceLocation(9, 5) + assertThat(findings).hasStartSourceLocation(9, 5) assertThat(findings[0]).hasMessage("The call listOfChecked is returning a value that is ignored.") } @@ -294,7 +294,7 @@ class IgnoredReturnValueSpec(private val env: KotlinCoreEnvironment) { """ val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) - assertThat(findings).hasSourceLocation(12, 10) + assertThat(findings).hasStartSourceLocation(12, 10) assertThat(findings[0]).hasMessage("The call listOfChecked is returning a value that is ignored.") } @@ -314,7 +314,7 @@ class IgnoredReturnValueSpec(private val env: KotlinCoreEnvironment) { """ val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) - assertThat(findings).hasSourceLocation(9, 5) + assertThat(findings).hasStartSourceLocation(9, 5) assertThat(findings[0]).hasMessage("The call listOfChecked is returning a value that is ignored.") } @@ -335,7 +335,7 @@ class IgnoredReturnValueSpec(private val env: KotlinCoreEnvironment) { """ val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) - assertThat(findings).hasSourceLocation(9, 20) + assertThat(findings).hasStartSourceLocation(9, 20) assertThat(findings[0]).hasMessage("The call listOfChecked is returning a value that is ignored.") } @@ -356,7 +356,7 @@ class IgnoredReturnValueSpec(private val env: KotlinCoreEnvironment) { """ val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) - assertThat(findings).hasSourceLocation(9, 14) + assertThat(findings).hasStartSourceLocation(9, 14) assertThat(findings[0]).hasMessage("The call listOfChecked is returning a value that is ignored.") } @@ -376,7 +376,7 @@ class IgnoredReturnValueSpec(private val env: KotlinCoreEnvironment) { """ val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) - assertThat(findings).hasSourceLocation(8, 11) + assertThat(findings).hasStartSourceLocation(8, 11) assertThat(findings[0]).hasMessage("The call isTheAnswer is returning a value that is ignored.") } @@ -730,7 +730,7 @@ class IgnoredReturnValueSpec(private val env: KotlinCoreEnvironment) { """ val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) - assertThat(findings).hasSourceLocation(8, 5) + assertThat(findings).hasStartSourceLocation(8, 5) assertThat(findings[0]).hasMessage("The call listOfChecked is returning a value that is ignored.") } @@ -791,7 +791,7 @@ class IgnoredReturnValueSpec(private val env: KotlinCoreEnvironment) { """ val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) - assertThat(findings).hasSourceLocation(9, 5) + assertThat(findings).hasStartSourceLocation(9, 5) assertThat(findings[0]).hasMessage("The call listOfChecked is returning a value that is ignored.") } @@ -807,7 +807,7 @@ class IgnoredReturnValueSpec(private val env: KotlinCoreEnvironment) { """ val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) - assertThat(findings).hasSourceLocation(4, 5) + assertThat(findings).hasStartSourceLocation(4, 5) assertThat(findings[0]).hasMessage("The call listOfChecked is returning a value that is ignored.") } 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 45d9454246b..a9ebdbb393d 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 @@ -23,7 +23,7 @@ class UnreachableCatchBlockSpec(private val env: KotlinCoreEnvironment) { """ val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) - assertThat(findings).hasSourceLocation(4, 7) + assertThat(findings).hasStartSourceLocation(4, 7) } @Test @@ -38,7 +38,7 @@ class UnreachableCatchBlockSpec(private val env: KotlinCoreEnvironment) { """ val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) - assertThat(findings).hasSourceLocation(4, 7) + assertThat(findings).hasStartSourceLocation(4, 7) } @Test diff --git a/detekt-rules-errorprone/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/UnusedUnaryOperatorSpec.kt b/detekt-rules-errorprone/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/UnusedUnaryOperatorSpec.kt index fe6f4debbe6..893b23bc3ee 100644 --- a/detekt-rules-errorprone/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/UnusedUnaryOperatorSpec.kt +++ b/detekt-rules-errorprone/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/UnusedUnaryOperatorSpec.kt @@ -20,7 +20,7 @@ class UnusedUnaryOperatorSpec(private val env: KotlinCoreEnvironment) { """ val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) - assertThat(findings).hasSourceLocation(3, 9) + assertThat(findings).hasStartSourceLocation(3, 9) assertThat(findings[0]).hasMessage("This '+ 3' is not used") } @@ -34,7 +34,7 @@ class UnusedUnaryOperatorSpec(private val env: KotlinCoreEnvironment) { """ val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) - assertThat(findings).hasSourceLocation(3, 9) + assertThat(findings).hasStartSourceLocation(3, 9) assertThat(findings[0]).hasMessage("This '- 3' is not used") } 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 fbd4dbb6958..59dc5ca0635 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 @@ -48,7 +48,7 @@ class FunctionNamingSpec { } interface I { fun shouldNotBeFlagged() } """ - assertThat(FunctionNaming().compileAndLint(code)).hasSourceLocation(3, 13) + assertThat(FunctionNaming().compileAndLint(code)).hasStartSourceLocation(3, 13) } @Test @@ -84,7 +84,7 @@ class FunctionNamingSpec { } interface I { @Suppress("FunctionNaming") fun SHOULD_BE_FLAGGED() } """ - assertThat(FunctionNaming().compileAndLint(code)).hasSourceLocation(3, 13) + assertThat(FunctionNaming().compileAndLint(code)).hasStartSourceLocation(3, 13) } @Test diff --git a/detekt-rules-naming/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/naming/MatchingDeclarationNameSpec.kt b/detekt-rules-naming/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/naming/MatchingDeclarationNameSpec.kt index b5c29655987..89cb46cfa9b 100644 --- a/detekt-rules-naming/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/naming/MatchingDeclarationNameSpec.kt +++ b/detekt-rules-naming/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/naming/MatchingDeclarationNameSpec.kt @@ -132,7 +132,7 @@ class MatchingDeclarationNameSpec { fun `should not pass for object declaration`() { val ktFile = compileContentForTest("object O", filename = "Objects.kt") val findings = MatchingDeclarationName().lint(ktFile) - assertThat(findings).hasSourceLocation(1, 8) + assertThat(findings).hasStartSourceLocation(1, 8) } @Test @@ -142,14 +142,14 @@ class MatchingDeclarationNameSpec { filename = "Objects.kt" ) val findings = MatchingDeclarationName().lint(ktFile) - assertThat(findings).hasSourceLocation(1, 45) + assertThat(findings).hasStartSourceLocation(1, 45) } @Test fun `should not pass for class declaration`() { val ktFile = compileContentForTest("class C", filename = "Classes.kt") val findings = MatchingDeclarationName().lint(ktFile) - assertThat(findings).hasSourceLocation(1, 7) + assertThat(findings).hasStartSourceLocation(1, 7) } @Test @@ -163,14 +163,14 @@ class MatchingDeclarationNameSpec { filename = "ClassUtils.kt" ) val findings = MatchingDeclarationName().lint(ktFile) - assertThat(findings).hasSourceLocation(1, 7) + assertThat(findings).hasStartSourceLocation(1, 7) } @Test fun `should not pass for interface declaration`() { val ktFile = compileContentForTest("interface I", filename = "Not_I.kt") val findings = MatchingDeclarationName().lint(ktFile) - assertThat(findings).hasSourceLocation(1, 11) + assertThat(findings).hasStartSourceLocation(1, 11) } @Test @@ -184,7 +184,7 @@ class MatchingDeclarationNameSpec { filename = "E.kt" ) val findings = MatchingDeclarationName().lint(ktFile) - assertThat(findings).hasSourceLocation(1, 12) + assertThat(findings).hasStartSourceLocation(1, 12) } @Test @@ -211,7 +211,7 @@ class MatchingDeclarationNameSpec { val findings = MatchingDeclarationName( TestConfig("mustBeFirst" to "false") ).lint(ktFile) - assertThat(findings).hasSourceLocation(3, 7) + assertThat(findings).hasStartSourceLocation(3, 7) } } } diff --git a/detekt-rules-naming/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/naming/NoNameShadowingSpec.kt b/detekt-rules-naming/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/naming/NoNameShadowingSpec.kt index e6f707169b9..ed16f59845b 100644 --- a/detekt-rules-naming/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/naming/NoNameShadowingSpec.kt +++ b/detekt-rules-naming/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/naming/NoNameShadowingSpec.kt @@ -19,7 +19,7 @@ class NoNameShadowingSpec(val env: KotlinCoreEnvironment) { """ val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) - assertThat(findings).hasSourceLocation(2, 9) + assertThat(findings).hasStartSourceLocation(2, 9) assertThat(findings[0]).hasMessage("Name shadowed: i") } diff --git a/detekt-rules-naming/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/naming/ObjectPropertyNamingSpec.kt b/detekt-rules-naming/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/naming/ObjectPropertyNamingSpec.kt index 3ab37272823..2c8dc13eb3b 100644 --- a/detekt-rules-naming/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/naming/ObjectPropertyNamingSpec.kt +++ b/detekt-rules-naming/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/naming/ObjectPropertyNamingSpec.kt @@ -64,7 +64,7 @@ class ObjectPropertyNamingSpec { ${PublicConst.positive} } """ - assertThat(subject.compileAndLint(code)).hasSourceLocation(2, 15) + assertThat(subject.compileAndLint(code)).hasStartSourceLocation(2, 15) } } @@ -130,7 +130,7 @@ class ObjectPropertyNamingSpec { } } """ - assertThat(subject.compileAndLint(code)).hasSourceLocation(3, 19) + assertThat(subject.compileAndLint(code)).hasStartSourceLocation(3, 19) } } 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 a32decb4ed0..1102c0eb9fb 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 @@ -189,8 +189,7 @@ class ForbiddenMethodCallSpec(val env: KotlinCoreEnvironment) { val findings = ForbiddenMethodCall( TestConfig(mapOf(METHODS to listOf("java.time.LocalDate.now()"))) ).compileAndLintWithContext(env, code) - assertThat(findings).hasSize(1) - assertThat(findings).hasSourceLocation(5, 26) + assertThat(findings).hasStartSourceLocation(5, 26) assertThat(findings[0]) .hasMessage("The method `java.time.LocalDate.now()` has been forbidden in the detekt config.") } @@ -210,7 +209,7 @@ class ForbiddenMethodCallSpec(val env: KotlinCoreEnvironment) { TestConfig(mapOf(METHODS to listOf("java.time.LocalDate.now(java.time.Clock)"))) ).compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) - assertThat(findings).hasSourceLocation(6, 27) + assertThat(findings).hasStartSourceLocation(6, 27) } @Test @@ -225,7 +224,7 @@ class ForbiddenMethodCallSpec(val env: KotlinCoreEnvironment) { TestConfig(mapOf(METHODS to listOf("java.time.LocalDate.of(kotlin.Int, kotlin.Int, kotlin.Int)"))) ).compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) - assertThat(findings).hasSourceLocation(3, 26) + assertThat(findings).hasStartSourceLocation(3, 26) } @Test @@ -240,7 +239,7 @@ class ForbiddenMethodCallSpec(val env: KotlinCoreEnvironment) { TestConfig(mapOf(METHODS to listOf("java.time.LocalDate.of(kotlin.Int,kotlin.Int,kotlin.Int)"))) ).compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) - assertThat(findings).hasSourceLocation(3, 26) + assertThat(findings).hasStartSourceLocation(3, 26) } @Test @@ -258,7 +257,7 @@ class ForbiddenMethodCallSpec(val env: KotlinCoreEnvironment) { TestConfig(mapOf(METHODS to listOf("io.gitlab.arturbosch.detekt.rules.style.`some, test`()"))) ).compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) - assertThat(findings).hasSourceLocation(6, 13) + assertThat(findings).hasStartSourceLocation(6, 13) } @Test @@ -281,7 +280,7 @@ class ForbiddenMethodCallSpec(val env: KotlinCoreEnvironment) { ) ).compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) - assertThat(findings).hasSourceLocation(6, 13) + assertThat(findings).hasStartSourceLocation(6, 13) } @Test @@ -420,7 +419,7 @@ class ForbiddenMethodCallSpec(val env: KotlinCoreEnvironment) { ).compileAndLintWithContext(env, code) assertThat(findings) .hasSize(1) - .hasSourceLocation(5, 16) + .hasStartSourceLocation(5, 16) } @Test @@ -430,7 +429,7 @@ class ForbiddenMethodCallSpec(val env: KotlinCoreEnvironment) { ).compileAndLintWithContext(env, code) assertThat(findings) .hasSize(1) - .hasSourceLocation(6, 9) + .hasStartSourceLocation(6, 9) } } diff --git a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/ForbiddenSuppressSpec.kt b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/ForbiddenSuppressSpec.kt index 668b7c94147..3fd6714e5c4 100644 --- a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/ForbiddenSuppressSpec.kt +++ b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/ForbiddenSuppressSpec.kt @@ -24,7 +24,7 @@ internal class ForbiddenSuppressSpec { """ val findings = subject.compileAndLint(code) assertThat(findings).hasSize(1) - assertThat(findings).hasSourceLocation(3, 1) + assertThat(findings).hasStartSourceLocation(3, 1) assertThat(findings.first()).hasMessage( "Cannot @Suppress rule \"ARule\" due to the current configuration." ) @@ -38,7 +38,7 @@ internal class ForbiddenSuppressSpec { """ val findings = subject.compileAndLint(code) assertThat(findings).hasSize(1) - assertThat(findings).hasSourceLocation(1, 1) + assertThat(findings).hasStartSourceLocation(1, 1) assertThat(findings.first()).hasMessage( "Cannot @Suppress rule \"ARule\" due to the current configuration." ) @@ -54,7 +54,7 @@ internal class ForbiddenSuppressSpec { """ val findings = subject.compileAndLint(code) assertThat(findings).hasSize(1) - assertThat(findings).hasSourceLocation(3, 1) + assertThat(findings).hasStartSourceLocation(3, 1) assertThat(findings.first()).hasMessage( "Cannot @Suppress rule \"ARule\" due to the current configuration." ) @@ -72,7 +72,7 @@ internal class ForbiddenSuppressSpec { """ val findings = subject.compileAndLint(code) assertThat(findings).hasSize(1) - assertThat(findings).hasSourceLocation(4, 5) + assertThat(findings).hasStartSourceLocation(4, 5) assertThat(findings.first()).hasMessage( "Cannot @Suppress rule \"ARule\" due to the current configuration." ) @@ -133,7 +133,7 @@ internal class ForbiddenSuppressSpec { """ val findings = subject.compileAndLint(code) assertThat(findings).hasSize(1) - assertThat(findings).hasSourceLocation(1, 1) + assertThat(findings).hasStartSourceLocation(1, 1) assertThat(findings.first()).hasMessage( "Cannot @Suppress rules \"ARule\", \"BRule\" " + "due to the current configuration." @@ -150,7 +150,7 @@ internal class ForbiddenSuppressSpec { """ val findings = subject.compileAndLint(code) assertThat(findings).hasSize(1) - assertThat(findings).hasSourceLocation(3, 1) + assertThat(findings).hasStartSourceLocation(3, 1) assertThat(findings.first()).hasMessage( "Cannot @Suppress rule \"BRule\" due to the current configuration." ) 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 9a17346044f..ea9d7c09b4b 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 @@ -39,7 +39,7 @@ class MagicNumberSpec { @Test fun `should be reported when ignoredNumbers is empty`() { val findings = MagicNumber(TestConfig(mapOf(IGNORE_NUMBERS to emptyList()))).lint(code) - assertThat(findings).hasSourceLocation(1, 15) + assertThat(findings).hasStartSourceLocation(1, 15) } } @@ -73,7 +73,7 @@ class MagicNumberSpec { @Test fun `should be reported when ignoredNumbers is empty`() { val findings = MagicNumber(TestConfig(mapOf(IGNORE_NUMBERS to emptyList()))).lint(code) - assertThat(findings).hasSourceLocation(1, 13) + assertThat(findings).hasStartSourceLocation(1, 13) } } @@ -107,7 +107,7 @@ class MagicNumberSpec { @Test fun `should be reported when ignoredNumbers is empty`() { val findings = MagicNumber(TestConfig(mapOf(IGNORE_NUMBERS to emptyList()))).lint(code) - assertThat(findings).hasSourceLocation(1, 14) + assertThat(findings).hasStartSourceLocation(1, 14) } } @@ -124,7 +124,7 @@ class MagicNumberSpec { @Test fun `should be reported when ignoredNumbers is empty`() { val findings = MagicNumber(TestConfig(mapOf(IGNORE_NUMBERS to emptyList()))).lint(code) - assertThat(findings).hasSourceLocation(1, 15) + assertThat(findings).hasStartSourceLocation(1, 15) } } @@ -135,7 +135,7 @@ class MagicNumberSpec { @Test fun `should be reported by default`() { val findings = MagicNumber().lint(code) - assertThat(findings).hasSourceLocation(1, 15) + assertThat(findings).hasStartSourceLocation(1, 15) } @Test @@ -154,14 +154,14 @@ class MagicNumberSpec { fun `should not be ignored when ignoredNumbers contains 2 but not -2`() { val findings = MagicNumber(TestConfig(mapOf(IGNORE_NUMBERS to listOf("1", "2", "3", "-1", "0")))) .lint(code) - assertThat(findings).hasSourceLocation(1, 15) + assertThat(findings).hasStartSourceLocation(1, 15) } @Test fun `should not be ignored when ignoredNumbers contains 2 but not -2 config with string`() { val findings = MagicNumber(TestConfig(mapOf(IGNORE_NUMBERS to "1,2,3,-1,0"))) .lint(code) - assertThat(findings).hasSourceLocation(1, 15) + assertThat(findings).hasStartSourceLocation(1, 15) } } @@ -195,7 +195,7 @@ class MagicNumberSpec { @Test fun `should be reported when ignoredNumbers is empty`() { val findings = MagicNumber(TestConfig(mapOf(IGNORE_NUMBERS to emptyList()))).lint(code) - assertThat(findings).hasSourceLocation(1, 16) + assertThat(findings).hasStartSourceLocation(1, 16) } } @@ -229,7 +229,7 @@ class MagicNumberSpec { @Test fun `should be reported when ignoredNumbers is empty`() { val findings = MagicNumber(TestConfig(mapOf(IGNORE_NUMBERS to emptyList()))).lint(code) - assertThat(findings).hasSourceLocation(1, 13) + assertThat(findings).hasStartSourceLocation(1, 13) } } @@ -291,7 +291,7 @@ class MagicNumberSpec { @Test fun `should be reported by default`() { val findings = MagicNumber().lint(code) - assertThat(findings).hasSourceLocation(1, 13) + assertThat(findings).hasStartSourceLocation(1, 13) } @Test @@ -405,7 +405,7 @@ class MagicNumberSpec { @Test fun `should be reported by default`() { val findings = MagicNumber().lint(code) - assertThat(findings).hasSourceLocation(1, 12) + assertThat(findings).hasStartSourceLocation(1, 12) } @Test @@ -601,7 +601,7 @@ class MagicNumberSpec { ) val findings = MagicNumber(config).lint(code) - assertThat(findings).hasSourceLocation(4, 35) + assertThat(findings).hasStartSourceLocation(4, 35) } @Test diff --git a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/NewLineAtEndOfFileSpec.kt b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/NewLineAtEndOfFileSpec.kt index 85d79712cd3..b1cf36d45ca 100644 --- a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/NewLineAtEndOfFileSpec.kt +++ b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/NewLineAtEndOfFileSpec.kt @@ -18,7 +18,7 @@ class NewLineAtEndOfFileSpec { fun `should flag a kt file not containing new line at the end`() { val code = "class Test" assertThat(subject.compileAndLint(code)).hasSize(1) - .hasSourceLocation(1, 11) + .hasStartSourceLocation(1, 11) } @Test 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 4ff47a08ef0..b1e473ff260 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 @@ -22,7 +22,7 @@ class ProtectedMemberInFinalClassSpec { """ val findings = subject.compileAndLint(code) assertThat(findings).hasSize(1) - assertThat(findings).hasSourceLocation(2, 5) + assertThat(findings).hasStartSourceLocation(2, 5) } @Test @@ -37,7 +37,7 @@ class ProtectedMemberInFinalClassSpec { """ val findings = subject.compileAndLint(code) assertThat(findings).hasSize(1) - assertThat(findings).hasSourceLocation(3, 5) + assertThat(findings).hasStartSourceLocation(3, 5) } @Test @@ -49,7 +49,7 @@ class ProtectedMemberInFinalClassSpec { """ val findings = subject.compileAndLint(code) assertThat(findings).hasSize(1) - assertThat(findings).hasSourceLocation(2, 5) + assertThat(findings).hasStartSourceLocation(2, 5) } @Test @@ -63,7 +63,7 @@ class ProtectedMemberInFinalClassSpec { """ val findings = subject.compileAndLint(code) assertThat(findings).hasSize(1) - assertThat(findings).hasSourceLocation(3, 9) + assertThat(findings).hasStartSourceLocation(3, 9) } @Test @@ -116,7 +116,7 @@ class ProtectedMemberInFinalClassSpec { """ val findings = subject.compileAndLint(code) assertThat(findings).hasSize(1) - assertThat(findings).hasSourceLocation(4, 13) + assertThat(findings).hasStartSourceLocation(4, 13) } @Test @@ -130,7 +130,7 @@ class ProtectedMemberInFinalClassSpec { """ val findings = subject.compileAndLint(code) assertThat(findings).hasSize(1) - assertThat(findings).hasSourceLocation(3, 9) + assertThat(findings).hasStartSourceLocation(3, 9) } @Test @@ -140,7 +140,7 @@ class ProtectedMemberInFinalClassSpec { """ val findings = subject.compileAndLint(code) assertThat(findings).hasSize(1) - assertThat(findings).hasSourceLocation(1, 42) + assertThat(findings).hasStartSourceLocation(1, 42) } } diff --git a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/RedundantHigherOrderMapUsageSpec.kt b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/RedundantHigherOrderMapUsageSpec.kt index d73d3da6269..6d562f0f2e1 100644 --- a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/RedundantHigherOrderMapUsageSpec.kt +++ b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/RedundantHigherOrderMapUsageSpec.kt @@ -24,7 +24,7 @@ class RedundantHigherOrderMapUsageSpec(val env: KotlinCoreEnvironment) { """ val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) - assertThat(findings).hasSourceLocation(4, 10) + assertThat(findings).hasStartSourceLocation(4, 10) assertThat(findings[0]).hasMessage("This 'map' call can be removed.") } @@ -44,7 +44,7 @@ class RedundantHigherOrderMapUsageSpec(val env: KotlinCoreEnvironment) { """ val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) - assertThat(findings).hasSourceLocation(5, 10) + assertThat(findings).hasStartSourceLocation(5, 10) assertThat(findings[0]).hasMessage("This 'map' call can be replaced with 'onEach' or 'forEach'.") } diff --git a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/UnnecessaryAbstractClassSpec.kt b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/UnnecessaryAbstractClassSpec.kt index d9b65a797bd..b6b2066444c 100644 --- a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/UnnecessaryAbstractClassSpec.kt +++ b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/UnnecessaryAbstractClassSpec.kt @@ -31,7 +31,7 @@ class UnnecessaryAbstractClassSpec(val env: KotlinCoreEnvironment) { """ val findings = subject.compileAndLintWithContext(env, code) assertFindingMessage(findings, message) - assertThat(findings).hasSourceLocation(1, 16) + assertThat(findings).hasStartSourceLocation(1, 16) } @Nested @@ -41,7 +41,7 @@ class UnnecessaryAbstractClassSpec(val env: KotlinCoreEnvironment) { val code = "abstract class A" val findings = subject.compileAndLintWithContext(env, code) assertFindingMessage(findings, message) - assertThat(findings).hasSourceLocation(1, 16) + assertThat(findings).hasStartSourceLocation(1, 16) } @Test @@ -204,7 +204,7 @@ class UnnecessaryAbstractClassSpec(val env: KotlinCoreEnvironment) { val code = "abstract class A(val i: Int)" val findings = subject.compileAndLintWithContext(env, code) assertFindingMessage(findings, message) - assertThat(findings).hasSourceLocation(1, 16) + assertThat(findings).hasStartSourceLocation(1, 16) } @Test @@ -219,7 +219,7 @@ class UnnecessaryAbstractClassSpec(val env: KotlinCoreEnvironment) { val code = "abstract class A(i: Int)" val findings = subject.compileAndLintWithContext(env, code) assertFindingMessage(findings, message) - assertThat(findings).hasSourceLocation(1, 16) + assertThat(findings).hasStartSourceLocation(1, 16) } @Test diff --git a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/UnusedPrivateClassSpec.kt b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/UnusedPrivateClassSpec.kt index 84cc5bacf1d..ff7a305e5d1 100644 --- a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/UnusedPrivateClassSpec.kt +++ b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/UnusedPrivateClassSpec.kt @@ -23,7 +23,7 @@ class UnusedPrivateClassSpec { val findings = subject.compileAndLint(code) assertThat(findings).hasSize(1) - assertThat(findings).hasSourceLocation(1, 1) + assertThat(findings).hasStartSourceLocation(1, 1) } @Nested @@ -39,7 +39,7 @@ class UnusedPrivateClassSpec { val findings = subject.compileAndLint(code) assertThat(findings).hasSize(1) - assertThat(findings).hasSourceLocation(1, 1) + assertThat(findings).hasStartSourceLocation(1, 1) } @Test @@ -52,7 +52,7 @@ class UnusedPrivateClassSpec { val findings = subject.compileAndLint(code) assertThat(findings).hasSize(1) - assertThat(findings).hasSourceLocation(2, 1) + assertThat(findings).hasStartSourceLocation(2, 1) } @Test @@ -435,7 +435,7 @@ class UnusedPrivateClassSpec { """ val findings = UnusedPrivateClass().lint(code) assertThat(findings).hasSize(1) - assertThat(findings).hasSourceLocation(10, 5) + assertThat(findings).hasStartSourceLocation(10, 5) } } } 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 b81acf5ea82..f7e39e0cb5d 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 @@ -1606,7 +1606,7 @@ class UnusedPrivateMemberSpec(val env: KotlinCoreEnvironment) { private fun foo() = 1 } """ - assertThat(subject.lint(code)).hasSize(1).hasSourceLocation(5, 17) + assertThat(subject.lint(code)).hasSize(1).hasStartSourceLocation(5, 17) } @Test @@ -1619,7 +1619,7 @@ class UnusedPrivateMemberSpec(val env: KotlinCoreEnvironment) { private val foo = 1 } """ - assertThat(subject.lint(code)).hasSize(1).hasSourceLocation(5, 17) + assertThat(subject.lint(code)).hasSize(1).hasStartSourceLocation(5, 17) } @Test @@ -1634,7 +1634,7 @@ class UnusedPrivateMemberSpec(val env: KotlinCoreEnvironment) { ) = 1 } """ - assertThat(subject.lint(code)).hasSize(1).hasSourceLocation(6, 9) + assertThat(subject.lint(code)).hasSize(1).hasStartSourceLocation(6, 9) } } } diff --git a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/UseCheckOrErrorSpec.kt b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/UseCheckOrErrorSpec.kt index 28d7ff8e727..3e67126601f 100644 --- a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/UseCheckOrErrorSpec.kt +++ b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/UseCheckOrErrorSpec.kt @@ -22,7 +22,7 @@ class UseCheckOrErrorSpec(val env: KotlinCoreEnvironment) { if (a < 0) throw IllegalStateException() } """ - assertThat(subject.lint(code)).hasSourceLocation(3, 16) + assertThat(subject.lint(code)).hasStartSourceLocation(3, 16) } @Test @@ -33,7 +33,7 @@ class UseCheckOrErrorSpec(val env: KotlinCoreEnvironment) { if (a < 0) throw IllegalStateException("More details") } """ - assertThat(subject.lint(code)).hasSourceLocation(3, 16) + assertThat(subject.lint(code)).hasStartSourceLocation(3, 16) } @Test @@ -45,7 +45,7 @@ class UseCheckOrErrorSpec(val env: KotlinCoreEnvironment) { else -> throw IllegalStateException() } """ - assertThat(subject.lint(code)).hasSourceLocation(4, 17) + assertThat(subject.lint(code)).hasStartSourceLocation(4, 17) } @Test @@ -56,7 +56,7 @@ class UseCheckOrErrorSpec(val env: KotlinCoreEnvironment) { if (a < 0) throw java.lang.IllegalStateException() } """ - assertThat(subject.lint(code)).hasSourceLocation(3, 16) + assertThat(subject.lint(code)).hasStartSourceLocation(3, 16) } @Test @@ -67,7 +67,7 @@ class UseCheckOrErrorSpec(val env: KotlinCoreEnvironment) { if (a < 0) throw kotlin.IllegalStateException() } """ - assertThat(subject.lint(code)).hasSourceLocation(3, 16) + assertThat(subject.lint(code)).hasStartSourceLocation(3, 16) } @Test @@ -106,13 +106,13 @@ class UseCheckOrErrorSpec(val env: KotlinCoreEnvironment) { @Test fun `reports an issue if the exception thrown as the only action in a function`() { val code = """fun doThrow() = throw IllegalStateException("message")""" - assertThat(subject.lint(code)).hasSourceLocation(1, 17) + assertThat(subject.lint(code)).hasStartSourceLocation(1, 17) } @Test fun `reports an issue if the exception thrown as the only action in a function block`() { val code = """fun doThrow() { throw IllegalStateException("message") }""" - assertThat(subject.lint(code)).hasSourceLocation(1, 17) + assertThat(subject.lint(code)).hasStartSourceLocation(1, 17) } @Test diff --git a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/UseIfEmptyOrIfBlankSpec.kt b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/UseIfEmptyOrIfBlankSpec.kt index 539199c3f69..6955ff5e479 100644 --- a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/UseIfEmptyOrIfBlankSpec.kt +++ b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/UseIfEmptyOrIfBlankSpec.kt @@ -26,7 +26,7 @@ class UseIfEmptyOrIfBlankSpec(val env: KotlinCoreEnvironment) { """ val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) - assertThat(findings).hasSourceLocation(4, 29) + assertThat(findings).hasStartSourceLocation(4, 29) assertThat(findings[0]).hasMessage("This 'isBlank' call can be replaced with 'ifBlank'") } @@ -45,7 +45,7 @@ class UseIfEmptyOrIfBlankSpec(val env: KotlinCoreEnvironment) { """ val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) - assertThat(findings).hasSourceLocation(4, 29) + assertThat(findings).hasStartSourceLocation(4, 29) assertThat(findings[0]).hasMessage("This 'isNotBlank' call can be replaced with 'ifBlank'") } @@ -61,7 +61,7 @@ class UseIfEmptyOrIfBlankSpec(val env: KotlinCoreEnvironment) { """ val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) - assertThat(findings).hasSourceLocation(4, 29) + assertThat(findings).hasStartSourceLocation(4, 29) assertThat(findings[0]).hasMessage("This 'isEmpty' call can be replaced with 'ifEmpty'") } @@ -80,7 +80,7 @@ class UseIfEmptyOrIfBlankSpec(val env: KotlinCoreEnvironment) { """ val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) - assertThat(findings).hasSourceLocation(4, 29) + assertThat(findings).hasStartSourceLocation(4, 29) assertThat(findings[0]).hasMessage("This 'isNotEmpty' call can be replaced with 'ifEmpty'") } diff --git a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/UseIsNullOrEmptySpec.kt b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/UseIsNullOrEmptySpec.kt index a0e43605232..b7a6f6844ca 100644 --- a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/UseIsNullOrEmptySpec.kt +++ b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/UseIsNullOrEmptySpec.kt @@ -24,7 +24,7 @@ class UseIsNullOrEmptySpec(val env: KotlinCoreEnvironment) { """ val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) - assertThat(findings).hasSourceLocation(2, 9) + assertThat(findings).hasStartSourceLocation(2, 9) assertThat(findings[0]).hasMessage( "This 'x == null || x.isEmpty()' can be replaced with 'isNullOrEmpty()' call" ) diff --git a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/UseOrEmptySpec.kt b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/UseOrEmptySpec.kt index ea9b2900b85..09d1466dcd2 100644 --- a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/UseOrEmptySpec.kt +++ b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/UseOrEmptySpec.kt @@ -22,7 +22,7 @@ class UseOrEmptySpec(val env: KotlinCoreEnvironment) { """ val findings = subject.compileAndLintWithContext(env, code) assertThat(findings).hasSize(1) - assertThat(findings).hasSourceLocation(2, 13) + assertThat(findings).hasStartSourceLocation(2, 13) assertThat(findings[0]).hasMessage("This '?: emptyList()' can be replaced with 'orEmpty()' call") } diff --git a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/UseRequireSpec.kt b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/UseRequireSpec.kt index 84d11edcc85..a726d9e96c9 100644 --- a/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/UseRequireSpec.kt +++ b/detekt-rules-style/src/test/kotlin/io/gitlab/arturbosch/detekt/rules/style/UseRequireSpec.kt @@ -22,7 +22,7 @@ class UseRequireSpec(val env: KotlinCoreEnvironment) { doSomething() } """ - assertThat(subject.lint(code)).hasSourceLocation(2, 16) + assertThat(subject.lint(code)).hasStartSourceLocation(2, 16) } @Test @@ -33,7 +33,7 @@ class UseRequireSpec(val env: KotlinCoreEnvironment) { doSomething() } """ - assertThat(subject.lint(code)).hasSourceLocation(2, 16) + assertThat(subject.lint(code)).hasStartSourceLocation(2, 16) } @Test @@ -44,7 +44,7 @@ class UseRequireSpec(val env: KotlinCoreEnvironment) { doSomething() } """ - assertThat(subject.lint(code)).hasSourceLocation(2, 16) + assertThat(subject.lint(code)).hasStartSourceLocation(2, 16) } @Test @@ -55,7 +55,7 @@ class UseRequireSpec(val env: KotlinCoreEnvironment) { doSomething() } """ - assertThat(subject.lint(code)).hasSourceLocation(2, 16) + assertThat(subject.lint(code)).hasStartSourceLocation(2, 16) } @Test diff --git a/detekt-test/src/main/kotlin/io/gitlab/arturbosch/detekt/test/FindingsAssertions.kt b/detekt-test/src/main/kotlin/io/gitlab/arturbosch/detekt/test/FindingsAssertions.kt index 1ab48ed38ca..3297cf7c5d7 100644 --- a/detekt-test/src/main/kotlin/io/gitlab/arturbosch/detekt/test/FindingsAssertions.kt +++ b/detekt-test/src/main/kotlin/io/gitlab/arturbosch/detekt/test/FindingsAssertions.kt @@ -6,7 +6,7 @@ import io.gitlab.arturbosch.detekt.api.TextLocation import org.assertj.core.api.AbstractAssert import org.assertj.core.api.AbstractListAssert import org.assertj.core.util.CheckReturnValue -import java.util.* +import java.util.Objects @CheckReturnValue fun assertThat(findings: List) = FindingsAssert(findings)