Open Chris-Goetz opened 3 weeks ago
Below TC is passing though
@Test
fun `does report private logger property in top level`() {
val code = """
private val logger = 2
""".trimIndent()
assertThat(subject.lintWithContext(env, code))
.hasSize(1)
}
is your type resolution set properly?
Hi, sorry for the late answer, one of my Outlook filters has eaten up the notification.
I've tried to run 'detektMain' wich gave me a lot of new findings but the unused logger property was still ignored. Then I tried to assign the value '2' to logger, like in your test. That was found by both, the 'detekt' and the 'detektMain' task. After that, I tried to assing 'private val logger = Logger.getLogger("foo")' and that was also found.
It must have something to do with the 'KotlinLogging.logger {}'.
Expected Behavior
detekt should find unused properties for which no exception is defined.
Observed Behavior
detekt does not find unused properties named "logger".
Steps to Reproduce
Context
The documentation statesthe default allowed values are: allowedNames (default: '_|ignored|expected|serialVersionUID') - "logger" is not listed here. We also have no exceptions in our config for that rule defined:
Your Environment
Version of Gradle used (if applicable):
Gradle 8.6
Build time: 2024-02-02 16:47:16 UTC Revision: d55c486870a0dc6f6278f53d21381396d0741c6e
Kotlin: 1.9.20 Groovy: 3.0.17 Ant: Apache Ant(TM) version 1.10.13 compiled on January 4 2023 JVM: 17.0.10 (Private Build 17.0.10+7-Ubuntu-122.04.1) OS: Linux 6.5.0-28-generic amd64