-
-
Notifications
You must be signed in to change notification settings - Fork 771
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 rule: fix false positives when type resolution is enabled #3079
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_TLS Both of those variables sit in a companion object. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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