Skip to content

Commit

Permalink
UnusedPrivateMember should not report external classes/interfaces (#4347
Browse files Browse the repository at this point in the history
)

* UnusedPrivateMember should not report external classes/interfaces

* Clarify the tests
  • Loading branch information
cortinico committed Dec 1, 2021
1 parent 5e34645 commit 9bfba9a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
Expand Up @@ -217,6 +217,7 @@ private class UnusedParameterVisitor(allowedNames: Regex) : UnusedMemberVisitor(

override fun visitClass(klass: KtClass) {
if (klass.isInterface()) return
if (klass.isExternal()) return

super.visitClass(klass)
}
Expand Down
Expand Up @@ -127,6 +127,21 @@ class UnusedPrivateMemberSpec : Spek({
}
}

describe("external classes") {

it("should not report functions in external classes") {
val code = """
external class Bugsnag {
companion object {
fun start(value: Int)
fun notify(error: String)
}
}
"""
assertThat(subject.lint(code)).isEmpty()
}
}

describe("protected functions") {

it("should not report parameters in protected functions") {
Expand Down

0 comments on commit 9bfba9a

Please sign in to comment.