Skip to content

Commit

Permalink
Don't use hasSourceLocations
Browse files Browse the repository at this point in the history
  • Loading branch information
BraisGabin committed Jul 23, 2022
1 parent cd5d604 commit 735d9c2
Show file tree
Hide file tree
Showing 13 changed files with 43 additions and 43 deletions.
Expand Up @@ -129,15 +129,15 @@ class ComplexMethodSpec {
)
val subject = ComplexMethod(config)

assertThat(subject.lint(path)).hasSourceLocations(SourceLocation(43, 5))
assertThat(subject.lint(path)).hasStartSourceLocations(SourceLocation(43, 5))
}

@Test
fun `reports all complex methods`() {
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),
Expand Down Expand Up @@ -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()
Expand Down
Expand Up @@ -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
Expand Down
Expand Up @@ -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)
)
Expand Down
Expand Up @@ -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)
)
Expand All @@ -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))
}
}
Expand Up @@ -18,7 +18,7 @@ class VariableNamingSpec {
}
"""
assertThat(VariableNaming().compileAndLint(code))
.hasSourceLocations(
.hasStartSourceLocations(
SourceLocation(2, 17),
SourceLocation(3, 9),
SourceLocation(4, 9)
Expand Down Expand Up @@ -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)
)
Expand Down
Expand Up @@ -26,7 +26,7 @@ class ForbiddenMethodCallSpec(val env: KotlinCoreEnvironment) {

assertThat(findings)
.hasSize(2)
.hasSourceLocations(
.hasStartSourceLocations(
SourceLocation(2, 5),
SourceLocation(3, 5),
)
Expand Down
Expand Up @@ -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),
Expand All @@ -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),
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -616,7 +616,7 @@ class MagicNumberSpec {

val findings = MagicNumber(config).lint(code)
assertThat(findings)
.hasSourceLocations(
.hasStartSourceLocations(
SourceLocation(4, 35),
SourceLocation(5, 43)
)
Expand Down
Expand Up @@ -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))
}
}
}
Expand Up @@ -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)
)
}
Expand All @@ -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)
)
}
Expand All @@ -111,7 +111,7 @@ class MayBeConstSpec {
}
"""
subject.compileAndLint(code)
assertThat(subject.findings).hasSize(1).hasSourceLocations(
assertThat(subject.findings).hasSize(1).hasStartSourceLocations(
SourceLocation(2, 19)
)
}
Expand All @@ -126,7 +126,7 @@ class MayBeConstSpec {
}
"""
subject.compileAndLint(code)
assertThat(subject.findings).hasSize(1).hasSourceLocations(
assertThat(subject.findings).hasSize(1).hasStartSourceLocations(
SourceLocation(3, 13)
)
}
Expand All @@ -143,7 +143,7 @@ class MayBeConstSpec {
}
"""
subject.compileAndLint(code)
assertThat(subject.findings).hasSize(1).hasSourceLocations(
assertThat(subject.findings).hasSize(1).hasStartSourceLocations(
SourceLocation(3, 9)
)
}
Expand All @@ -159,7 +159,7 @@ class MayBeConstSpec {
}
"""
subject.compileAndLint(code)
assertThat(subject.findings).hasSize(1).hasSourceLocations(
assertThat(subject.findings).hasSize(1).hasStartSourceLocations(
SourceLocation(4, 13)
)
}
Expand All @@ -173,7 +173,7 @@ class MayBeConstSpec {
}
"""
subject.compileAndLint(code)
assertThat(subject.findings).hasSize(1).hasSourceLocations(
assertThat(subject.findings).hasSize(1).hasStartSourceLocations(
SourceLocation(3, 9)
)
}
Expand All @@ -187,7 +187,7 @@ class MayBeConstSpec {
}
"""
subject.compileAndLint(code)
assertThat(subject.findings).hasSize(1).hasSourceLocations(
assertThat(subject.findings).hasSize(1).hasStartSourceLocations(
SourceLocation(3, 9)
)
}
Expand All @@ -203,7 +203,7 @@ class MayBeConstSpec {
}
"""
subject.compileAndLint(code)
assertThat(subject.findings).hasSize(1).hasSourceLocations(
assertThat(subject.findings).hasSize(1).hasStartSourceLocations(
SourceLocation(5, 9)
)
}
Expand All @@ -217,7 +217,7 @@ class MayBeConstSpec {
}
"""
subject.compileAndLint(code)
assertThat(subject.findings).hasSize(1).hasSourceLocations(
assertThat(subject.findings).hasSize(1).hasStartSourceLocations(
SourceLocation(3, 17)
)
}
Expand Down Expand Up @@ -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)
Expand Down
Expand Up @@ -33,7 +33,7 @@ class ObjectLiteralToLambdaSpec {
subject.compileAndLintWithContext(env, code)
.assert()
.hasSize(1)
.hasSourceLocations(SourceLocation(4, 9))
.hasStartSourceLocations(SourceLocation(4, 9))
}

@Test
Expand All @@ -52,7 +52,7 @@ class ObjectLiteralToLambdaSpec {
subject.compileAndLintWithContext(env, code)
.assert()
.hasSize(1)
.hasSourceLocations(SourceLocation(5, 5))
.hasStartSourceLocations(SourceLocation(5, 5))
}

@Test
Expand All @@ -73,7 +73,7 @@ class ObjectLiteralToLambdaSpec {
subject.compileAndLintWithContext(env, code)
.assert()
.hasSize(1)
.hasSourceLocations(SourceLocation(6, 9))
.hasStartSourceLocations(SourceLocation(6, 9))
}

@Test
Expand All @@ -91,7 +91,7 @@ class ObjectLiteralToLambdaSpec {
subject.compileAndLintWithContext(env, code)
.assert()
.hasSize(1)
.hasSourceLocations(SourceLocation(4, 9))
.hasStartSourceLocations(SourceLocation(4, 9))
}

@Test
Expand All @@ -109,7 +109,7 @@ class ObjectLiteralToLambdaSpec {
subject.compileAndLintWithContext(env, code)
.assert()
.hasSize(1)
.hasSourceLocations(SourceLocation(5, 9))
.hasStartSourceLocations(SourceLocation(5, 9))
}

@Test
Expand All @@ -130,7 +130,7 @@ class ObjectLiteralToLambdaSpec {
subject.compileAndLintWithContext(env, code)
.assert()
.hasSize(1)
.hasSourceLocations(SourceLocation(7, 5))
.hasStartSourceLocations(SourceLocation(7, 5))
}

@Test
Expand All @@ -146,7 +146,7 @@ class ObjectLiteralToLambdaSpec {
subject.compileAndLintWithContext(env, code)
.assert()
.hasSize(1)
.hasSourceLocations(SourceLocation(4, 9))
.hasStartSourceLocations(SourceLocation(4, 9))
}
}

Expand Down Expand Up @@ -337,7 +337,7 @@ class ObjectLiteralToLambdaSpec {
subject.compileAndLintWithContext(env, code)
.assert()
.hasSize(1)
.hasSourceLocations(SourceLocation(1, 9))
.hasStartSourceLocations(SourceLocation(1, 9))
}

@Test
Expand All @@ -353,7 +353,7 @@ class ObjectLiteralToLambdaSpec {
subject.compileAndLintWithContext(env, code)
.assert()
.hasSize(1)
.hasSourceLocations(SourceLocation(2, 9))
.hasStartSourceLocations(SourceLocation(2, 9))
}

@Test
Expand Down Expand Up @@ -466,7 +466,7 @@ class ObjectLiteralToLambdaSpec {
subject.compileAndLintWithContext(env, code)
.assert()
.hasSize(1)
.hasSourceLocations(SourceLocation(6, 5))
.hasStartSourceLocations(SourceLocation(6, 5))
}

@Test
Expand All @@ -489,7 +489,7 @@ class ObjectLiteralToLambdaSpec {
subject.compileAndLintWithContext(env, code)
.assert()
.hasSize(1)
.hasSourceLocations(SourceLocation(7, 9))
.hasStartSourceLocations(SourceLocation(7, 9))
}

@Test
Expand Down Expand Up @@ -534,7 +534,7 @@ class ObjectLiteralToLambdaSpec {
subject.compileAndLintWithContext(env, code)
.assert()
.hasSize(1)
.hasSourceLocations(SourceLocation(5, 19))
.hasStartSourceLocations(SourceLocation(5, 19))
}
}
}
Expand Down
Expand Up @@ -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
Expand All @@ -87,7 +87,7 @@ class OptionalWhenBracesSpec {
"""
assertThat(subject.compileAndLint(code))
.hasSize(1)
.hasSourceLocations(SourceLocation(3, 9))
.hasStartSourceLocations(SourceLocation(3, 9))
}

@Nested
Expand Down
Expand Up @@ -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)
)
Expand All @@ -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)
Expand Down
Expand Up @@ -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)
)
}
Expand Down

0 comments on commit 735d9c2

Please sign in to comment.