Skip to content

Commit 127809b

Browse files
Address several small lint warning throughout the app (#6233)
1 parent ca13e61 commit 127809b

File tree

20 files changed

+34
-52
lines changed

20 files changed

+34
-52
lines changed

app/src/main/kotlin/com/x8bit/bitwarden/data/auth/manager/AuthRequestManagerImpl.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ import kotlinx.coroutines.flow.flow
2828
import kotlinx.coroutines.isActive
2929
import java.time.Clock
3030
import javax.inject.Singleton
31-
import kotlin.coroutines.coroutineContext
3231

3332
private const val PASSWORDLESS_NOTIFICATION_TIMEOUT_MILLIS: Long = 15L * 60L * 1_000L
3433
private const val PASSWORDLESS_NOTIFICATION_RETRY_INTERVAL_MILLIS: Long = 4L * 1_000L
@@ -163,7 +162,7 @@ class AuthRequestManagerImpl(
163162
emit(result)
164163
if (result is AuthRequestUpdatesResult.Error) return@flow
165164
var isComplete = false
166-
while (coroutineContext.isActive && !isComplete) {
165+
while (currentCoroutineContext().isActive && !isComplete) {
167166
delay(PASSWORDLESS_APPROVER_INTERVAL_MILLIS)
168167
val updateResult = result as AuthRequestUpdatesResult.Update
169168
authRequestsService

app/src/main/kotlin/com/x8bit/bitwarden/data/auth/repository/AuthRepositoryImpl.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1356,10 +1356,10 @@ class AuthRepositoryImpl(
13561356
)
13571357
.fold(
13581358
onSuccess = {
1359-
when (val json = it) {
1359+
when (it) {
13601360
VerifyEmailTokenResponseJson.Valid -> EmailTokenResult.Success
13611361
is VerifyEmailTokenResponseJson.Invalid -> {
1362-
EmailTokenResult.Error(message = json.message, error = null)
1362+
EmailTokenResult.Error(message = it.message, error = null)
13631363
}
13641364

13651365
VerifyEmailTokenResponseJson.TokenExpired -> EmailTokenResult.Expired

app/src/main/kotlin/com/x8bit/bitwarden/data/auth/util/CompleteRegistrationDataUtils.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package com.x8bit.bitwarden.data.auth.util
22

33
import android.content.Intent
4-
import android.net.Uri
4+
import androidx.core.net.toUri
55
import com.x8bit.bitwarden.data.platform.manager.model.CompleteRegistrationData
66

77
/**
@@ -14,7 +14,7 @@ fun Intent.getCompleteRegistrationDataIntentOrNull(): CompleteRegistrationData?
1414
newValue = "/",
1515
ignoreCase = true,
1616
)
17-
val uri = runCatching { Uri.parse(sanitizedUriString) }.getOrNull() ?: return null
17+
val uri = runCatching { sanitizedUriString.toUri() }.getOrNull() ?: return null
1818
uri.host ?: return null
1919
if (uri.path != "/finish-signup") return null
2020
val email = uri.getQueryParameter("email") ?: return null
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.x8bit.bitwarden.data.autofill.accessibility.util
22

33
import android.net.Uri
4+
import androidx.core.net.toUri
45
import com.bitwarden.annotation.OmitFromCoverage
56
import java.net.URISyntaxException
67

@@ -10,7 +11,7 @@ import java.net.URISyntaxException
1011
@OmitFromCoverage
1112
fun String.toUriOrNull(): Uri? =
1213
try {
13-
Uri.parse(this)
14-
} catch (e: URISyntaxException) {
14+
this.toUri()
15+
} catch (_: URISyntaxException) {
1516
null
1617
}

app/src/main/kotlin/com/x8bit/bitwarden/ui/auth/feature/enterprisesignon/EnterpriseSignOnViewModel.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package com.x8bit.bitwarden.ui.auth.feature.enterprisesignon
22

33
import android.net.Uri
44
import android.os.Parcelable
5+
import androidx.core.net.toUri
56
import androidx.lifecycle.SavedStateHandle
67
import androidx.lifecycle.viewModelScope
78
import com.bitwarden.data.repository.util.baseIdentityUrl
@@ -400,7 +401,7 @@ class EnterpriseSignOnViewModel @Inject constructor(
400401

401402
// Hide any dialog since we're about to launch a custom tab and could return without getting
402403
// a result due to user intervention
403-
sendAction(EnterpriseSignOnAction.Internal.OnGenerateUriForSsoResult(Uri.parse(uri)))
404+
sendAction(EnterpriseSignOnAction.Internal.OnGenerateUriForSsoResult(uri.toUri()))
404405
}
405406

406407
private fun showError(

app/src/main/kotlin/com/x8bit/bitwarden/ui/auth/feature/twofactorlogin/TwoFactorLoginViewModel.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ class TwoFactorLoginViewModel @Inject constructor(
185185
// The url should not be empty unless the environment is somehow not supported.
186186
authUrl
187187
?.let {
188-
sendEvent(event = TwoFactorLoginEvent.NavigateToDuo(uri = Uri.parse(it)))
188+
sendEvent(event = TwoFactorLoginEvent.NavigateToDuo(uri = it.toUri()))
189189
}
190190
?: mutableStateFlow.update {
191191
it.copy(

app/src/main/kotlin/com/x8bit/bitwarden/ui/vault/feature/item/util/CipherViewExtensions.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ private fun LoginUriView.toUriData() =
257257
isLaunchable = !uri.isNullOrBlank(),
258258
)
259259

260-
private fun Fido2Credential.getCreationDateText(clock: Clock): Text? =
260+
private fun Fido2Credential.getCreationDateText(clock: Clock): Text =
261261
BitwardenString.created_x.asText(
262262
this.creationDate.toFormattedDateTimeStyle(
263263
dateStyle = FormatStyle.MEDIUM,

app/src/main/kotlin/com/x8bit/bitwarden/ui/vault/feature/vault/util/VaultDataExtensions.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package com.x8bit.bitwarden.ui.vault.feature.vault.util
22

3-
import android.net.Uri
3+
import androidx.core.net.toUri
44
import com.bitwarden.collections.CollectionView
55
import com.bitwarden.ui.platform.components.icon.model.IconData
66
import com.bitwarden.ui.platform.resource.BitwardenDrawable
@@ -249,7 +249,7 @@ fun List<LoginUriView>?.toLoginIconData(
249249
uri = "http://$uri"
250250
}
251251

252-
val iconUri = Uri.parse(uri)
252+
val iconUri = uri.toUri()
253253
val hostname = iconUri.host
254254

255255
val url = "$baseIconUrl/$hostname/icon.png"

app/src/test/kotlin/com/x8bit/bitwarden/AutofillCallbackViewModelTest.kt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,9 +168,6 @@ class AutofillCallbackViewModelTest : BaseViewModelTest() {
168168
fun `on IntentReceived should emit FinishActivity when cipherID is extracted, vault unlocked, and cipherView not found`() =
169169
runTest {
170170
// Setup
171-
val cipherView: CipherView = mockk {
172-
every { id } returns "NEW CIPHER ID"
173-
}
174171
val totpCopyData = AutofillCallbackData(
175172
cipherId = CIPHER_ID,
176173
)

app/src/test/kotlin/com/x8bit/bitwarden/data/platform/manager/ReviewPromptManagerTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,6 @@ class ReviewPromptManagerTest {
143143
}
144144

145145
private const val USER_ID = "user_id"
146-
private val MOCK_USER_STATE = mockk<UserStateJson>() {
146+
private val MOCK_USER_STATE = mockk<UserStateJson> {
147147
every { activeUserId } returns USER_ID
148148
}

0 commit comments

Comments
 (0)