You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Private property delegation operators are marked as used when they are used.
Observed Behavior
Property delegation operator by (getValue, setValue) has false positives for UnusedPrivateMember.
Steps to Reproduce
I've created a unit test that fits into UnusedPrivateMemberSpec that triggers the false positive. Looking through the other tests, the public property should be enough to be considered used.
it("Does not report used getValue, setValue") {
val code = """
class Test {
var delegated by "Hello"
}
private operator fun String.getValue(test: Test, prop: KProperty<*>): String {
return "working"
}
private operator fun String.setValue(test: Test, prop: KProperty<*>, value: String) {
error("setValue")
}
""".trimIndent()
assertThat(subject.compileAndLintWithContext(env, code)).hasSize(0)
}
Context
I originally wanted to create delegate methods for ThreadLocal scoped to within my current file so I could use it like a regular variable, but after updating detekt it's now being flagged as an unused member.
Expected Behavior
Private property delegation operators are marked as used when they are used.
Observed Behavior
Property delegation operator
by
(getValue
,setValue
) has false positives forUnusedPrivateMember
.Steps to Reproduce
I've created a unit test that fits into
UnusedPrivateMemberSpec
that triggers the false positive. Looking through the other tests, the public property should be enough to be considered used.Context
I originally wanted to create delegate methods for
ThreadLocal
scoped to within my current file so I could use it like a regular variable, but after updating detekt it's now being flagged as an unused member.It is not being flagged in 1.5.1, b190e11
Bisect shows it was introduced here with the unused operator overload detection: 38c54c8
Your Environment
The text was updated successfully, but these errors were encountered: