Skip to content

Commit

Permalink
Make InvalidRange aware of rangeUntil operator (#6264)
Browse files Browse the repository at this point in the history
  • Loading branch information
3flex authored and cortinico committed Jul 15, 2023
1 parent efbcd94 commit 8687e2a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class InvalidRange(config: Config = Config.empty) : Rule(config) {
return when (range[1].text) {
".." -> checkRangeTo(lowerValue, upperValue)
"downTo" -> checkDownTo(lowerValue, upperValue)
"until" -> checkUntil(lowerValue, upperValue)
"until", "..<" -> checkUntil(lowerValue, upperValue)
else -> false
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class InvalidRangeSpec {
for (i in 2..2) {}
for (i in 2 downTo 2) {}
for (i in 2 until 3) {}
for (i in 2..<3) {}
for (i in 2 until 4 step 2) {}
for (i in (1+1)..3) { }
}
Expand All @@ -33,10 +34,11 @@ class InvalidRangeSpec {
for (i in 2..1) { }
for (i in 1 downTo 2) { }
for (i in 2 until 2) { }
for (i in 2..<2) { }
for (i in 2 until 1 step 2) { }
}
""".trimIndent()
assertThat(subject.compileAndLint(code)).hasSize(4)
assertThat(subject.compileAndLint(code)).hasSize(5)
}

@Test
Expand Down

0 comments on commit 8687e2a

Please sign in to comment.