From ee06a9ce6b9273d5bf387998ae4878dfc418ad3d Mon Sep 17 00:00:00 2001 From: Matt Czech Date: Thu, 3 Oct 2024 09:50:28 -0500 Subject: [PATCH] PM-13135: Fix linting and Sendable warnings --- .../Core/Auth/Models/Enum/TwoFactorUnlockMethod.swift | 2 +- .../Auth/Models/Response/IdentityTokenErrorModel.swift | 8 ++++---- .../Core/Auth/Services/KeychainRepository.swift | 4 ++-- .../Core/Platform/Services/ClientServiceTests.swift | 2 ++ .../Core/Tools/Repositories/SendRepositoryTests.swift | 2 ++ .../Core/Vault/Services/PolicyServiceTests.swift | 6 ++++-- BitwardenShared/UI/Auth/AuthCoordinator.swift | 2 +- ...agate.swift => MockMasterPasswordUpdateDelegate.swift} | 0 .../UI/Platform/Application/AppProcessor.swift | 2 +- .../Platform/Application/Appearance/StyleGuideFont.swift | 2 ++ .../UI/Tools/Send/Send/SendList/SendListSection.swift | 2 +- .../ViewLoginItem/Extensions/CipherViewUpdateTests.swift | 2 +- 12 files changed, 21 insertions(+), 13 deletions(-) rename BitwardenShared/UI/Auth/CompleteRegistration/MasterPasswordGenerator/TestHelpers/{MockMasterPasswordUpdateDeleagate.swift => MockMasterPasswordUpdateDelegate.swift} (100%) diff --git a/BitwardenShared/Core/Auth/Models/Enum/TwoFactorUnlockMethod.swift b/BitwardenShared/Core/Auth/Models/Enum/TwoFactorUnlockMethod.swift index d04b3cc1a3..c6cc1f2aaa 100644 --- a/BitwardenShared/Core/Auth/Models/Enum/TwoFactorUnlockMethod.swift +++ b/BitwardenShared/Core/Auth/Models/Enum/TwoFactorUnlockMethod.swift @@ -1,7 +1,7 @@ /// An enumeration of methods used to unlock the user's vault after two-factor authentication /// completes successfully. /// -public enum TwoFactorUnlockMethod: Equatable { +public enum TwoFactorUnlockMethod: Equatable, Sendable { /// The vault should be unlocked with the response from logging in with another device. case loginWithDevice(key: String, masterPasswordHash: String?, privateKey: String) diff --git a/BitwardenShared/Core/Auth/Models/Response/IdentityTokenErrorModel.swift b/BitwardenShared/Core/Auth/Models/Response/IdentityTokenErrorModel.swift index f8c0417c4f..fa32c904c6 100644 --- a/BitwardenShared/Core/Auth/Models/Response/IdentityTokenErrorModel.swift +++ b/BitwardenShared/Core/Auth/Models/Response/IdentityTokenErrorModel.swift @@ -85,7 +85,7 @@ public struct AuthMethodsData: Codable, Equatable, Sendable { // MARK: - Duo /// Struct with information regarding Duo two factor authentication -public struct Duo: Codable, Equatable { +public struct Duo: Codable, Equatable, Sendable { enum CodingKeys: String, CodingKey { case authUrl = "AuthUrl" case host = "Host" @@ -110,7 +110,7 @@ public struct Email: Codable, Equatable, Sendable { // MARK: - WebAuthn /// Struct with information regarding WebAuthn two factor authentication -public struct WebAuthn: Codable, Equatable { +public struct WebAuthn: Codable, Equatable, Sendable { /// Credentials allowed to be used to solve the challenge let allowCredentials: [AllowCredential]? @@ -136,7 +136,7 @@ public struct WebAuthn: Codable, Equatable { // MARK: - AllowCredential /// Struct with information regarding user credentials for WebAuthn two factor authentication -public struct AllowCredential: Codable, Equatable { +public struct AllowCredential: Codable, Equatable, Sendable { /// Public key identifier let id: String? @@ -147,7 +147,7 @@ public struct AllowCredential: Codable, Equatable { // MARK: - Yubikey /// Struct with information for two factor authentication with Yubikeys -public struct Yubikey: Codable, Equatable { +public struct Yubikey: Codable, Equatable, Sendable { enum CodingKeys: String, CodingKey { case nfc = "Nfc" } diff --git a/BitwardenShared/Core/Auth/Services/KeychainRepository.swift b/BitwardenShared/Core/Auth/Services/KeychainRepository.swift index 6cc67237f0..18f277ffac 100644 --- a/BitwardenShared/Core/Auth/Services/KeychainRepository.swift +++ b/BitwardenShared/Core/Auth/Services/KeychainRepository.swift @@ -243,8 +243,8 @@ class DefaultKeychainRepository: KeychainRepository { ) if let resultDictionary = foundItem as? [String: Any], - let data = resultDictionary[kSecValueData as String] as? Data { - let string = String(decoding: data, as: UTF8.self) + let data = resultDictionary[kSecValueData as String] as? Data, + let string = String(data: data, encoding: .utf8) { guard !string.isEmpty else { throw KeychainServiceError.keyNotFound(item) } diff --git a/BitwardenShared/Core/Platform/Services/ClientServiceTests.swift b/BitwardenShared/Core/Platform/Services/ClientServiceTests.swift index 77432c450c..c37b4f2177 100644 --- a/BitwardenShared/Core/Platform/Services/ClientServiceTests.swift +++ b/BitwardenShared/Core/Platform/Services/ClientServiceTests.swift @@ -3,6 +3,8 @@ import XCTest @testable import BitwardenShared +// swiftlint:disable file_length + final class ClientServiceTests: BitwardenTestCase { // swiftlint:disable:this type_body_length var clientBuilder: MockClientBuilder! var configService: MockConfigService! diff --git a/BitwardenShared/Core/Tools/Repositories/SendRepositoryTests.swift b/BitwardenShared/Core/Tools/Repositories/SendRepositoryTests.swift index e1d949416f..d2e3007f77 100644 --- a/BitwardenShared/Core/Tools/Repositories/SendRepositoryTests.swift +++ b/BitwardenShared/Core/Tools/Repositories/SendRepositoryTests.swift @@ -4,6 +4,8 @@ import XCTest @testable import BitwardenShared +// swiftlint:disable file_length + // MARK: - SendRepositoryTests class SendRepositoryTests: BitwardenTestCase { // swiftlint:disable:this type_body_length diff --git a/BitwardenShared/Core/Vault/Services/PolicyServiceTests.swift b/BitwardenShared/Core/Vault/Services/PolicyServiceTests.swift index 22f719264c..045df7a20b 100644 --- a/BitwardenShared/Core/Vault/Services/PolicyServiceTests.swift +++ b/BitwardenShared/Core/Vault/Services/PolicyServiceTests.swift @@ -161,13 +161,15 @@ class PolicyServiceTests: BitwardenTestCase { // swiftlint:disable:this type_bod passwordGeneratorPolicy, .fixture( data: [ - PolicyOptionType.overridePasswordType.rawValue: .string(PasswordGeneratorType.password.rawValue), + PolicyOptionType.overridePasswordType.rawValue: + .string(PasswordGeneratorType.password.rawValue), ], type: .passwordGenerator ), .fixture( data: [ - PolicyOptionType.overridePasswordType.rawValue: .string(PasswordGeneratorType.passphrase.rawValue), + PolicyOptionType.overridePasswordType.rawValue: + .string(PasswordGeneratorType.passphrase.rawValue), ], type: .passwordGenerator ), diff --git a/BitwardenShared/UI/Auth/AuthCoordinator.swift b/BitwardenShared/UI/Auth/AuthCoordinator.swift index 8560e91efd..ccd511cbd8 100644 --- a/BitwardenShared/UI/Auth/AuthCoordinator.swift +++ b/BitwardenShared/UI/Auth/AuthCoordinator.swift @@ -50,8 +50,8 @@ final class AuthCoordinator: NSObject, // swiftlint:disable:this type_body_lengt & HasEnvironmentService & HasErrorReporter & HasGeneratorRepository - & HasNotificationCenterService & HasNFCReaderService + & HasNotificationCenterService & HasOrganizationAPIService & HasPolicyService & HasSettingsRepository diff --git a/BitwardenShared/UI/Auth/CompleteRegistration/MasterPasswordGenerator/TestHelpers/MockMasterPasswordUpdateDeleagate.swift b/BitwardenShared/UI/Auth/CompleteRegistration/MasterPasswordGenerator/TestHelpers/MockMasterPasswordUpdateDelegate.swift similarity index 100% rename from BitwardenShared/UI/Auth/CompleteRegistration/MasterPasswordGenerator/TestHelpers/MockMasterPasswordUpdateDeleagate.swift rename to BitwardenShared/UI/Auth/CompleteRegistration/MasterPasswordGenerator/TestHelpers/MockMasterPasswordUpdateDelegate.swift diff --git a/BitwardenShared/UI/Platform/Application/AppProcessor.swift b/BitwardenShared/UI/Platform/Application/AppProcessor.swift index 4462d60c6e..52503e332d 100644 --- a/BitwardenShared/UI/Platform/Application/AppProcessor.swift +++ b/BitwardenShared/UI/Platform/Application/AppProcessor.swift @@ -210,7 +210,7 @@ public class AppProcessor { let accounts = try await services.stateService.getAccounts() for account in accounts { let userId = account.profile.userId - guard let progress = try await services.stateService.getAccountSetupAutofill(userId: userId), + guard let progress = await services.stateService.getAccountSetupAutofill(userId: userId), progress != .complete else { continue } try await services.stateService.setAccountSetupAutofill(.complete, userId: userId) diff --git a/BitwardenShared/UI/Platform/Application/Appearance/StyleGuideFont.swift b/BitwardenShared/UI/Platform/Application/Appearance/StyleGuideFont.swift index 14f8031b7e..f6bd12d849 100644 --- a/BitwardenShared/UI/Platform/Application/Appearance/StyleGuideFont.swift +++ b/BitwardenShared/UI/Platform/Application/Appearance/StyleGuideFont.swift @@ -1,5 +1,7 @@ import SwiftUI +// swiftlint:disable file_length + /// A `StyleGuideFont` contains the font to use for a specific style. /// struct StyleGuideFont { diff --git a/BitwardenShared/UI/Tools/Send/Send/SendList/SendListSection.swift b/BitwardenShared/UI/Tools/Send/Send/SendList/SendListSection.swift index cf32cb30b5..2918948513 100644 --- a/BitwardenShared/UI/Tools/Send/Send/SendList/SendListSection.swift +++ b/BitwardenShared/UI/Tools/Send/Send/SendList/SendListSection.swift @@ -2,7 +2,7 @@ /// Data model for a section of items in the send list. /// -public struct SendListSection: Equatable, Identifiable { +public struct SendListSection: Equatable, Identifiable, Sendable { // MARK: Properties /// The identifier for the section. diff --git a/BitwardenShared/UI/Vault/VaultItem/ViewItem/ViewLoginItem/Extensions/CipherViewUpdateTests.swift b/BitwardenShared/UI/Vault/VaultItem/ViewItem/ViewLoginItem/Extensions/CipherViewUpdateTests.swift index f8e00c620f..e29b591529 100644 --- a/BitwardenShared/UI/Vault/VaultItem/ViewItem/ViewLoginItem/Extensions/CipherViewUpdateTests.swift +++ b/BitwardenShared/UI/Vault/VaultItem/ViewItem/ViewLoginItem/Extensions/CipherViewUpdateTests.swift @@ -3,7 +3,7 @@ import XCTest @testable import BitwardenShared -final class CipherViewUpdateTests: BitwardenTestCase { +final class CipherViewUpdateTests: BitwardenTestCase { // swiftlint:disable:this type_body_length // MARK: Properties var cipherItemState: CipherItemState!