Issue#67 Fix Code Analysis errors

This commit is contained in:
Gergely Hegedus 2022-05-31 12:31:28 +03:00
parent 99141c0f17
commit 8d60a37b16
16 changed files with 31 additions and 24 deletions

View file

@ -26,4 +26,4 @@ interface SharedMigrationTestRule : TestRule {
fun closeWhenFinished(db: SupportSQLiteDatabase)
fun closeWhenFinished(db: RoomDatabase)
}
}

View file

@ -6,8 +6,8 @@ import androidx.room.migration.AutoMigrationSpec
import androidx.sqlite.db.SupportSQLiteOpenHelper
import org.fnives.test.showcase.android.testutil.robolectric.RobolectricMigrationTestRule
inline fun <reified Database: RoomDatabase> SharedMigrationTestRule(
instrumentation: Instrumentation
inline fun <reified Database : RoomDatabase> SharedMigrationTestRule(
instrumentation: Instrumentation,
): SharedMigrationTestRule =
createAndroidClassOrRobolectric(
androidClassFactory = { androidClass ->
@ -22,9 +22,9 @@ inline fun <reified Database: RoomDatabase> SharedMigrationTestRule(
}
)
inline fun <reified Database: RoomDatabase> SharedMigrationTestRule(
inline fun <reified Database : RoomDatabase> SharedMigrationTestRule(
instrumentation: Instrumentation,
specs: List<AutoMigrationSpec>
specs: List<AutoMigrationSpec>,
): SharedMigrationTestRule =
createAndroidClassOrRobolectric(
androidClassFactory = { androidClass ->
@ -40,10 +40,10 @@ inline fun <reified Database: RoomDatabase> SharedMigrationTestRule(
}
)
inline fun <reified Database: RoomDatabase> SharedMigrationTestRule(
inline fun <reified Database : RoomDatabase> SharedMigrationTestRule(
instrumentation: Instrumentation,
specs: List<AutoMigrationSpec>,
openFactory: SupportSQLiteOpenHelper.Factory
openFactory: SupportSQLiteOpenHelper.Factory,
): SharedMigrationTestRule =
createAndroidClassOrRobolectric(
androidClassFactory = { androidClass ->
@ -62,7 +62,7 @@ inline fun <reified Database: RoomDatabase> SharedMigrationTestRule(
fun createAndroidClassOrRobolectric(
androidClassFactory: (Class<*>) -> Any,
robolectricFactory: () -> SharedMigrationTestRule
robolectricFactory: () -> SharedMigrationTestRule,
): SharedMigrationTestRule {
val androidClass = getAndroidClass()
return if (androidClass == null) {
@ -72,8 +72,9 @@ fun createAndroidClassOrRobolectric(
}
}
@Suppress("SwallowedException")
private fun getAndroidClass() = try {
Class.forName("org.fnives.test.showcase.android.testutil.AndroidMigrationTestRule")
} catch (classNotFoundException: ClassNotFoundException) {
null
}
}