From d7074db06f28e405793a65803c1c7719caffc93e Mon Sep 17 00:00:00 2001 From: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> Date: Mon, 21 Oct 2024 07:29:13 -0400 Subject: [PATCH] Remove unnecessary `else` blocks. Partial #592 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> --- Sources/mas/AppStore/ISStoreAccount.swift | 30 +++++++++++------------ Sources/mas/Commands/Upgrade.swift | 8 +++--- Sources/mas/Errors/MASError.swift | 18 +++++--------- 3 files changed, 25 insertions(+), 31 deletions(-) diff --git a/Sources/mas/AppStore/ISStoreAccount.swift b/Sources/mas/AppStore/ISStoreAccount.swift index f1d4fe0..414dc29 100644 --- a/Sources/mas/AppStore/ISStoreAccount.swift +++ b/Sources/mas/AppStore/ISStoreAccount.swift @@ -25,9 +25,9 @@ extension ISStoreAccount: StoreAccount { Promise(error: MASError.notSignedIn) } ) - } else { - return .value(CKAccountStore.shared().primaryAccount) } + + return .value(CKAccountStore.shared().primaryAccount) } static func signIn(username: String, password: String, systemDialog: Bool) -> Promise { @@ -70,20 +70,20 @@ extension ISStoreAccount: StoreAccount { if systemDialog { return signInPromise - } else { - context.demoMode = true - context.demoAccountName = username - context.demoAccountPassword = password - context.demoAutologinMode = true - - return race( - signInPromise, - after(seconds: 30) - .then { - Promise(error: MASError.signInFailed(error: nil)) - } - ) } + + context.demoMode = true + context.demoAccountName = username + context.demoAccountPassword = password + context.demoAutologinMode = true + + return race( + signInPromise, + after(seconds: 30) + .then { + Promise(error: MASError.signInFailed(error: nil)) + } + ) } } } diff --git a/Sources/mas/Commands/Upgrade.swift b/Sources/mas/Commands/Upgrade.swift index a588af2..bd23d93 100644 --- a/Sources/mas/Commands/Upgrade.swift +++ b/Sources/mas/Commands/Upgrade.swift @@ -60,12 +60,12 @@ extension Mas { ? appLibrary.installedApps : appIDs.compactMap { if let appID = AppID($0) { - // if argument an AppID, lookup app by id using argument + // argument is an AppID, lookup app by id using argument return appLibrary.installedApp(withAppID: appID) - } else { - // if argument not an AppID, lookup app by name using argument - return appLibrary.installedApp(named: $0) } + + // argument is not an AppID, lookup app by name using argument + return appLibrary.installedApp(named: $0) } let promises = apps.map { installedApp in diff --git a/Sources/mas/Errors/MASError.swift b/Sources/mas/Errors/MASError.swift index 4d4155a..28e6754 100644 --- a/Sources/mas/Errors/MASError.swift +++ b/Sources/mas/Errors/MASError.swift @@ -51,29 +51,25 @@ extension MASError: CustomStringConvertible { case .failed(let error): if let error { return "Failed: \(error.localizedDescription)" - } else { - return "Failed" } + return "Failed" case .signInFailed(let error): if let error { return "Sign in failed: \(error.localizedDescription)" - } else { - return "Sign in failed" } + return "Sign in failed" case .alreadySignedIn(let accountId): return "Already signed in as \(accountId)" case .purchaseFailed(let error): if let error { return "Download request failed: \(error.localizedDescription)" - } else { - return "Download request failed" } + return "Download request failed" case .downloadFailed(let error): if let error { return "Download failed: \(error.localizedDescription)" - } else { - return "Download failed" } + return "Download failed" case .noDownloads: return "No downloads began" case .cancelled: @@ -94,12 +90,10 @@ extension MASError: CustomStringConvertible { if let data { if let unparsable = String(data: data, encoding: .utf8) { return "Unable to parse response as JSON: \n\(unparsable)" - } else { - return "Received defective response" } - } else { - return "Received empty response" + return "Received defective response" } + return "Received empty response" } } }