mirror of
https://github.com/bitwarden/android.git
synced 2024-10-30 22:55:44 +03:00
Update detekt config and update suppressions (#3396)
This commit is contained in:
parent
ba95a53ebf
commit
074979095b
32 changed files with 11 additions and 49 deletions
|
@ -443,7 +443,6 @@ class AuthRepositoryImpl(
|
|||
},
|
||||
)
|
||||
|
||||
@Suppress("ReturnCount")
|
||||
override suspend fun createNewSsoUser(): NewSsoUserResult {
|
||||
val account = authDiskSource.userState?.activeAccount ?: return NewSsoUserResult.Failure
|
||||
val orgIdentifier = rememberedOrgIdentifier ?: return NewSsoUserResult.Failure
|
||||
|
@ -501,7 +500,6 @@ class AuthRepositoryImpl(
|
|||
)
|
||||
}
|
||||
|
||||
@Suppress("ReturnCount")
|
||||
override suspend fun completeTdeLogin(
|
||||
requestPrivateKey: String,
|
||||
asymmetricalKey: String,
|
||||
|
@ -678,7 +676,6 @@ class AuthRepositoryImpl(
|
|||
}
|
||||
?: ResendEmailResult.Error(message = null)
|
||||
|
||||
@Suppress("ReturnCount")
|
||||
override fun switchAccount(userId: String): SwitchAccountResult {
|
||||
val currentUserState = authDiskSource.userState ?: return SwitchAccountResult.NoChange
|
||||
val previousActiveUserId = currentUserState.activeUserId
|
||||
|
@ -711,7 +708,7 @@ class AuthRepositoryImpl(
|
|||
)
|
||||
}
|
||||
|
||||
@Suppress("ReturnCount", "LongMethod")
|
||||
@Suppress("LongMethod")
|
||||
override suspend fun register(
|
||||
email: String,
|
||||
masterPassword: String,
|
||||
|
@ -806,7 +803,6 @@ class AuthRepositoryImpl(
|
|||
)
|
||||
}
|
||||
|
||||
@Suppress("ReturnCount")
|
||||
override suspend fun resetPassword(
|
||||
currentPassword: String?,
|
||||
newPassword: String,
|
||||
|
@ -1059,7 +1055,6 @@ class AuthRepositoryImpl(
|
|||
onFailure = { PasswordStrengthResult.Error },
|
||||
)
|
||||
|
||||
@Suppress("ReturnCount")
|
||||
override suspend fun validatePassword(password: String): ValidatePasswordResult {
|
||||
val userId = activeUserId ?: return ValidatePasswordResult.Error
|
||||
return authDiskSource
|
||||
|
@ -1109,7 +1104,7 @@ class AuthRepositoryImpl(
|
|||
): Boolean = passwordPolicies
|
||||
.all { validatePasswordAgainstPolicy(password, it) }
|
||||
|
||||
@Suppress("CyclomaticComplexMethod", "ReturnCount")
|
||||
@Suppress("CyclomaticComplexMethod")
|
||||
private suspend fun validatePasswordAgainstPolicy(
|
||||
password: String,
|
||||
policy: PolicyInformation.MasterPassword,
|
||||
|
@ -1438,7 +1433,6 @@ class AuthRepositoryImpl(
|
|||
/**
|
||||
* A helper method to handle the [TrustedDeviceUserDecryptionOptionsJson] specific to TDE.
|
||||
*/
|
||||
@Suppress("ReturnCount")
|
||||
private suspend fun handleLoginCommonSuccessTrustedDeviceUserDecryptionOptions(
|
||||
trustedDeviceDecryptionOptions: TrustedDeviceUserDecryptionOptionsJson,
|
||||
userStateJson: UserStateJson,
|
||||
|
|
|
@ -34,7 +34,6 @@ object AuthRepositoryModule {
|
|||
|
||||
@Provides
|
||||
@Singleton
|
||||
@Suppress("LongParameterList")
|
||||
fun providesAuthRepository(
|
||||
accountsService: AccountsService,
|
||||
devicesService: DevicesService,
|
||||
|
|
|
@ -17,7 +17,7 @@ private val json: Json by lazy {
|
|||
/**
|
||||
* Parses a [JwtTokenDataJson] from the given [jwtToken], or `null` if this parsing is not possible.
|
||||
*/
|
||||
@Suppress("MagicNumber", "ReturnCount")
|
||||
@Suppress("MagicNumber")
|
||||
fun parseJwtTokenDataOrNull(jwtToken: String): JwtTokenDataJson? {
|
||||
val parts = jwtToken.split(".")
|
||||
if (parts.size != 3) return null
|
||||
|
|
|
@ -17,7 +17,6 @@ import com.x8bit.bitwarden.ui.platform.base.util.toHexColorRepresentation
|
|||
* [UserStateJson]. The original will be returned if the sync response does not match any accounts
|
||||
* in the [UserStateJson].
|
||||
*/
|
||||
@Suppress("ReturnCount")
|
||||
fun UserStateJson.toUpdatedUserStateJson(
|
||||
syncResponse: SyncResponseJson,
|
||||
): UserStateJson {
|
||||
|
|
|
@ -9,7 +9,6 @@ import com.x8bit.bitwarden.data.autofill.fido2.manager.Fido2CredentialManager
|
|||
import com.x8bit.bitwarden.data.autofill.fido2.manager.Fido2CredentialManagerImpl
|
||||
import com.x8bit.bitwarden.data.autofill.fido2.processor.Fido2ProviderProcessor
|
||||
import com.x8bit.bitwarden.data.autofill.fido2.processor.Fido2ProviderProcessorImpl
|
||||
import com.x8bit.bitwarden.data.platform.annotation.OmitFromCoverage
|
||||
import com.x8bit.bitwarden.data.platform.manager.AssetManager
|
||||
import com.x8bit.bitwarden.data.platform.manager.dispatcher.DispatcherManager
|
||||
import com.x8bit.bitwarden.ui.platform.manager.intent.IntentManager
|
||||
|
@ -24,7 +23,6 @@ import javax.inject.Singleton
|
|||
/**
|
||||
* Provides dependencies within the fido2 package.
|
||||
*/
|
||||
@OmitFromCoverage
|
||||
@Module
|
||||
@InstallIn(SingletonComponent::class)
|
||||
object Fido2ProviderModule {
|
||||
|
|
|
@ -51,7 +51,6 @@ class Fido2CredentialManagerImpl(
|
|||
null
|
||||
}
|
||||
|
||||
@Suppress("ReturnCount")
|
||||
private suspend fun validateCallingApplicationAssetLinks(
|
||||
fido2CredentialRequest: Fido2CredentialRequest,
|
||||
): Fido2ValidateOriginResult {
|
||||
|
|
|
@ -81,7 +81,6 @@ class Fido2ProviderProcessorImpl(
|
|||
}
|
||||
}
|
||||
|
||||
@Suppress("ReturnCount")
|
||||
private fun handleCreatePasskeyQuery(
|
||||
request: BeginCreatePublicKeyCredentialRequest,
|
||||
): BeginCreateCredentialResponse? {
|
||||
|
|
|
@ -13,7 +13,6 @@ import com.x8bit.bitwarden.ui.platform.manager.intent.EXTRA_KEY_USER_ID
|
|||
* Checks if this [Intent] contains a [Fido2CredentialRequest] related to an ongoing FIDO 2
|
||||
* credential creation process.
|
||||
*/
|
||||
@Suppress("ReturnCount")
|
||||
@OmitFromCoverage
|
||||
fun Intent.getFido2CredentialRequestOrNull(): Fido2CredentialRequest? {
|
||||
if (isBuildVersionBelow(Build.VERSION_CODES.UPSIDE_DOWN_CAKE)) return null
|
||||
|
|
|
@ -155,7 +155,6 @@ private fun AssistStructure.ViewNode.buildAutofillView(
|
|||
/**
|
||||
* Check whether this [AssistStructure.ViewNode] represents a password field.
|
||||
*/
|
||||
@Suppress("ReturnCount")
|
||||
fun AssistStructure.ViewNode.isPasswordField(
|
||||
supportedHint: String?,
|
||||
): Boolean {
|
||||
|
|
|
@ -13,7 +13,6 @@ private const val ANDROID_APP_SCHEME: String = "androidapp"
|
|||
* Try and build a URI. First, try building a website from the list of [ViewNodeTraversalData]. If
|
||||
* that fails, try converting [packageName] into an Android app URI.
|
||||
*/
|
||||
@Suppress("ReturnCount")
|
||||
fun List<ViewNodeTraversalData>.buildUriOrNull(
|
||||
packageName: String?,
|
||||
): String? {
|
||||
|
|
|
@ -56,7 +56,7 @@ class ResultCall<T>(
|
|||
*/
|
||||
fun executeForResult(): Result<T> = requireNotNull(execute().body())
|
||||
|
||||
@Suppress("ReturnCount", "TooGenericExceptionCaught")
|
||||
@Suppress("TooGenericExceptionCaught")
|
||||
override fun execute(): Response<Result<T>> {
|
||||
val response = try {
|
||||
backingCall.execute()
|
||||
|
|
|
@ -57,7 +57,6 @@ class PolicyManagerImpl(
|
|||
/**
|
||||
* A helper method to filter policies.
|
||||
*/
|
||||
@Suppress("ReturnCount")
|
||||
private fun filterPolicies(
|
||||
userId: String,
|
||||
type: PolicyTypeJson,
|
||||
|
|
|
@ -281,7 +281,6 @@ class PushManagerImpl @Inject constructor(
|
|||
}
|
||||
}
|
||||
|
||||
@Suppress("ReturnCount")
|
||||
override fun registerStoredPushTokenIfNecessary() {
|
||||
val userId = activeUserId ?: return
|
||||
if (!isLoggedIn(userId)) return
|
||||
|
|
|
@ -57,7 +57,6 @@ class OrganizationEventManagerImpl(
|
|||
)
|
||||
}
|
||||
|
||||
@Suppress("ReturnCount")
|
||||
override fun trackEvent(event: OrganizationEvent) {
|
||||
val userId = authRepository.activeUserId ?: return
|
||||
if (authRepository.authStateFlow.value !is AuthState.Authenticated) return
|
||||
|
|
|
@ -105,7 +105,6 @@ class CiphersServiceImpl(
|
|||
?: throw throwable
|
||||
}
|
||||
|
||||
@Suppress("ReturnCount")
|
||||
override suspend fun shareAttachment(
|
||||
cipherId: String,
|
||||
attachment: Attachment,
|
||||
|
|
|
@ -399,7 +399,6 @@ class CipherManagerImpl(
|
|||
onFailure = { DownloadAttachmentResult.Failure },
|
||||
)
|
||||
|
||||
@Suppress("ReturnCount")
|
||||
private suspend fun downloadAttachmentForResult(
|
||||
cipherView: CipherView,
|
||||
attachmentId: String,
|
||||
|
@ -482,7 +481,6 @@ class CipherManagerImpl(
|
|||
vaultSdkSource.encryptCipher(userId = userId, cipherView = this)
|
||||
}
|
||||
|
||||
@Suppress("ReturnCount")
|
||||
private suspend fun migrateAttachments(
|
||||
userId: String,
|
||||
cipherView: CipherView,
|
||||
|
|
|
@ -38,7 +38,7 @@ class FileManagerImpl(
|
|||
}
|
||||
}
|
||||
|
||||
@Suppress("NestedBlockDepth", "ReturnCount")
|
||||
@Suppress("NestedBlockDepth")
|
||||
override suspend fun downloadFileToCache(url: String): DownloadResult {
|
||||
val response = downloadService
|
||||
.getDataStream(url)
|
||||
|
|
|
@ -431,7 +431,6 @@ class VaultLockManagerImpl(
|
|||
* Checks the current [VaultTimeout] for the given [userId]. If the given timeout value has
|
||||
* been exceeded, the [VaultTimeoutAction] for the given user will be performed.
|
||||
*/
|
||||
@Suppress("ReturnCount")
|
||||
private fun checkForVaultTimeout(
|
||||
userId: String,
|
||||
isAppRestart: Boolean = false,
|
||||
|
@ -485,7 +484,6 @@ class VaultLockManagerImpl(
|
|||
)
|
||||
}
|
||||
|
||||
@Suppress("ReturnCount")
|
||||
private suspend fun unlockVaultForUser(
|
||||
userId: String,
|
||||
initUserCryptoMethod: InitUserCryptoMethod,
|
||||
|
|
|
@ -524,7 +524,6 @@ class VaultRepositoryImpl(
|
|||
mutableTotpCodeResultFlow.tryEmit(totpCodeResult)
|
||||
}
|
||||
|
||||
@Suppress("ReturnCount")
|
||||
override suspend fun unlockVaultWithBiometrics(): VaultUnlockResult {
|
||||
val userId = activeUserId ?: return VaultUnlockResult.InvalidStateError
|
||||
val biometricsKey = authDiskSource
|
||||
|
@ -543,7 +542,6 @@ class VaultRepositoryImpl(
|
|||
}
|
||||
}
|
||||
|
||||
@Suppress("ReturnCount")
|
||||
override suspend fun unlockVaultWithMasterPassword(
|
||||
masterPassword: String,
|
||||
): VaultUnlockResult {
|
||||
|
@ -564,7 +562,6 @@ class VaultRepositoryImpl(
|
|||
}
|
||||
}
|
||||
|
||||
@Suppress("ReturnCount")
|
||||
override suspend fun unlockVaultWithPin(
|
||||
pin: String,
|
||||
): VaultUnlockResult {
|
||||
|
@ -601,7 +598,6 @@ class VaultRepositoryImpl(
|
|||
organizationKeys = organizationKeys,
|
||||
)
|
||||
|
||||
@Suppress("ReturnCount")
|
||||
override suspend fun createSend(
|
||||
sendView: SendView,
|
||||
fileUri: Uri?,
|
||||
|
@ -834,7 +830,6 @@ class VaultRepositoryImpl(
|
|||
}
|
||||
}
|
||||
|
||||
@Suppress("ReturnCount")
|
||||
override suspend fun exportVaultDataToString(format: ExportFormat): ExportVaultDataResult {
|
||||
val userId = activeUserId ?: return ExportVaultDataResult.Error
|
||||
val folders = vaultDiskSource
|
||||
|
@ -920,7 +915,6 @@ class VaultRepositoryImpl(
|
|||
}
|
||||
}
|
||||
|
||||
@Suppress("ReturnCount")
|
||||
private suspend fun unlockVaultForUser(
|
||||
userId: String,
|
||||
initUserCryptoMethod: InitUserCryptoMethod,
|
||||
|
@ -1128,7 +1122,6 @@ class VaultRepositoryImpl(
|
|||
* are met. If the resource cannot be found cloud-side, and it was updated, delete it from disk
|
||||
* for now.
|
||||
*/
|
||||
@Suppress("ReturnCount")
|
||||
private suspend fun syncCipherIfNecessary(syncCipherUpsertData: SyncCipherUpsertData) {
|
||||
val userId = activeUserId ?: return
|
||||
val cipherId = syncCipherUpsertData.cipherId
|
||||
|
|
|
@ -60,7 +60,7 @@ class MasterPasswordHintViewModel @Inject constructor(
|
|||
)
|
||||
}
|
||||
|
||||
@Suppress("LongMethod", "ReturnCount")
|
||||
@Suppress("LongMethod")
|
||||
private fun handleSubmitClick() {
|
||||
val email = stateFlow.value.emailInput
|
||||
|
||||
|
|
|
@ -202,7 +202,6 @@ fun RootNavScreen(
|
|||
* As noted above, this can be removed after upgrading to latest compose navigation, since
|
||||
* the nav args can prevent us from having to do this check.
|
||||
*/
|
||||
@Suppress("ReturnCount")
|
||||
private fun NavDestination?.rootLevelRoute(): String? {
|
||||
if (this == null) {
|
||||
return null
|
||||
|
|
|
@ -15,7 +15,6 @@ import com.x8bit.bitwarden.ui.platform.base.util.asText
|
|||
*
|
||||
* This function will return the error message or null if there is no error.
|
||||
*/
|
||||
@Suppress("ReturnCount")
|
||||
fun String.validateUri(existingUris: List<String>): Text? {
|
||||
|
||||
// Check if URI starts with allowed schemes.
|
||||
|
|
|
@ -130,7 +130,6 @@ class ExportVaultViewModel @Inject constructor(
|
|||
/**
|
||||
* Verify the master password after confirming exporting the vault.
|
||||
*/
|
||||
@Suppress("ReturnCount")
|
||||
private fun handleConfirmExportVaultClicked() {
|
||||
// Display an error alert if the user hasn't entered a password.
|
||||
if (state.passwordInput.isBlank()) {
|
||||
|
|
|
@ -131,7 +131,6 @@ class IntentManagerImpl(
|
|||
override fun getFileDataFromIntent(intent: Intent): IntentManager.FileData? =
|
||||
intent.clipData?.getItemAt(0)?.uri?.let { getLocalFileData(it) }
|
||||
|
||||
@Suppress("ReturnCount")
|
||||
override fun getShareDataFromIntent(intent: Intent): IntentManager.ShareData? {
|
||||
if (intent.action != Intent.ACTION_SEND) return null
|
||||
return if (intent.type?.contains("text/") == true) {
|
||||
|
|
|
@ -8,7 +8,7 @@ import com.x8bit.bitwarden.ui.tools.feature.generator.GeneratorState.MainType.Us
|
|||
/**
|
||||
* Converts a [ServiceType] to a [UsernameGeneratorRequest.Forwarded].
|
||||
*/
|
||||
@Suppress("ReturnCount", "LongMethod")
|
||||
@Suppress("LongMethod")
|
||||
fun ServiceType.toUsernameGeneratorRequest(website: String?): UsernameGeneratorRequest.Forwarded? {
|
||||
return when (this) {
|
||||
is ServiceType.AddyIo -> {
|
||||
|
|
|
@ -287,7 +287,6 @@ class VaultItemListingViewModel @Inject constructor(
|
|||
sendEvent(VaultItemListingEvent.NavigateToSendItem(id = action.sendId))
|
||||
}
|
||||
|
||||
@Suppress("ReturnCount")
|
||||
private fun handleItemClick(action: VaultItemListingsAction.ItemClick) {
|
||||
if (state.isAutofill) {
|
||||
val cipherView = getCipherViewOrNull(action.id) ?: return
|
||||
|
|
|
@ -79,7 +79,7 @@ class QrCodeScanViewModel @Inject constructor(
|
|||
)
|
||||
}
|
||||
|
||||
@Suppress("NestedBlockDepth", "ReturnCount", "MagicNumber")
|
||||
@Suppress("NestedBlockDepth", "MagicNumber")
|
||||
private fun areParametersValid(scannedCode: String, parameters: Set<String>): Boolean {
|
||||
parameters.forEach { parameter ->
|
||||
Uri.parse(scannedCode).getQueryParameter(parameter)?.let { value ->
|
||||
|
|
|
@ -9,7 +9,6 @@ private const val COLLECTION_DIVIDER: String = "/"
|
|||
* display names. This function is necessary if we want to show the nested collections for a
|
||||
* specific collection.
|
||||
*/
|
||||
@Suppress("ReturnCount")
|
||||
fun List<CollectionView>.getCollections(collectionId: String): List<CollectionView> {
|
||||
val currentCollection = this.find { it.id == collectionId } ?: return emptyList()
|
||||
|
||||
|
|
|
@ -8,7 +8,6 @@ private const val FOLDER_DIVIDER: String = "/"
|
|||
* Retrieves the subfolders of a given [folderId] and updates their names to proper display names.
|
||||
* This function is necessary if we want to show the subfolders for a specific folder.
|
||||
*/
|
||||
@Suppress("ReturnCount")
|
||||
fun List<FolderView>.getFolders(folderId: String): List<FolderView> {
|
||||
val currentFolder = this.find { it.id == folderId } ?: return emptyList()
|
||||
|
||||
|
|
|
@ -142,7 +142,6 @@ fun VaultData.toViewState(
|
|||
/**
|
||||
* Method to build the icon data for login item icons.
|
||||
*/
|
||||
@Suppress("ReturnCount")
|
||||
fun List<LoginUriView>?.toLoginIconData(
|
||||
isIconLoadingDisabled: Boolean,
|
||||
baseIconUrl: String,
|
||||
|
|
|
@ -33,7 +33,7 @@ class CipherViewExtensionsTest {
|
|||
// This visibility state should be preserved
|
||||
isVisible = true,
|
||||
canViewPassword = false,
|
||||
)
|
||||
),
|
||||
),
|
||||
),
|
||||
isPremiumUser = true,
|
||||
|
@ -58,7 +58,7 @@ class CipherViewExtensionsTest {
|
|||
password = "password",
|
||||
isVisible = true,
|
||||
canViewPassword = false,
|
||||
)
|
||||
),
|
||||
),
|
||||
),
|
||||
viewState,
|
||||
|
|
|
@ -595,7 +595,7 @@ style:
|
|||
RedundantVisibilityModifierRule:
|
||||
active: false
|
||||
ReturnCount:
|
||||
active: true
|
||||
active: false
|
||||
max: 2
|
||||
excludedFunctions: [ 'equals' ]
|
||||
excludeLabeled: false
|
||||
|
|
Loading…
Reference in a new issue