UnusedImports rule: fix false positives when type resolution is enabled#3079
UnusedImports rule: fix false positives when type resolution is enabled#3079arturbosch merged 4 commits intodetekt:masterfrom
Conversation
ef19c7a to
605119b
Compare
Codecov Report
@@ Coverage Diff @@
## master #3079 +/- ##
=========================================
Coverage 79.26% 79.26%
- Complexity 2563 2567 +4
=========================================
Files 432 434 +2
Lines 7726 7737 +11
Branches 1469 1470 +1
=========================================
+ Hits 6124 6133 +9
- Misses 816 817 +1
- Partials 786 787 +1
Continue to review full report at Codecov.
|
605119b to
5814446
Compare
|
Thanks @t-kameyama, that's a big improvement! Unfortunately I still have some false positives with type resolution enabled. Here import androidx.sqlite.db.SupportSQLiteDatabase
import androidx.sqlite.db.SupportSQLiteOpenHelper
import com.squareup.sqldelight.android.AndroidSqliteDriver
internal class DbOpenHelper : SupportSQLiteOpenHelper.Callback(DATABASE_VERSION) {
override fun onCreate(db: SupportSQLiteDatabase) {
val driver = AndroidSqliteDriver(db)
Database.Schema.create(driver)
}
}I also have annotations in another file which are used, but they're still being reported. |
|
Awesome :) A couple more, where the reference resolves to a companion object... Lots of code omitted here, but the import is reported when it's used like this: import com.bluelinelabs.conductor.RouterTransaction
RouterTransaction.with(DomainListController())That resolves to: class RouterTransaction {
companion object {
@JvmStatic
fun with(controller: Controller): RouterTransaction = RouterTransaction(controller)
}
}And another example, again, lots of code omitted: import okhttp3.ConnectionSpec
ConnectionSpec.MODERN_TLS
ConnectionSpec.COMPATIBLE_TLSBoth of those variables sit in a companion object. |
3flex
left a comment
There was a problem hiding this comment.
Amazing! I can enable the rule with TR enabled now.
Possibly there will be other cases that pop up but this resolves my initial issue.
|
Thanks for the fix @t-kameyama |
|
@cortinico |
|
@cortinico we can close #3077 now, right? |
Yup 👌 |
Closes #3074