Update detekt config and update suppressions (#3396)

This commit is contained in:
David Perez 2024-07-02 17:19:56 -05:00 committed by GitHub
parent ba95a53ebf
commit 074979095b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
32 changed files with 11 additions and 49 deletions

View file

@ -443,7 +443,6 @@ class AuthRepositoryImpl(
}, },
) )
@Suppress("ReturnCount")
override suspend fun createNewSsoUser(): NewSsoUserResult { override suspend fun createNewSsoUser(): NewSsoUserResult {
val account = authDiskSource.userState?.activeAccount ?: return NewSsoUserResult.Failure val account = authDiskSource.userState?.activeAccount ?: return NewSsoUserResult.Failure
val orgIdentifier = rememberedOrgIdentifier ?: return NewSsoUserResult.Failure val orgIdentifier = rememberedOrgIdentifier ?: return NewSsoUserResult.Failure
@ -501,7 +500,6 @@ class AuthRepositoryImpl(
) )
} }
@Suppress("ReturnCount")
override suspend fun completeTdeLogin( override suspend fun completeTdeLogin(
requestPrivateKey: String, requestPrivateKey: String,
asymmetricalKey: String, asymmetricalKey: String,
@ -678,7 +676,6 @@ class AuthRepositoryImpl(
} }
?: ResendEmailResult.Error(message = null) ?: ResendEmailResult.Error(message = null)
@Suppress("ReturnCount")
override fun switchAccount(userId: String): SwitchAccountResult { override fun switchAccount(userId: String): SwitchAccountResult {
val currentUserState = authDiskSource.userState ?: return SwitchAccountResult.NoChange val currentUserState = authDiskSource.userState ?: return SwitchAccountResult.NoChange
val previousActiveUserId = currentUserState.activeUserId val previousActiveUserId = currentUserState.activeUserId
@ -711,7 +708,7 @@ class AuthRepositoryImpl(
) )
} }
@Suppress("ReturnCount", "LongMethod") @Suppress("LongMethod")
override suspend fun register( override suspend fun register(
email: String, email: String,
masterPassword: String, masterPassword: String,
@ -806,7 +803,6 @@ class AuthRepositoryImpl(
) )
} }
@Suppress("ReturnCount")
override suspend fun resetPassword( override suspend fun resetPassword(
currentPassword: String?, currentPassword: String?,
newPassword: String, newPassword: String,
@ -1059,7 +1055,6 @@ class AuthRepositoryImpl(
onFailure = { PasswordStrengthResult.Error }, onFailure = { PasswordStrengthResult.Error },
) )
@Suppress("ReturnCount")
override suspend fun validatePassword(password: String): ValidatePasswordResult { override suspend fun validatePassword(password: String): ValidatePasswordResult {
val userId = activeUserId ?: return ValidatePasswordResult.Error val userId = activeUserId ?: return ValidatePasswordResult.Error
return authDiskSource return authDiskSource
@ -1109,7 +1104,7 @@ class AuthRepositoryImpl(
): Boolean = passwordPolicies ): Boolean = passwordPolicies
.all { validatePasswordAgainstPolicy(password, it) } .all { validatePasswordAgainstPolicy(password, it) }
@Suppress("CyclomaticComplexMethod", "ReturnCount") @Suppress("CyclomaticComplexMethod")
private suspend fun validatePasswordAgainstPolicy( private suspend fun validatePasswordAgainstPolicy(
password: String, password: String,
policy: PolicyInformation.MasterPassword, policy: PolicyInformation.MasterPassword,
@ -1438,7 +1433,6 @@ class AuthRepositoryImpl(
/** /**
* A helper method to handle the [TrustedDeviceUserDecryptionOptionsJson] specific to TDE. * A helper method to handle the [TrustedDeviceUserDecryptionOptionsJson] specific to TDE.
*/ */
@Suppress("ReturnCount")
private suspend fun handleLoginCommonSuccessTrustedDeviceUserDecryptionOptions( private suspend fun handleLoginCommonSuccessTrustedDeviceUserDecryptionOptions(
trustedDeviceDecryptionOptions: TrustedDeviceUserDecryptionOptionsJson, trustedDeviceDecryptionOptions: TrustedDeviceUserDecryptionOptionsJson,
userStateJson: UserStateJson, userStateJson: UserStateJson,

View file

@ -34,7 +34,6 @@ object AuthRepositoryModule {
@Provides @Provides
@Singleton @Singleton
@Suppress("LongParameterList")
fun providesAuthRepository( fun providesAuthRepository(
accountsService: AccountsService, accountsService: AccountsService,
devicesService: DevicesService, devicesService: DevicesService,

View file

@ -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. * 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? { fun parseJwtTokenDataOrNull(jwtToken: String): JwtTokenDataJson? {
val parts = jwtToken.split(".") val parts = jwtToken.split(".")
if (parts.size != 3) return null if (parts.size != 3) return null

View file

@ -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 * [UserStateJson]. The original will be returned if the sync response does not match any accounts
* in the [UserStateJson]. * in the [UserStateJson].
*/ */
@Suppress("ReturnCount")
fun UserStateJson.toUpdatedUserStateJson( fun UserStateJson.toUpdatedUserStateJson(
syncResponse: SyncResponseJson, syncResponse: SyncResponseJson,
): UserStateJson { ): UserStateJson {

View file

@ -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.manager.Fido2CredentialManagerImpl
import com.x8bit.bitwarden.data.autofill.fido2.processor.Fido2ProviderProcessor import com.x8bit.bitwarden.data.autofill.fido2.processor.Fido2ProviderProcessor
import com.x8bit.bitwarden.data.autofill.fido2.processor.Fido2ProviderProcessorImpl 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.AssetManager
import com.x8bit.bitwarden.data.platform.manager.dispatcher.DispatcherManager import com.x8bit.bitwarden.data.platform.manager.dispatcher.DispatcherManager
import com.x8bit.bitwarden.ui.platform.manager.intent.IntentManager import com.x8bit.bitwarden.ui.platform.manager.intent.IntentManager
@ -24,7 +23,6 @@ import javax.inject.Singleton
/** /**
* Provides dependencies within the fido2 package. * Provides dependencies within the fido2 package.
*/ */
@OmitFromCoverage
@Module @Module
@InstallIn(SingletonComponent::class) @InstallIn(SingletonComponent::class)
object Fido2ProviderModule { object Fido2ProviderModule {

View file

@ -51,7 +51,6 @@ class Fido2CredentialManagerImpl(
null null
} }
@Suppress("ReturnCount")
private suspend fun validateCallingApplicationAssetLinks( private suspend fun validateCallingApplicationAssetLinks(
fido2CredentialRequest: Fido2CredentialRequest, fido2CredentialRequest: Fido2CredentialRequest,
): Fido2ValidateOriginResult { ): Fido2ValidateOriginResult {

View file

@ -81,7 +81,6 @@ class Fido2ProviderProcessorImpl(
} }
} }
@Suppress("ReturnCount")
private fun handleCreatePasskeyQuery( private fun handleCreatePasskeyQuery(
request: BeginCreatePublicKeyCredentialRequest, request: BeginCreatePublicKeyCredentialRequest,
): BeginCreateCredentialResponse? { ): BeginCreateCredentialResponse? {

View file

@ -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 * Checks if this [Intent] contains a [Fido2CredentialRequest] related to an ongoing FIDO 2
* credential creation process. * credential creation process.
*/ */
@Suppress("ReturnCount")
@OmitFromCoverage @OmitFromCoverage
fun Intent.getFido2CredentialRequestOrNull(): Fido2CredentialRequest? { fun Intent.getFido2CredentialRequestOrNull(): Fido2CredentialRequest? {
if (isBuildVersionBelow(Build.VERSION_CODES.UPSIDE_DOWN_CAKE)) return null if (isBuildVersionBelow(Build.VERSION_CODES.UPSIDE_DOWN_CAKE)) return null

View file

@ -155,7 +155,6 @@ private fun AssistStructure.ViewNode.buildAutofillView(
/** /**
* Check whether this [AssistStructure.ViewNode] represents a password field. * Check whether this [AssistStructure.ViewNode] represents a password field.
*/ */
@Suppress("ReturnCount")
fun AssistStructure.ViewNode.isPasswordField( fun AssistStructure.ViewNode.isPasswordField(
supportedHint: String?, supportedHint: String?,
): Boolean { ): Boolean {

View file

@ -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 * 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. * that fails, try converting [packageName] into an Android app URI.
*/ */
@Suppress("ReturnCount")
fun List<ViewNodeTraversalData>.buildUriOrNull( fun List<ViewNodeTraversalData>.buildUriOrNull(
packageName: String?, packageName: String?,
): String? { ): String? {

View file

@ -56,7 +56,7 @@ class ResultCall<T>(
*/ */
fun executeForResult(): Result<T> = requireNotNull(execute().body()) fun executeForResult(): Result<T> = requireNotNull(execute().body())
@Suppress("ReturnCount", "TooGenericExceptionCaught") @Suppress("TooGenericExceptionCaught")
override fun execute(): Response<Result<T>> { override fun execute(): Response<Result<T>> {
val response = try { val response = try {
backingCall.execute() backingCall.execute()

View file

@ -57,7 +57,6 @@ class PolicyManagerImpl(
/** /**
* A helper method to filter policies. * A helper method to filter policies.
*/ */
@Suppress("ReturnCount")
private fun filterPolicies( private fun filterPolicies(
userId: String, userId: String,
type: PolicyTypeJson, type: PolicyTypeJson,

View file

@ -281,7 +281,6 @@ class PushManagerImpl @Inject constructor(
} }
} }
@Suppress("ReturnCount")
override fun registerStoredPushTokenIfNecessary() { override fun registerStoredPushTokenIfNecessary() {
val userId = activeUserId ?: return val userId = activeUserId ?: return
if (!isLoggedIn(userId)) return if (!isLoggedIn(userId)) return

View file

@ -57,7 +57,6 @@ class OrganizationEventManagerImpl(
) )
} }
@Suppress("ReturnCount")
override fun trackEvent(event: OrganizationEvent) { override fun trackEvent(event: OrganizationEvent) {
val userId = authRepository.activeUserId ?: return val userId = authRepository.activeUserId ?: return
if (authRepository.authStateFlow.value !is AuthState.Authenticated) return if (authRepository.authStateFlow.value !is AuthState.Authenticated) return

View file

@ -105,7 +105,6 @@ class CiphersServiceImpl(
?: throw throwable ?: throw throwable
} }
@Suppress("ReturnCount")
override suspend fun shareAttachment( override suspend fun shareAttachment(
cipherId: String, cipherId: String,
attachment: Attachment, attachment: Attachment,

View file

@ -399,7 +399,6 @@ class CipherManagerImpl(
onFailure = { DownloadAttachmentResult.Failure }, onFailure = { DownloadAttachmentResult.Failure },
) )
@Suppress("ReturnCount")
private suspend fun downloadAttachmentForResult( private suspend fun downloadAttachmentForResult(
cipherView: CipherView, cipherView: CipherView,
attachmentId: String, attachmentId: String,
@ -482,7 +481,6 @@ class CipherManagerImpl(
vaultSdkSource.encryptCipher(userId = userId, cipherView = this) vaultSdkSource.encryptCipher(userId = userId, cipherView = this)
} }
@Suppress("ReturnCount")
private suspend fun migrateAttachments( private suspend fun migrateAttachments(
userId: String, userId: String,
cipherView: CipherView, cipherView: CipherView,

View file

@ -38,7 +38,7 @@ class FileManagerImpl(
} }
} }
@Suppress("NestedBlockDepth", "ReturnCount") @Suppress("NestedBlockDepth")
override suspend fun downloadFileToCache(url: String): DownloadResult { override suspend fun downloadFileToCache(url: String): DownloadResult {
val response = downloadService val response = downloadService
.getDataStream(url) .getDataStream(url)

View file

@ -431,7 +431,6 @@ class VaultLockManagerImpl(
* Checks the current [VaultTimeout] for the given [userId]. If the given timeout value has * 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. * been exceeded, the [VaultTimeoutAction] for the given user will be performed.
*/ */
@Suppress("ReturnCount")
private fun checkForVaultTimeout( private fun checkForVaultTimeout(
userId: String, userId: String,
isAppRestart: Boolean = false, isAppRestart: Boolean = false,
@ -485,7 +484,6 @@ class VaultLockManagerImpl(
) )
} }
@Suppress("ReturnCount")
private suspend fun unlockVaultForUser( private suspend fun unlockVaultForUser(
userId: String, userId: String,
initUserCryptoMethod: InitUserCryptoMethod, initUserCryptoMethod: InitUserCryptoMethod,

View file

@ -524,7 +524,6 @@ class VaultRepositoryImpl(
mutableTotpCodeResultFlow.tryEmit(totpCodeResult) mutableTotpCodeResultFlow.tryEmit(totpCodeResult)
} }
@Suppress("ReturnCount")
override suspend fun unlockVaultWithBiometrics(): VaultUnlockResult { override suspend fun unlockVaultWithBiometrics(): VaultUnlockResult {
val userId = activeUserId ?: return VaultUnlockResult.InvalidStateError val userId = activeUserId ?: return VaultUnlockResult.InvalidStateError
val biometricsKey = authDiskSource val biometricsKey = authDiskSource
@ -543,7 +542,6 @@ class VaultRepositoryImpl(
} }
} }
@Suppress("ReturnCount")
override suspend fun unlockVaultWithMasterPassword( override suspend fun unlockVaultWithMasterPassword(
masterPassword: String, masterPassword: String,
): VaultUnlockResult { ): VaultUnlockResult {
@ -564,7 +562,6 @@ class VaultRepositoryImpl(
} }
} }
@Suppress("ReturnCount")
override suspend fun unlockVaultWithPin( override suspend fun unlockVaultWithPin(
pin: String, pin: String,
): VaultUnlockResult { ): VaultUnlockResult {
@ -601,7 +598,6 @@ class VaultRepositoryImpl(
organizationKeys = organizationKeys, organizationKeys = organizationKeys,
) )
@Suppress("ReturnCount")
override suspend fun createSend( override suspend fun createSend(
sendView: SendView, sendView: SendView,
fileUri: Uri?, fileUri: Uri?,
@ -834,7 +830,6 @@ class VaultRepositoryImpl(
} }
} }
@Suppress("ReturnCount")
override suspend fun exportVaultDataToString(format: ExportFormat): ExportVaultDataResult { override suspend fun exportVaultDataToString(format: ExportFormat): ExportVaultDataResult {
val userId = activeUserId ?: return ExportVaultDataResult.Error val userId = activeUserId ?: return ExportVaultDataResult.Error
val folders = vaultDiskSource val folders = vaultDiskSource
@ -920,7 +915,6 @@ class VaultRepositoryImpl(
} }
} }
@Suppress("ReturnCount")
private suspend fun unlockVaultForUser( private suspend fun unlockVaultForUser(
userId: String, userId: String,
initUserCryptoMethod: InitUserCryptoMethod, 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 * are met. If the resource cannot be found cloud-side, and it was updated, delete it from disk
* for now. * for now.
*/ */
@Suppress("ReturnCount")
private suspend fun syncCipherIfNecessary(syncCipherUpsertData: SyncCipherUpsertData) { private suspend fun syncCipherIfNecessary(syncCipherUpsertData: SyncCipherUpsertData) {
val userId = activeUserId ?: return val userId = activeUserId ?: return
val cipherId = syncCipherUpsertData.cipherId val cipherId = syncCipherUpsertData.cipherId

View file

@ -60,7 +60,7 @@ class MasterPasswordHintViewModel @Inject constructor(
) )
} }
@Suppress("LongMethod", "ReturnCount") @Suppress("LongMethod")
private fun handleSubmitClick() { private fun handleSubmitClick() {
val email = stateFlow.value.emailInput val email = stateFlow.value.emailInput

View file

@ -202,7 +202,6 @@ fun RootNavScreen(
* As noted above, this can be removed after upgrading to latest compose navigation, since * 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. * the nav args can prevent us from having to do this check.
*/ */
@Suppress("ReturnCount")
private fun NavDestination?.rootLevelRoute(): String? { private fun NavDestination?.rootLevelRoute(): String? {
if (this == null) { if (this == null) {
return null return null

View file

@ -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. * This function will return the error message or null if there is no error.
*/ */
@Suppress("ReturnCount")
fun String.validateUri(existingUris: List<String>): Text? { fun String.validateUri(existingUris: List<String>): Text? {
// Check if URI starts with allowed schemes. // Check if URI starts with allowed schemes.

View file

@ -130,7 +130,6 @@ class ExportVaultViewModel @Inject constructor(
/** /**
* Verify the master password after confirming exporting the vault. * Verify the master password after confirming exporting the vault.
*/ */
@Suppress("ReturnCount")
private fun handleConfirmExportVaultClicked() { private fun handleConfirmExportVaultClicked() {
// Display an error alert if the user hasn't entered a password. // Display an error alert if the user hasn't entered a password.
if (state.passwordInput.isBlank()) { if (state.passwordInput.isBlank()) {

View file

@ -131,7 +131,6 @@ class IntentManagerImpl(
override fun getFileDataFromIntent(intent: Intent): IntentManager.FileData? = override fun getFileDataFromIntent(intent: Intent): IntentManager.FileData? =
intent.clipData?.getItemAt(0)?.uri?.let { getLocalFileData(it) } intent.clipData?.getItemAt(0)?.uri?.let { getLocalFileData(it) }
@Suppress("ReturnCount")
override fun getShareDataFromIntent(intent: Intent): IntentManager.ShareData? { override fun getShareDataFromIntent(intent: Intent): IntentManager.ShareData? {
if (intent.action != Intent.ACTION_SEND) return null if (intent.action != Intent.ACTION_SEND) return null
return if (intent.type?.contains("text/") == true) { return if (intent.type?.contains("text/") == true) {

View file

@ -8,7 +8,7 @@ import com.x8bit.bitwarden.ui.tools.feature.generator.GeneratorState.MainType.Us
/** /**
* Converts a [ServiceType] to a [UsernameGeneratorRequest.Forwarded]. * Converts a [ServiceType] to a [UsernameGeneratorRequest.Forwarded].
*/ */
@Suppress("ReturnCount", "LongMethod") @Suppress("LongMethod")
fun ServiceType.toUsernameGeneratorRequest(website: String?): UsernameGeneratorRequest.Forwarded? { fun ServiceType.toUsernameGeneratorRequest(website: String?): UsernameGeneratorRequest.Forwarded? {
return when (this) { return when (this) {
is ServiceType.AddyIo -> { is ServiceType.AddyIo -> {

View file

@ -287,7 +287,6 @@ class VaultItemListingViewModel @Inject constructor(
sendEvent(VaultItemListingEvent.NavigateToSendItem(id = action.sendId)) sendEvent(VaultItemListingEvent.NavigateToSendItem(id = action.sendId))
} }
@Suppress("ReturnCount")
private fun handleItemClick(action: VaultItemListingsAction.ItemClick) { private fun handleItemClick(action: VaultItemListingsAction.ItemClick) {
if (state.isAutofill) { if (state.isAutofill) {
val cipherView = getCipherViewOrNull(action.id) ?: return val cipherView = getCipherViewOrNull(action.id) ?: return

View file

@ -79,7 +79,7 @@ class QrCodeScanViewModel @Inject constructor(
) )
} }
@Suppress("NestedBlockDepth", "ReturnCount", "MagicNumber") @Suppress("NestedBlockDepth", "MagicNumber")
private fun areParametersValid(scannedCode: String, parameters: Set<String>): Boolean { private fun areParametersValid(scannedCode: String, parameters: Set<String>): Boolean {
parameters.forEach { parameter -> parameters.forEach { parameter ->
Uri.parse(scannedCode).getQueryParameter(parameter)?.let { value -> Uri.parse(scannedCode).getQueryParameter(parameter)?.let { value ->

View file

@ -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 * display names. This function is necessary if we want to show the nested collections for a
* specific collection. * specific collection.
*/ */
@Suppress("ReturnCount")
fun List<CollectionView>.getCollections(collectionId: String): List<CollectionView> { fun List<CollectionView>.getCollections(collectionId: String): List<CollectionView> {
val currentCollection = this.find { it.id == collectionId } ?: return emptyList() val currentCollection = this.find { it.id == collectionId } ?: return emptyList()

View file

@ -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. * 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. * 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> { fun List<FolderView>.getFolders(folderId: String): List<FolderView> {
val currentFolder = this.find { it.id == folderId } ?: return emptyList() val currentFolder = this.find { it.id == folderId } ?: return emptyList()

View file

@ -142,7 +142,6 @@ fun VaultData.toViewState(
/** /**
* Method to build the icon data for login item icons. * Method to build the icon data for login item icons.
*/ */
@Suppress("ReturnCount")
fun List<LoginUriView>?.toLoginIconData( fun List<LoginUriView>?.toLoginIconData(
isIconLoadingDisabled: Boolean, isIconLoadingDisabled: Boolean,
baseIconUrl: String, baseIconUrl: String,

View file

@ -33,7 +33,7 @@ class CipherViewExtensionsTest {
// This visibility state should be preserved // This visibility state should be preserved
isVisible = true, isVisible = true,
canViewPassword = false, canViewPassword = false,
) ),
), ),
), ),
isPremiumUser = true, isPremiumUser = true,
@ -58,7 +58,7 @@ class CipherViewExtensionsTest {
password = "password", password = "password",
isVisible = true, isVisible = true,
canViewPassword = false, canViewPassword = false,
) ),
), ),
), ),
viewState, viewState,

View file

@ -595,7 +595,7 @@ style:
RedundantVisibilityModifierRule: RedundantVisibilityModifierRule:
active: false active: false
ReturnCount: ReturnCount:
active: true active: false
max: 2 max: 2
excludedFunctions: [ 'equals' ] excludedFunctions: [ 'equals' ]
excludeLabeled: false excludeLabeled: false