-
-
Notifications
You must be signed in to change notification settings - Fork 777
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
UnusedImports: Lots of false positives #3074
Comments
I've just done a quick run and I was able to reproduce but only with type resolution enabled. |
Well, actually you don't need to import package kotlin.collections
@SinceKotlin("1.1") public actual typealias HashMap<K, V> = java.util.HashMap<K, V> I don't know if there's a good reason to keep that import. |
Thanks @BraisGabin it was just one very simple example. Here's another: import dagger.Module
import dagger.hilt.InstallIn
import dagger.hilt.components.SingletonComponent
@Module
@InstallIn(SingletonComponent::class)
object DbModule {
// other code exists here
} In this example all three imports are being reported, but they're being used. Actually every single import in the real file is being flagged by this rule now. |
I've done further investigations on this front. The offending commit is #3033 Currently the The problem is actually here: detekt/detekt-rules-style/src/main/kotlin/io/gitlab/arturbosch/detekt/rules/style/UnusedImports.kt Lines 75 to 82 in 1c6a7ea
The assumption in this code is that all the I advice we revert #3033 (to close this issue) and eventually reopen #3020. Ideally we should consider having |
Expected Behavior
java.util.HashMap
is not reported as unused, since the type is used in the function value parameter:Observed Behavior
java.util.HashMap
is reported as unused by UnusedImports rule.Steps to Reproduce
Run detekt with type resolution enabled on the code provided above.
Context
Lots of false positives in detekt 1.13.x.
Your Environment
The text was updated successfully, but these errors were encountered: