#3832 Remove unused code via Declaraction Redundancy>Unused Declaration Inspection - fix TextUtils usage

This commit is contained in:
Sean Mac Gillicuddy 2020-06-22 10:48:50 +01:00
parent f8f08f0f14
commit 2ad8663e24
3 changed files with 6 additions and 7 deletions

View file

@ -1,6 +1,5 @@
package fr.free.nrw.commons.category
import android.text.TextUtils
import fr.free.nrw.commons.upload.GpsCategoryModel
import fr.free.nrw.commons.upload.structure.depictions.DepictedItem
import fr.free.nrw.commons.utils.StringSortingUtils
@ -82,7 +81,7 @@ class CategoriesModel @Inject constructor(
imageTitleList: List<String>,
selectedDepictions: List<DepictedItem>
): Observable<List<String>> {
return if (TextUtils.isEmpty(term))
return if (term.isBlank())
Observable.combineLatest(
categoriesFromDepiction(selectedDepictions),
gpsCategoryModel.categoriesFromLocation,

View file

@ -1,6 +1,5 @@
package fr.free.nrw.commons.upload.categories
import android.text.TextUtils
import fr.free.nrw.commons.R
import fr.free.nrw.commons.category.CategoryItem
import fr.free.nrw.commons.di.CommonsApplicationModule
@ -84,7 +83,7 @@ class CategoriesPresenter @Inject constructor(
private fun getImageTitleList(): List<String> {
return repository.uploads
.map { it.uploadMediaDetails[0].captionText }
.filterNot { TextUtils.isEmpty(it) }
.filterNot { it.isBlank() }
}
/**

View file

@ -7,7 +7,6 @@ import android.database.MatrixCursor
import android.database.sqlite.SQLiteDatabase
import android.os.RemoteException
import com.nhaarman.mockitokotlin2.*
import fr.free.nrw.commons.BuildConfig
import fr.free.nrw.commons.TestCommonsApplication
import fr.free.nrw.commons.category.CategoryContentProvider.BASE_URI
import fr.free.nrw.commons.category.CategoryContentProvider.uriForId
@ -151,9 +150,11 @@ class CategoryDaoTest {
@Test(expected = RuntimeException::class)
fun testSaveTranslatesRemoteExceptions() {
whenever(client.insert(isA(), isA())).thenThrow(RemoteException(""))
testObject.save(Category())
testObject.save(category())
}
private fun category() = Category(null,null,null,0)
@Test
fun whenTheresNoDataFindReturnsNull_nullCursor() {
whenever(client.query(any(), any(), any(), any(), any())).thenReturn(null)
@ -268,4 +269,4 @@ class CategoryDaoTest {
}
}
}
}