Apply formatter to entire app (#4053)

This commit is contained in:
David Perez 2024-10-08 16:42:09 -05:00 committed by GitHub
parent 2af96988ab
commit 8a30f14dea
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
50 changed files with 170 additions and 165 deletions

View file

@ -11,7 +11,7 @@ val AuthRequestType.isSso: Boolean
AuthRequestType.OTHER_DEVICE -> false
AuthRequestType.SSO_OTHER_DEVICE,
AuthRequestType.SSO_ADMIN_APPROVAL,
-> true
-> true
}
/**
@ -21,7 +21,7 @@ fun AuthRequestType.toAuthRequestTypeJson(): AuthRequestTypeJson =
when (this) {
AuthRequestType.OTHER_DEVICE,
AuthRequestType.SSO_OTHER_DEVICE,
-> AuthRequestTypeJson.LOGIN_WITH_DEVICE
-> AuthRequestTypeJson.LOGIN_WITH_DEVICE
AuthRequestType.SSO_ADMIN_APPROVAL -> AuthRequestTypeJson.ADMIN_APPROVAL
}

View file

@ -998,7 +998,7 @@ class AuthRepositoryImpl(
ForcePasswordResetReason.ADMIN_FORCE_PASSWORD_RESET,
ForcePasswordResetReason.WEAK_MASTER_PASSWORD_ON_LOGIN,
null,
-> {
-> {
authSdkSource
.makeRegisterKeys(
email = activeAccount.profile.email,
@ -1048,7 +1048,7 @@ class AuthRepositoryImpl(
is VaultUnlockResult.AuthenticationError,
VaultUnlockResult.InvalidStateError,
VaultUnlockResult.GenericError,
-> {
-> {
IllegalStateException("Failed to unlock vault").asFailure()
}
}

View file

@ -11,5 +11,5 @@ fun VaultUnlockError.toLoginErrorResult(): LoginResult.Error = when (this) {
is VaultUnlockResult.AuthenticationError -> LoginResult.Error(this.message)
VaultUnlockResult.GenericError,
VaultUnlockResult.InvalidStateError,
-> LoginResult.Error(errorMessage = null)
-> LoginResult.Error(errorMessage = null)
}

View file

@ -1,6 +1,5 @@
package com.x8bit.bitwarden.data.auth.repository.model
import com.x8bit.bitwarden.data.vault.datasource.network.model.SyncResponseJson
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

View file

@ -176,12 +176,12 @@ val AuthDiskSource.activeUserIdChangesFlow: Flow<String?>
@OptIn(ExperimentalCoroutinesApi::class)
val AuthDiskSource.onboardingStatusChangesFlow: Flow<OnboardingStatus?>
get() = activeUserIdChangesFlow
.flatMapLatest { activeUserId ->
activeUserId
?.let { this.getOnboardingStatusFlow(userId = it) }
?: flowOf(null)
}
.distinctUntilChanged()
.flatMapLatest { activeUserId ->
activeUserId
?.let { this.getOnboardingStatusFlow(userId = it) }
?: flowOf(null)
}
.distinctUntilChanged()
val AuthDiskSource.currentOnboardingStatus: OnboardingStatus?
get() = this

View file

@ -55,9 +55,9 @@ class BiometricsEncryptionManagerImpl(
}
val cipher = try {
Cipher.getInstance(CIPHER_TRANSFORMATION)
} catch (e: NoSuchAlgorithmException) {
} catch (_: NoSuchAlgorithmException) {
return null
} catch (e: NoSuchPaddingException) {
} catch (_: NoSuchPaddingException) {
return null
}
// This should never fail to initialize / return false because the cipher is newly generated
@ -116,20 +116,20 @@ class BiometricsEncryptionManagerImpl(
KeyProperties.KEY_ALGORITHM_AES,
ENCRYPTION_KEYSTORE_NAME,
)
} catch (e: NoSuchAlgorithmException) {
} catch (_: NoSuchAlgorithmException) {
return null
} catch (e: NoSuchProviderException) {
} catch (_: NoSuchProviderException) {
return null
} catch (e: IllegalArgumentException) {
} catch (_: IllegalArgumentException) {
return null
}
try {
keyGen.init(keyGenParameterSpec)
keyGen.generateKey()
} catch (e: InvalidAlgorithmParameterException) {
} catch (_: InvalidAlgorithmParameterException) {
return null
} catch (e: ProviderException) {
} catch (_: ProviderException) {
return null
}
@ -142,29 +142,29 @@ class BiometricsEncryptionManagerImpl(
private fun getSecretKeyOrNull(): SecretKey? {
try {
keystore.load(null)
} catch (e: IllegalArgumentException) {
} catch (_: IllegalArgumentException) {
// keystore could not be loaded because [param] is unrecognized.
return null
} catch (e: IOException) {
} catch (_: IOException) {
// keystore data format is invalid or the password is incorrect.
return null
} catch (e: NoSuchAlgorithmException) {
} catch (_: NoSuchAlgorithmException) {
// keystore integrity could not be checked due to missing algorithm.
return null
} catch (e: CertificateException) {
} catch (_: CertificateException) {
// keystore certificates could not be loaded
return null
}
return try {
keystore.getKey(ENCRYPTION_KEY_NAME, null) as? SecretKey
} catch (e: KeyStoreException) {
} catch (_: KeyStoreException) {
// keystore was not loaded
null
} catch (e: NoSuchAlgorithmException) {
} catch (_: NoSuchAlgorithmException) {
// keystore algorithm cannot be found
null
} catch (e: UnrecoverableKeyException) {
} catch (_: UnrecoverableKeyException) {
// key could not be recovered
null
}
@ -181,15 +181,15 @@ class BiometricsEncryptionManagerImpl(
try {
cipher.init(Cipher.ENCRYPT_MODE, secretKey)
true
} catch (e: KeyPermanentlyInvalidatedException) {
} catch (_: KeyPermanentlyInvalidatedException) {
// Biometric has changed
settingsDiskSource.systemBiometricIntegritySource = null
false
} catch (e: UnrecoverableKeyException) {
} catch (_: UnrecoverableKeyException) {
// Biometric was disabled and re-enabled
settingsDiskSource.systemBiometricIntegritySource = null
false
} catch (e: InvalidKeyException) {
} catch (_: InvalidKeyException) {
// Fallback for old Bitwarden users without a key
createIntegrityValues(userId)
true

View file

@ -129,7 +129,7 @@ class PushManagerImpl @Inject constructor(
when (val type = notification.notificationType) {
NotificationType.AUTH_REQUEST,
NotificationType.AUTH_REQUEST_RESPONSE,
-> {
-> {
json
.decodeFromString<NotificationPayload.PasswordlessRequestNotification>(
string = notification.payload,
@ -156,7 +156,7 @@ class PushManagerImpl @Inject constructor(
NotificationType.SYNC_CIPHER_CREATE,
NotificationType.SYNC_CIPHER_UPDATE,
-> {
-> {
json
.decodeFromString<NotificationPayload.SyncCipherNotification>(
string = notification.payload,
@ -183,7 +183,7 @@ class PushManagerImpl @Inject constructor(
NotificationType.SYNC_CIPHER_DELETE,
NotificationType.SYNC_LOGIN_DELETE,
-> {
-> {
json
.decodeFromString<NotificationPayload.SyncCipherNotification>(
string = notification.payload,
@ -196,13 +196,13 @@ class PushManagerImpl @Inject constructor(
NotificationType.SYNC_CIPHERS,
NotificationType.SYNC_SETTINGS,
NotificationType.SYNC_VAULT,
-> {
-> {
mutableFullSyncSharedFlow.tryEmit(Unit)
}
NotificationType.SYNC_FOLDER_CREATE,
NotificationType.SYNC_FOLDER_UPDATE,
-> {
-> {
json
.decodeFromString<NotificationPayload.SyncFolderNotification>(
string = notification.payload,
@ -238,7 +238,7 @@ class PushManagerImpl @Inject constructor(
NotificationType.SYNC_SEND_CREATE,
NotificationType.SYNC_SEND_UPDATE,
-> {
-> {
json
.decodeFromString<NotificationPayload.SyncSendNotification>(
string = notification.payload,

View file

@ -19,6 +19,7 @@ class SpecialCircumstanceManagerImpl(
) : SpecialCircumstanceManager {
private val mutableSpecialCircumstanceFlow = MutableStateFlow<SpecialCircumstance?>(null)
private val unconfinedScope = CoroutineScope(dispatcherManager.unconfined)
init {
authRepository
.userStateFlow

View file

@ -20,8 +20,6 @@ import com.x8bit.bitwarden.data.platform.manager.AssetManager
import com.x8bit.bitwarden.data.platform.manager.AssetManagerImpl
import com.x8bit.bitwarden.data.platform.manager.BiometricsEncryptionManager
import com.x8bit.bitwarden.data.platform.manager.BiometricsEncryptionManagerImpl
import com.x8bit.bitwarden.data.platform.processor.AuthenticatorBridgeProcessor
import com.x8bit.bitwarden.data.platform.processor.AuthenticatorBridgeProcessorImpl
import com.x8bit.bitwarden.data.platform.manager.CrashLogsManager
import com.x8bit.bitwarden.data.platform.manager.CrashLogsManagerImpl
import com.x8bit.bitwarden.data.platform.manager.DebugMenuFeatureFlagManagerImpl
@ -51,6 +49,8 @@ import com.x8bit.bitwarden.data.platform.manager.garbage.GarbageCollectionManage
import com.x8bit.bitwarden.data.platform.manager.garbage.GarbageCollectionManagerImpl
import com.x8bit.bitwarden.data.platform.manager.restriction.RestrictionManager
import com.x8bit.bitwarden.data.platform.manager.restriction.RestrictionManagerImpl
import com.x8bit.bitwarden.data.platform.processor.AuthenticatorBridgeProcessor
import com.x8bit.bitwarden.data.platform.processor.AuthenticatorBridgeProcessorImpl
import com.x8bit.bitwarden.data.platform.repository.AuthenticatorBridgeRepository
import com.x8bit.bitwarden.data.platform.repository.DebugMenuRepository
import com.x8bit.bitwarden.data.platform.repository.EnvironmentRepository

View file

@ -75,7 +75,7 @@ class AuthenticatorBridgeRepositoryImpl(
is VaultUnlockResult.AuthenticationError,
VaultUnlockResult.GenericError,
VaultUnlockResult.InvalidStateError,
-> {
-> {
// Not being able to unlock the user's vault with the
// decrypted unlock key is an unexpected case, but if it does
// happen we omit the account from list of shared accounts

View file

@ -125,11 +125,11 @@ fun EnvironmentUrlDataJson.toEnvironmentUrls(): Environment =
when (this) {
EnvironmentUrlDataJson.DEFAULT_US,
EnvironmentUrlDataJson.DEFAULT_LEGACY_US,
-> Environment.Us
-> Environment.Us
EnvironmentUrlDataJson.DEFAULT_EU,
EnvironmentUrlDataJson.DEFAULT_LEGACY_EU,
-> Environment.Eu
-> Environment.Eu
else -> Environment.SelfHosted(environmentUrlData = this)
}

View file

@ -121,7 +121,7 @@ private fun parseDomainNameOrNullInternal(
val tldRange: IntRange? = when (largestMatch) {
is SuffixMatchType.Exception,
is SuffixMatchType.Normal,
-> {
-> {
host.findLastSubstringIndicesOrNull(largestMatch.partialDomain)
}

View file

@ -3,7 +3,6 @@ package com.x8bit.bitwarden.data.vault.datasource.sdk
import com.bitwarden.core.DateTime
import com.bitwarden.core.DerivePinKeyResponse
import com.bitwarden.core.InitOrgCryptoRequest
import com.bitwarden.core.InitUserCryptoMethod
import com.bitwarden.core.InitUserCryptoRequest
import com.bitwarden.core.UpdatePasswordResponse
import com.bitwarden.crypto.Kdf

View file

@ -489,7 +489,7 @@ class VaultLockManagerImpl(
// User no longer active or engaging with the app.
CheckTimeoutReason.APP_BACKGROUNDED,
CheckTimeoutReason.USER_CHANGED,
-> {
-> {
handleTimeoutActionWithDelay(
userId = userId,
vaultTimeoutAction = vaultTimeoutAction,

View file

@ -464,11 +464,11 @@ data class CompleteRegistrationState(
PasswordStrengthState.WEAK_1,
PasswordStrengthState.WEAK_2,
PasswordStrengthState.WEAK_3,
-> false
-> false
PasswordStrengthState.GOOD,
PasswordStrengthState.STRONG,
-> true
-> true
}
/**

View file

@ -415,11 +415,11 @@ data class CreateAccountState(
PasswordStrengthState.WEAK_1,
PasswordStrengthState.WEAK_2,
PasswordStrengthState.WEAK_3,
-> false
-> false
PasswordStrengthState.GOOD,
PasswordStrengthState.STRONG,
-> true
-> true
}
}

View file

@ -33,7 +33,7 @@ class EnvironmentViewModel @Inject constructor(
val environmentUrlData = when (val environment = environmentRepository.environment) {
Environment.Us,
Environment.Eu,
-> EnvironmentUrlDataJson(base = "")
-> EnvironmentUrlDataJson(base = "")
is Environment.SelfHosted -> environment.environmentUrlData
}

View file

@ -12,8 +12,8 @@ import javax.inject.Inject
class ExpiredRegistrationLinkViewModel @Inject constructor(
private val authRepository: AuthRepository,
) : BaseViewModel<Unit, ExpiredRegistrationLinkEvent, ExpiredRegistrationLinkAction>(
initialState = Unit,
) {
initialState = Unit,
) {
override fun handleAction(action: ExpiredRegistrationLinkAction) {
when (action) {
ExpiredRegistrationLinkAction.CloseClicked -> handleCloseClicked()

View file

@ -161,7 +161,7 @@ class LoginWithDeviceViewModel @Inject constructor(
when (state.loginWithDeviceType) {
LoginWithDeviceType.OTHER_DEVICE,
LoginWithDeviceType.SSO_OTHER_DEVICE,
-> {
-> {
mutableStateFlow.update {
it.copy(
viewState = LoginWithDeviceState.ViewState.Content(
@ -292,7 +292,7 @@ class LoginWithDeviceViewModel @Inject constructor(
LoginWithDeviceType.SSO_ADMIN_APPROVAL,
LoginWithDeviceType.SSO_OTHER_DEVICE,
-> {
-> {
authRepository.completeTdeLogin(
requestPrivateKey = loginData.privateKey,
asymmetricalKey = loginData.asymmetricalKey,
@ -352,7 +352,7 @@ data class LoginWithDeviceState(
get() = when (loginWithDeviceType) {
LoginWithDeviceType.OTHER_DEVICE,
LoginWithDeviceType.SSO_OTHER_DEVICE,
-> R.string.log_in_with_device.asText()
-> R.string.log_in_with_device.asText()
LoginWithDeviceType.SSO_ADMIN_APPROVAL -> R.string.log_in_initiated.asText()
}
@ -389,10 +389,10 @@ data class LoginWithDeviceState(
get() = when (loginWithDeviceType) {
LoginWithDeviceType.OTHER_DEVICE,
LoginWithDeviceType.SSO_OTHER_DEVICE,
-> R.string.log_in_initiated.asText()
-> R.string.log_in_initiated.asText()
LoginWithDeviceType.SSO_ADMIN_APPROVAL,
-> R.string.admin_approval_requested.asText()
-> R.string.admin_approval_requested.asText()
}
/**
@ -402,10 +402,10 @@ data class LoginWithDeviceState(
get() = when (loginWithDeviceType) {
LoginWithDeviceType.OTHER_DEVICE,
LoginWithDeviceType.SSO_OTHER_DEVICE,
-> R.string.a_notification_has_been_sent_to_your_device.asText()
-> R.string.a_notification_has_been_sent_to_your_device.asText()
LoginWithDeviceType.SSO_ADMIN_APPROVAL,
-> R.string.your_request_has_been_sent_to_your_admin.asText()
-> R.string.your_request_has_been_sent_to_your_admin.asText()
}
/**
@ -416,10 +416,10 @@ data class LoginWithDeviceState(
get() = when (loginWithDeviceType) {
LoginWithDeviceType.OTHER_DEVICE,
LoginWithDeviceType.SSO_OTHER_DEVICE,
-> R.string.please_make_sure_your_vault_is_unlocked_and_the_fingerprint_phrase_matches_on_the_other_device.asText()
-> R.string.please_make_sure_your_vault_is_unlocked_and_the_fingerprint_phrase_matches_on_the_other_device.asText()
LoginWithDeviceType.SSO_ADMIN_APPROVAL,
-> R.string.you_will_be_notified_once_approved.asText()
-> R.string.you_will_be_notified_once_approved.asText()
}
/**
@ -430,7 +430,7 @@ data class LoginWithDeviceState(
get() = when (loginWithDeviceType) {
LoginWithDeviceType.OTHER_DEVICE,
LoginWithDeviceType.SSO_OTHER_DEVICE,
-> R.string.log_in_with_device_must_be_set_up_in_the_settings_of_the_bitwarden_app_need_another_option.asText()
-> R.string.log_in_with_device_must_be_set_up_in_the_settings_of_the_bitwarden_app_need_another_option.asText()
LoginWithDeviceType.SSO_ADMIN_APPROVAL -> R.string.trouble_logging_in.asText()
}

View file

@ -202,7 +202,7 @@ class TwoFactorLoginViewModel @Inject constructor(
when (state.authMethod) {
TwoFactorAuthMethod.DUO,
TwoFactorAuthMethod.DUO_ORGANIZATION,
-> {
-> {
val authUrl = authRepository.twoFactorResponse.twoFactorDuoAuthUrl
// The url should not be empty unless the environment is somehow not supported.
authUrl
@ -256,7 +256,7 @@ class TwoFactorLoginViewModel @Inject constructor(
TwoFactorAuthMethod.U2F,
TwoFactorAuthMethod.REMEMBER,
TwoFactorAuthMethod.RECOVERY_CODE,
-> initiateLogin()
-> initiateLogin()
}
}
@ -486,7 +486,7 @@ class TwoFactorLoginViewModel @Inject constructor(
TwoFactorAuthMethod.REMEMBER,
TwoFactorAuthMethod.DUO_ORGANIZATION,
TwoFactorAuthMethod.WEB_AUTH,
-> {
-> {
updateAuthMethodRelatedState(action.authMethod)
}
}
@ -517,7 +517,7 @@ class TwoFactorLoginViewModel @Inject constructor(
val code = when (state.authMethod) {
TwoFactorAuthMethod.AUTHENTICATOR_APP,
TwoFactorAuthMethod.EMAIL,
-> state.codeInput.replace(" ", "")
-> state.codeInput.replace(" ", "")
TwoFactorAuthMethod.DUO,
TwoFactorAuthMethod.DUO_ORGANIZATION,
@ -526,7 +526,7 @@ class TwoFactorLoginViewModel @Inject constructor(
TwoFactorAuthMethod.REMEMBER,
TwoFactorAuthMethod.WEB_AUTH,
TwoFactorAuthMethod.RECOVERY_CODE,
-> state.codeInput
-> state.codeInput
}
viewModelScope.launch {

View file

@ -51,7 +51,7 @@ val TwoFactorAuthMethod.button: Text
get() = when (this) {
TwoFactorAuthMethod.DUO,
TwoFactorAuthMethod.DUO_ORGANIZATION,
-> R.string.launch_duo.asText()
-> R.string.launch_duo.asText()
TwoFactorAuthMethod.AUTHENTICATOR_APP,
TwoFactorAuthMethod.EMAIL,
@ -59,7 +59,7 @@ val TwoFactorAuthMethod.button: Text
TwoFactorAuthMethod.U2F,
TwoFactorAuthMethod.REMEMBER,
TwoFactorAuthMethod.RECOVERY_CODE,
-> R.string.continue_text.asText()
-> R.string.continue_text.asText()
TwoFactorAuthMethod.WEB_AUTH -> R.string.launch_web_authn.asText()
}
@ -72,7 +72,7 @@ val TwoFactorAuthMethod.isContinueButtonEnabled: Boolean
TwoFactorAuthMethod.DUO,
TwoFactorAuthMethod.DUO_ORGANIZATION,
TwoFactorAuthMethod.WEB_AUTH,
-> true
-> true
TwoFactorAuthMethod.AUTHENTICATOR_APP,
TwoFactorAuthMethod.EMAIL,
@ -80,7 +80,7 @@ val TwoFactorAuthMethod.isContinueButtonEnabled: Boolean
TwoFactorAuthMethod.U2F,
TwoFactorAuthMethod.REMEMBER,
TwoFactorAuthMethod.RECOVERY_CODE,
-> false
-> false
}
/**
@ -91,7 +91,7 @@ val TwoFactorAuthMethod.showPasswordInput: Boolean
TwoFactorAuthMethod.DUO,
TwoFactorAuthMethod.DUO_ORGANIZATION,
TwoFactorAuthMethod.WEB_AUTH,
-> false
-> false
TwoFactorAuthMethod.AUTHENTICATOR_APP,
TwoFactorAuthMethod.EMAIL,
@ -99,7 +99,7 @@ val TwoFactorAuthMethod.showPasswordInput: Boolean
TwoFactorAuthMethod.U2F,
TwoFactorAuthMethod.REMEMBER,
TwoFactorAuthMethod.RECOVERY_CODE,
-> true
-> true
}
/**

View file

@ -118,6 +118,7 @@ fun VaultUnlockScreen(
result = Fido2CredentialAssertionResult.Error,
)
}
VaultUnlockEvent.Fido2GetCredentialsError -> {
fido2CompletionManager.completeFido2GetCredentialRequest(
result = Fido2GetCredentialsResult.Error,

View file

@ -300,7 +300,7 @@ class VaultUnlockViewModel @Inject constructor(
VaultUnlockResult.GenericError,
VaultUnlockResult.InvalidStateError,
-> {
-> {
mutableStateFlow.update {
it.copy(
dialog = VaultUnlockState.VaultUnlockDialog.Error(

View file

@ -132,7 +132,7 @@ class Fido2CompletionManagerImpl(
}
Fido2GetCredentialsResult.Error,
-> {
-> {
PendingIntentHandler.setGetCredentialException(
resultIntent,
GetCredentialUnknownException(),

View file

@ -14,7 +14,7 @@ val Configuration.maxDialogHeight: Dp
Configuration.ORIENTATION_UNDEFINED -> Dp.Unspecified
@Suppress("DEPRECATION")
Configuration.ORIENTATION_SQUARE,
-> Dp.Unspecified
-> Dp.Unspecified
else -> Dp.Unspecified
}
@ -29,7 +29,7 @@ val Configuration.maxDialogWidth: Dp
Configuration.ORIENTATION_UNDEFINED -> Dp.Unspecified
@Suppress("DEPRECATION")
Configuration.ORIENTATION_SQUARE,
-> Dp.Unspecified
-> Dp.Unspecified
else -> Dp.Unspecified
}

View file

@ -20,13 +20,13 @@ fun <T : Any> FlagKey<T>.ListItemContent(
FlagKey.DummyBoolean,
is FlagKey.DummyInt,
FlagKey.DummyString,
-> Unit
-> Unit
FlagKey.AuthenticatorSync,
FlagKey.EmailVerification,
FlagKey.OnboardingCarousel,
FlagKey.OnboardingFlow,
-> BooleanFlagItem(
-> BooleanFlagItem(
label = flagKey.getDisplayLabel(),
key = flagKey as FlagKey<Boolean>,
currentValue = currentValue as Boolean,
@ -61,7 +61,7 @@ private fun <T : Any> FlagKey<T>.getDisplayLabel(): String = when (this) {
FlagKey.DummyBoolean,
is FlagKey.DummyInt,
FlagKey.DummyString,
-> this.keyName
-> this.keyName
FlagKey.AuthenticatorSync -> stringResource(R.string.authenticator_sync)
FlagKey.EmailVerification -> stringResource(R.string.email_verification)

View file

@ -109,7 +109,7 @@ fun RootNavScreen(
is RootNavState.CompleteOngoingRegistration,
RootNavState.AuthWithWelcome,
RootNavState.ExpiredRegistrationLink,
-> AUTH_GRAPH_ROUTE
-> AUTH_GRAPH_ROUTE
RootNavState.ResetPassword -> RESET_PASSWORD_ROUTE
RootNavState.SetPassword -> SET_PASSWORD_ROUTE
@ -126,7 +126,7 @@ fun RootNavScreen(
is RootNavState.VaultUnlockedForFido2Save,
is RootNavState.VaultUnlockedForFido2Assertion,
is RootNavState.VaultUnlockedForFido2GetCredentials,
-> VAULT_UNLOCKED_GRAPH_ROUTE
-> VAULT_UNLOCKED_GRAPH_ROUTE
RootNavState.OnboardingAccountLockSetup -> SETUP_UNLOCK_AS_ROOT_ROUTE
RootNavState.OnboardingAutoFillSetup -> SETUP_AUTO_FILL_AS_ROOT_ROUTE
@ -235,7 +235,7 @@ fun RootNavScreen(
is RootNavState.VaultUnlockedForFido2Save,
is RootNavState.VaultUnlockedForFido2Assertion,
is RootNavState.VaultUnlockedForFido2GetCredentials,
-> {
-> {
navController.navigateToVaultUnlockedGraph(rootNavOptions)
navController.navigateToVaultItemListingAsRoot(
vaultItemListingType = VaultItemListingType.Login,

View file

@ -95,7 +95,8 @@ class RootNavViewModel @Inject constructor(
when (userState.activeAccount.onboardingStatus) {
OnboardingStatus.NOT_STARTED,
OnboardingStatus.ACCOUNT_LOCK_SETUP,
-> RootNavState.OnboardingAccountLockSetup
-> RootNavState.OnboardingAccountLockSetup
OnboardingStatus.AUTOFILL_SETUP -> RootNavState.OnboardingAutoFillSetup
OnboardingStatus.FINAL_STEP -> RootNavState.OnboardingStepsComplete
OnboardingStatus.COMPLETE -> throw IllegalStateException("Should not have entered here.")
@ -153,7 +154,7 @@ class RootNavViewModel @Inject constructor(
SpecialCircumstance.GeneratorShortcut,
SpecialCircumstance.VaultShortcut,
null,
-> RootNavState.VaultUnlocked(activeUserId = userState.activeAccount.userId)
-> RootNavState.VaultUnlocked(activeUserId = userState.activeAccount.userId)
is SpecialCircumstance.RegistrationEvent -> {
throw IllegalStateException(

View file

@ -73,7 +73,7 @@ fun SearchContent(
is ListingItemOverflowAction.VaultAction.LaunchClick,
is ListingItemOverflowAction.VaultAction.ViewClick,
null,
-> Unit
-> Unit
}
var autofillSelectionOptionsItem by rememberSaveable {

View file

@ -95,7 +95,7 @@ fun DeleteAccountScreen(
DeleteAccountState.DeleteAccountDialog.Loading,
-> BitwardenLoadingDialog(
-> BitwardenLoadingDialog(
visibilityState = LoadingDialogState.Shown(R.string.loading.asText()),
)

View file

@ -183,7 +183,7 @@ class LoginApprovalViewModel @Inject constructor(
AuthRequestUpdatesResult.Approved,
AuthRequestUpdatesResult.Declined,
AuthRequestUpdatesResult.Expired,
-> {
-> {
sendClosingEvent()
}
}

View file

@ -86,7 +86,7 @@ fun VaultUnlockedNavBarScreen(
when (event) {
is VaultUnlockedNavBarEvent.Shortcut.NavigateToVaultScreen,
is VaultUnlockedNavBarEvent.NavigateToVaultScreen,
-> {
-> {
navigateToVaultGraph(navOptions)
}
@ -96,7 +96,7 @@ fun VaultUnlockedNavBarScreen(
VaultUnlockedNavBarEvent.Shortcut.NavigateToGeneratorScreen,
VaultUnlockedNavBarEvent.NavigateToGeneratorScreen,
-> {
-> {
navigateToGeneratorGraph(navOptions)
}

View file

@ -74,7 +74,7 @@ class BiometricsManagerImpl(
BiometricManager.BIOMETRIC_ERROR_NONE_ENROLLED,
BiometricManager.BIOMETRIC_ERROR_NO_HARDWARE,
BiometricManager.BIOMETRIC_ERROR_SECURITY_UPDATE_REQUIRED,
-> false
-> false
else -> false
}
@ -106,13 +106,13 @@ class BiometricsManagerImpl(
BiometricPrompt.ERROR_NO_BIOMETRICS,
BiometricPrompt.ERROR_HW_NOT_PRESENT,
BiometricPrompt.ERROR_NO_DEVICE_CREDENTIAL,
-> onError()
-> onError()
BiometricPrompt.ERROR_NEGATIVE_BUTTON -> onCancel()
BiometricPrompt.ERROR_LOCKOUT,
BiometricPrompt.ERROR_LOCKOUT_PERMANENT,
-> onLockOut()
-> onLockOut()
}
}

View file

@ -40,7 +40,7 @@ val VaultTimeout.Type.minutes: Int
VaultTimeout.Type.ON_APP_RESTART,
VaultTimeout.Type.NEVER,
-> Int.MAX_VALUE
-> Int.MAX_VALUE
VaultTimeout.Type.CUSTOM -> 0
}

View file

@ -192,7 +192,7 @@ fun GeneratorScreen(
when (state.generatorMode) {
is GeneratorMode.Modal.Username,
GeneratorMode.Modal.Password,
-> {
-> {
ModalAppBar(
scrollBehavior = scrollBehavior,
onCloseClick = remember(viewModel) {

View file

@ -779,44 +779,44 @@ class GeneratorViewModel @Inject constructor(
) {
when (action) {
is GeneratorAction.MainType.Passcode.PasscodeType.Password.SliderLengthChange,
-> {
-> {
handlePasswordLengthSliderChange(action)
}
is GeneratorAction.MainType.Passcode.PasscodeType.Password.ToggleCapitalLettersChange,
-> {
-> {
handleToggleCapitalLetters(action)
}
is GeneratorAction.MainType.Passcode.PasscodeType.Password.ToggleLowercaseLettersChange,
-> {
-> {
handleToggleLowercaseLetters(action)
}
is GeneratorAction.MainType.Passcode.PasscodeType.Password.ToggleNumbersChange,
-> {
-> {
handleToggleNumbers(action)
}
is GeneratorAction.MainType.Passcode.PasscodeType.Password
.ToggleSpecialCharactersChange,
-> {
-> {
handleToggleSpecialChars(action)
}
is GeneratorAction.MainType.Passcode.PasscodeType.Password.MinNumbersCounterChange,
-> {
-> {
handleMinNumbersChange(action)
}
is GeneratorAction.MainType.Passcode.PasscodeType.Password.MinSpecialCharactersChange,
-> {
-> {
handleMinSpecialChange(action)
}
is GeneratorAction.MainType.Passcode.PasscodeType.Password
.ToggleAvoidAmbigousCharactersChange,
-> {
-> {
handleToggleAmbiguousChars(action)
}
}
@ -923,22 +923,22 @@ class GeneratorViewModel @Inject constructor(
) {
when (action) {
is GeneratorAction.MainType.Passcode.PasscodeType.Passphrase.NumWordsCounterChange,
-> {
-> {
handleNumWordsCounterChange(action)
}
is GeneratorAction.MainType.Passcode.PasscodeType.Passphrase.ToggleCapitalizeChange,
-> {
-> {
handlePassphraseToggleCapitalizeChange(action)
}
is GeneratorAction.MainType.Passcode.PasscodeType.Passphrase.ToggleIncludeNumberChange,
-> {
-> {
handlePassphraseToggleIncludeNumberChange(action)
}
is GeneratorAction.MainType.Passcode.PasscodeType.Passphrase.WordSeparatorTextChange,
-> {
-> {
handleWordSeparatorTextInputChange(action)
}
}
@ -1096,7 +1096,7 @@ class GeneratorViewModel @Inject constructor(
.ForwardedEmailAlias
.AddyIo
.AccessTokenTextChange,
-> {
-> {
handleAddyIoAccessTokenTextChange(action)
}
@ -1107,7 +1107,7 @@ class GeneratorViewModel @Inject constructor(
.ForwardedEmailAlias
.AddyIo
.DomainTextChange,
-> {
-> {
handleAddyIoDomainNameTextChange(action)
}
}
@ -1220,7 +1220,7 @@ class GeneratorViewModel @Inject constructor(
.ForwardedEmailAlias
.ForwardEmail
.ApiKeyTextChange,
-> {
-> {
handleForwardEmailApiKeyTextChange(action)
}
@ -1231,7 +1231,7 @@ class GeneratorViewModel @Inject constructor(
.ForwardedEmailAlias
.ForwardEmail
.DomainNameTextChange,
-> {
-> {
handleForwardEmailDomainNameTextChange(action)
}
}
@ -1330,7 +1330,7 @@ class GeneratorViewModel @Inject constructor(
.UsernameType
.RandomWord
.ToggleIncludeNumberChange,
-> {
-> {
handleRandomWordToggleIncludeNumberChange(action)
}
}

View file

@ -118,7 +118,7 @@ private fun VaultAddEditType.toVaultItemCipherTypeOrNull(): String? =
is VaultAddEditType.AddItem -> vaultItemCipherType.toTypeString()
is VaultAddEditType.CloneItem,
is VaultAddEditType.EditItem,
-> null
-> null
}
private fun VaultItemCipherType.toTypeString(): String =

View file

@ -195,7 +195,7 @@ fun VaultData.toViewState(
val shouldShowAddButton = when (itemListingType) {
is VaultItemListingState.ItemListingType.Vault.Folder,
VaultItemListingState.ItemListingType.Vault.Trash,
-> false
-> false
else -> true
}

View file

@ -40,5 +40,9 @@ fun VaultItemListingState.ItemListingType.Vault.toVaultItemCipherType(): VaultIt
is VaultItemListingState.ItemListingType.Vault.Collection -> VaultItemCipherType.LOGIN
is VaultItemListingState.ItemListingType.Vault.Trash,
is VaultItemListingState.ItemListingType.Vault.Folder,
-> throw IllegalStateException("Cannot create vault item from this VaultItemListingState!")
-> {
throw IllegalStateException(
"Cannot create vault item from this VaultItemListingState!",
)
}
}

View file

@ -50,7 +50,7 @@ val AccountSummary.iconTestTag: String
AccountSummary.Status.LOCKED,
AccountSummary.Status.LOGGED_OUT,
AccountSummary.Status.UNLOCKED,
-> "InactiveVaultIcon"
-> "InactiveVaultIcon"
}
/**

View file

@ -295,7 +295,7 @@ fun List<FolderView>.toFilteredList(
when (vaultFilterType) {
VaultFilterType.AllVaults,
VaultFilterType.MyVault,
-> true
-> true
// Only include folders containing an item associated with this organization.
is VaultFilterType.OrganizationVault -> {

View file

@ -13,7 +13,7 @@ fun VaultState.ViewState.vaultFilterDataIfRequired(
when (this) {
is VaultState.ViewState.Content,
is VaultState.ViewState.NoItems,
-> vaultFilterData?.let {
-> vaultFilterData?.let {
if (it.vaultFilterTypes.contains(VaultFilterType.MyVault) ||
it.vaultFilterTypes.size > 2
) {
@ -25,5 +25,5 @@ fun VaultState.ViewState.vaultFilterDataIfRequired(
is VaultState.ViewState.Error,
is VaultState.ViewState.Loading,
-> null
-> null
}

View file

@ -408,27 +408,24 @@ class IdentityServiceTest : BaseServiceTest() {
@Suppress("MaxLineLength")
@Test
fun `verifyEmailToken should return Invalid when response message is non expired error`() = runTest {
val messageWithOutExpired = "message without expir... whoops"
val json = """
{
"message": "$messageWithOutExpired"
}
""".trimIndent()
val response = MockResponse().setResponseCode(400).setBody(json)
server.enqueue(response)
val result = identityService.verifyEmailRegistrationToken(
body = VerifyEmailTokenRequestJson(
token = EMAIL_TOKEN,
email = EMAIL,
),
)
assertTrue(result.isSuccess)
assertEquals(
VerifyEmailTokenResponseJson.Invalid(messageWithOutExpired),
result.getOrThrow(),
)
}
fun `verifyEmailToken should return Invalid when response message is non expired error`() =
runTest {
val messageWithOutExpired = "message without expir... whoops"
val json = """{ "message": "$messageWithOutExpired" }""".trimIndent()
val response = MockResponse().setResponseCode(400).setBody(json)
server.enqueue(response)
val result = identityService.verifyEmailRegistrationToken(
body = VerifyEmailTokenRequestJson(
token = EMAIL_TOKEN,
email = EMAIL,
),
)
assertTrue(result.isSuccess)
assertEquals(
VerifyEmailTokenResponseJson.Invalid(messageWithOutExpired),
result.getOrThrow(),
)
}
@Test
fun `verifyEmailToken should return an error when response is an un-handled error`() = runTest {

View file

@ -352,6 +352,7 @@ class FakeSettingsDiskSource : SettingsDiskSource {
mutablePullToRefreshEnabledFlowMap.getOrPut(userId) {
bufferedMutableSharedFlow(replay = 1)
}
private fun getMutableShowAutoFillSettingBadgeFlow(
userId: String,
): MutableSharedFlow<Boolean?> = mutableShowAutoFillSettingBadgeFlowMap.getOrPut(userId) {

View file

@ -1119,7 +1119,9 @@ class SettingsRepositoryTest {
assertFalse(settingsRepository.isAuthenticatorSyncEnabled)
assertNull(fakeAuthDiskSource.getAuthenticatorSyncUnlockKey(USER_ID))
assertTrue(fakeAuthDiskSource.authenticatorSyncSymmetricKey.contentEquals(syncSymmetricKey))
assertTrue(
fakeAuthDiskSource.authenticatorSyncSymmetricKey.contentEquals(syncSymmetricKey),
)
}
@Test

View file

@ -181,7 +181,7 @@ class VaultLockManagerTest {
VaultTimeout.OneHour,
VaultTimeout.FourHours,
is VaultTimeout.Custom,
-> {
-> {
assertTrue(vaultLockManager.isVaultUnlocked(USER_ID))
}
@ -189,7 +189,7 @@ class VaultLockManagerTest {
VaultTimeout.Immediately,
VaultTimeout.OneMinute,
VaultTimeout.FiveMinutes,
-> {
-> {
assertFalse(vaultLockManager.isVaultUnlocked(USER_ID))
}
}
@ -214,7 +214,7 @@ class VaultLockManagerTest {
VaultTimeout.OneHour,
VaultTimeout.FourHours,
is VaultTimeout.Custom,
-> {
-> {
verify(exactly = 0) { userLogoutManager.softLogout(any()) }
}
@ -222,7 +222,7 @@ class VaultLockManagerTest {
VaultTimeout.Immediately,
VaultTimeout.OneMinute,
VaultTimeout.FiveMinutes,
-> {
-> {
verify(exactly = 1) { userLogoutManager.softLogout(USER_ID) }
}
}
@ -418,7 +418,7 @@ class VaultLockManagerTest {
VaultTimeout.OneHour,
VaultTimeout.FourHours,
is VaultTimeout.Custom,
-> {
-> {
assertTrue(vaultLockManager.isVaultUnlocked(activeUserId))
assertTrue(vaultLockManager.isVaultUnlocked(inactiveUserId))
}
@ -427,7 +427,7 @@ class VaultLockManagerTest {
VaultTimeout.Immediately,
VaultTimeout.OneMinute,
VaultTimeout.FiveMinutes,
-> {
-> {
assertTrue(vaultLockManager.isVaultUnlocked(activeUserId))
assertFalse(vaultLockManager.isVaultUnlocked(inactiveUserId))
}
@ -459,7 +459,7 @@ class VaultLockManagerTest {
VaultTimeout.OneHour,
VaultTimeout.FourHours,
is VaultTimeout.Custom,
-> {
-> {
verify(exactly = 0) { userLogoutManager.softLogout(any()) }
}
@ -467,7 +467,7 @@ class VaultLockManagerTest {
VaultTimeout.Immediately,
VaultTimeout.OneMinute,
VaultTimeout.FiveMinutes,
-> {
-> {
verify(exactly = 0) { userLogoutManager.softLogout(activeUserId) }
verify(exactly = 1) { userLogoutManager.softLogout(inactiveUserId) }
}

View file

@ -350,10 +350,10 @@ class CompleteRegistrationScreenTest : BaseComposeTest() {
.performScrollTo()
.performClick()
verify {
viewModel.trySendAction(CompleteRegistrationAction.LearnToPreventLockoutClick)
verify {
viewModel.trySendAction(CompleteRegistrationAction.LearnToPreventLockoutClick)
}
}
}
@Test
fun `Header should be displayed in portrait mode`() = testWithFeatureFlagOn {

View file

@ -731,8 +731,8 @@ class AccountSecurityViewModelTest : BaseViewModelTest() {
@Test
fun `when UnlockActionCardCtaClick action received, should dismiss unlock action card and send NavigateToSetupUnlockScreen event`() =
runTest {
mutableShowUnlockBadgeFlow.update { true }
val viewModel = createViewModel()
mutableShowUnlockBadgeFlow.update { true }
val viewModel = createViewModel()
viewModel.eventFlow.test {
viewModel.trySendAction(AccountSecurityAction.UnlockActionCardCtaClick)
assertEquals(
@ -740,10 +740,10 @@ class AccountSecurityViewModelTest : BaseViewModelTest() {
awaitItem(),
)
}
verify {
settingsRepository.storeShowUnlockSettingBadge(DEFAULT_STATE.userId, false)
verify {
settingsRepository.storeShowUnlockSettingBadge(DEFAULT_STATE.userId, false)
}
}
}
@Suppress("LongParameterList")
private fun createViewModel(

View file

@ -323,8 +323,8 @@ class AutoFillViewModelTest : BaseViewModelTest() {
@Test
fun `when AutoFillActionCardCtaClick action is sent should update show autofill in repository and send NavigateToSetupAutofill event`() =
runTest {
mutableShowAutofillActionCardFlow.update { true }
val viewModel = createViewModel()
mutableShowAutofillActionCardFlow.update { true }
val viewModel = createViewModel()
viewModel.eventFlow.test {
viewModel.trySendAction(AutoFillAction.AutoFillActionCardCtaClick)
assertEquals(
@ -332,13 +332,10 @@ class AutoFillViewModelTest : BaseViewModelTest() {
awaitItem(),
)
}
verify {
settingsRepository.storeShowAutoFillSettingBadge(
DEFAULT_STATE.activeUserId,
false,
)
verify {
settingsRepository.storeShowAutoFillSettingBadge(DEFAULT_STATE.activeUserId, false)
}
}
}
@Suppress("MaxLineLength")
@Test

View file

@ -44,7 +44,10 @@ class VaultUnlockedNavBarViewModelTest : BaseViewModelTest() {
val viewModel = createViewModel()
viewModel.eventFlow.test {
assertEquals(VaultUnlockedNavBarEvent.Shortcut.NavigateToGeneratorScreen, awaitItem())
assertEquals(
VaultUnlockedNavBarEvent.Shortcut.NavigateToGeneratorScreen,
awaitItem(),
)
}
verify(exactly = 1) {
specialCircumstancesManager.specialCircumstance