Eliminate magic numbers.

Partial #592

Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com>
This commit is contained in:
Ross Goldberg 2024-10-21 08:58:18 -04:00
parent fcf8ba29f6
commit ee28af69df
No known key found for this signature in database
3 changed files with 9 additions and 4 deletions

View file

@ -10,6 +10,8 @@ import CommerceKit
import PromiseKit
import StoreFoundation
private let timeout = 30.0
extension ISStoreAccount: StoreAccount {
static var primaryAccount: Promise<ISStoreAccount> {
if #available(macOS 10.13, *) {
@ -20,7 +22,7 @@ extension ISStoreAccount: StoreAccount {
seal.fulfill(storeAccount)
}
},
after(seconds: 30)
after(seconds: timeout)
.then {
Promise(error: MASError.notSignedIn)
}
@ -79,7 +81,7 @@ extension ISStoreAccount: StoreAccount {
return race(
signInPromise,
after(seconds: 30)
after(seconds: timeout)
.then {
Promise(error: MASError.signInFailed(error: nil))
}

View file

@ -65,6 +65,7 @@ struct ProgressState {
let phase: String
var percentage: String {
// swiftlint:disable:next no_magic_numbers
String(format: "%.1f%%", floor(percentComplete * 1000) / 10)
}
}

View file

@ -17,8 +17,10 @@ enum SearchResultFormatter {
/// - includePrice: Indicates whether to include prices in the output
/// - Returns: Multiline text output.
static func format(results: [SearchResult], includePrice: Bool = false) -> String {
// find longest appName for formatting, default 50
let maxLength = results.map(\.trackName.count).max() ?? 50
guard let maxLength = results.map(\.trackName.count).max() else {
return ""
}
var output = ""
for result in results {