Skip to content

Commit

Permalink
Ignore imports for rangeUntil in no-unused-imports rule (#2376)
Browse files Browse the repository at this point in the history
Removing this import results in compilation error when shorthand "..<" is used instead of function `rangeUntil(..)`.

Closes #2373
  • Loading branch information
paul-dingemans committed Nov 26, 2023
1 parent e5d944b commit 421cdbe
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ public class NoUnusedImportsRule : StandardRule("no-unused-imports") {
// inc/dec
"inc", "dec",
// arithmetic
"plus", "minus", "times", "div", "rem", "mod", "rangeTo",
"plus", "minus", "times", "div", "rem", "mod", "rangeTo", "rangeUntil",
// in
"contains",
// indexed access
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -841,4 +841,19 @@ class NoUnusedImportsRuleTest {
""".trimIndent()
noUnusedImportsRuleAssertThat(code).hasNoLintViolations()
}

@Test
fun `Issue 2373 - Do not mark rangeUntil as unused import`() {
val code =
"""
package com.example
// Assume that "com.example.Baz" defines a rangeUntil operator as follows:
// operator fun Baz.rangeUntil(baz: Baz) = ...
import com.example.Baz.rangeUntil
val baz = Baz(1.0)..<Baz(2.0)
""".trimIndent()
noUnusedImportsRuleAssertThat(code).hasNoLintViolations()
}
}

0 comments on commit 421cdbe

Please sign in to comment.