mirror of
https://github.com/bitwarden/android.git
synced 2025-02-16 11:59:57 +03:00
Update detekt and fix minor warnings (#955)
This commit is contained in:
parent
28f805418d
commit
61212c3628
5 changed files with 6 additions and 60 deletions
|
@ -18,5 +18,6 @@ inline fun <reified T> Intent.getSafeParcelableExtra(name: String): T? =
|
||||||
T::class.java,
|
T::class.java,
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
|
@Suppress("DEPRECATION")
|
||||||
getParcelableExtra(name)
|
getParcelableExtra(name)
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,7 @@ private const val IP_REGEX: String =
|
||||||
* Parses the base domain from the URL. Returns null if unavailable.
|
* Parses the base domain from the URL. Returns null if unavailable.
|
||||||
*/
|
*/
|
||||||
fun URI.parseDomainOrNull(context: Context): String? {
|
fun URI.parseDomainOrNull(context: Context): String? {
|
||||||
val host = this?.host ?: return null
|
val host = this.host ?: return null
|
||||||
val isIpAddress = host.matches(IP_REGEX.toRegex())
|
val isIpAddress = host.matches(IP_REGEX.toRegex())
|
||||||
|
|
||||||
return if (host == "localhost" || isIpAddress) {
|
return if (host == "localhost" || isIpAddress) {
|
||||||
|
@ -38,7 +38,7 @@ fun URI.parseDomainOrNull(context: Context): String? {
|
||||||
fun URI.parseDomainNameOrNull(context: Context): DomainName? =
|
fun URI.parseDomainNameOrNull(context: Context): DomainName? =
|
||||||
this
|
this
|
||||||
// URI is a platform type and host can be null.
|
// URI is a platform type and host can be null.
|
||||||
?.host
|
.host
|
||||||
?.let { nonNullHost ->
|
?.let { nonNullHost ->
|
||||||
parseDomainNameOrNullInternal(
|
parseDomainNameOrNullInternal(
|
||||||
context = context,
|
context = context,
|
||||||
|
|
|
@ -3335,9 +3335,6 @@ class VaultRepositoryTest {
|
||||||
fakeAuthDiskSource.userState = MOCK_USER_STATE
|
fakeAuthDiskSource.userState = MOCK_USER_STATE
|
||||||
|
|
||||||
val attachmentId = "mockId-1"
|
val attachmentId = "mockId-1"
|
||||||
val attachment = mockk<Attachment> {
|
|
||||||
every { id } returns attachmentId
|
|
||||||
}
|
|
||||||
val cipher = mockk<Cipher> {
|
val cipher = mockk<Cipher> {
|
||||||
every { attachments } returns emptyList()
|
every { attachments } returns emptyList()
|
||||||
every { id } returns "mockId-1"
|
every { id } returns "mockId-1"
|
||||||
|
@ -5366,58 +5363,6 @@ class VaultRepositoryTest {
|
||||||
coEvery { vaultDiskSource.getSends(MOCK_USER_STATE.activeUserId) } returns sendsFlow
|
coEvery { vaultDiskSource.getSends(MOCK_USER_STATE.activeUserId) } returns sendsFlow
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Helper to ensures that the vault for the user with the given [userId] is unlocked.
|
|
||||||
*/
|
|
||||||
private suspend fun verifyUnlockedVault(userId: String) {
|
|
||||||
val kdf = MOCK_PROFILE.toSdkParams()
|
|
||||||
val email = MOCK_PROFILE.email
|
|
||||||
val masterPassword = "drowssap"
|
|
||||||
val userKey = "12345"
|
|
||||||
val privateKey = "54321"
|
|
||||||
val organizationKeys = null
|
|
||||||
coEvery {
|
|
||||||
vaultSdkSource.initializeCrypto(
|
|
||||||
userId = userId,
|
|
||||||
request = InitUserCryptoRequest(
|
|
||||||
kdfParams = kdf,
|
|
||||||
email = email,
|
|
||||||
privateKey = privateKey,
|
|
||||||
method = InitUserCryptoMethod.Password(
|
|
||||||
password = masterPassword,
|
|
||||||
userKey = userKey,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
} returns InitializeCryptoResult.Success.asSuccess()
|
|
||||||
|
|
||||||
val result = vaultRepository.unlockVault(
|
|
||||||
userId = userId,
|
|
||||||
masterPassword = masterPassword,
|
|
||||||
kdf = kdf,
|
|
||||||
email = email,
|
|
||||||
userKey = userKey,
|
|
||||||
privateKey = privateKey,
|
|
||||||
organizationKeys = organizationKeys,
|
|
||||||
)
|
|
||||||
|
|
||||||
assertEquals(VaultUnlockResult.Success, result)
|
|
||||||
coVerify(exactly = 1) {
|
|
||||||
vaultSdkSource.initializeCrypto(
|
|
||||||
userId = userId,
|
|
||||||
request = InitUserCryptoRequest(
|
|
||||||
kdfParams = kdf,
|
|
||||||
email = email,
|
|
||||||
privateKey = privateKey,
|
|
||||||
method = InitUserCryptoMethod.Password(
|
|
||||||
password = masterPassword,
|
|
||||||
userKey = userKey,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private suspend fun setupDataStateFlow(userId: String) {
|
private suspend fun setupDataStateFlow(userId: String) {
|
||||||
coEvery {
|
coEvery {
|
||||||
vaultSdkSource.decryptCipherList(
|
vaultSdkSource.decryptCipherList(
|
||||||
|
|
|
@ -417,7 +417,7 @@ naming:
|
||||||
packagePattern: '[a-z]+(\.[a-z][A-Za-z0-9]*)*'
|
packagePattern: '[a-z]+(\.[a-z][A-Za-z0-9]*)*'
|
||||||
TopLevelPropertyNaming:
|
TopLevelPropertyNaming:
|
||||||
active: true
|
active: true
|
||||||
excludes: [ '**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**', '**/compose/**']
|
excludes: [ '**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**', '**/compose/**' ]
|
||||||
constantPattern: '[A-Z][_A-Z0-9]*'
|
constantPattern: '[A-Z][_A-Z0-9]*'
|
||||||
propertyPattern: '[A-Za-z][_A-Za-z0-9]*'
|
propertyPattern: '[A-Za-z][_A-Za-z0-9]*'
|
||||||
privatePropertyPattern: '_?[A-Za-z][_A-Za-z0-9]*'
|
privatePropertyPattern: '_?[A-Za-z][_A-Za-z0-9]*'
|
||||||
|
@ -584,7 +584,7 @@ style:
|
||||||
active: true
|
active: true
|
||||||
OptionalUnit:
|
OptionalUnit:
|
||||||
active: false
|
active: false
|
||||||
OptionalWhenBraces:
|
BracesOnWhenStatements:
|
||||||
active: false
|
active: false
|
||||||
PreferToOverPairSyntax:
|
PreferToOverPairSyntax:
|
||||||
active: false
|
active: false
|
||||||
|
|
|
@ -29,7 +29,7 @@ androdixAutofill = "1.1.0"
|
||||||
androidxWork = "2.9.0"
|
androidxWork = "2.9.0"
|
||||||
bitwardenSdk = "0.4.0-20240205.155354-106"
|
bitwardenSdk = "0.4.0-20240205.155354-106"
|
||||||
crashlytics = "2.9.9"
|
crashlytics = "2.9.9"
|
||||||
detekt = "1.23.1"
|
detekt = "1.23.5"
|
||||||
firebaseBom = "32.7.0"
|
firebaseBom = "32.7.0"
|
||||||
glide = "1.0.0-beta01"
|
glide = "1.0.0-beta01"
|
||||||
googleServices = "4.4.0"
|
googleServices = "4.4.0"
|
||||||
|
|
Loading…
Add table
Reference in a new issue