diff --git a/Sources/mas/AppStore/Downloader.swift b/Sources/mas/AppStore/Downloader.swift index bb09f3d..6435ff6 100644 --- a/Sources/mas/AppStore/Downloader.swift +++ b/Sources/mas/AppStore/Downloader.swift @@ -47,7 +47,8 @@ private func downloadWithRetries(_ appID: AppID, purchase: Bool = false, attempt } // If the download failed due to network issues, try again. Otherwise, fail immediately. - guard case MASError.downloadFailed(let downloadError) = error, + guard + case MASError.downloadFailed(let downloadError) = error, case NSURLErrorDomain = downloadError?.domain else { throw error diff --git a/Sources/mas/AppStore/PurchaseDownloadObserver.swift b/Sources/mas/AppStore/PurchaseDownloadObserver.swift index c6709cf..30b968c 100644 --- a/Sources/mas/AppStore/PurchaseDownloadObserver.swift +++ b/Sources/mas/AppStore/PurchaseDownloadObserver.swift @@ -20,7 +20,8 @@ class PurchaseDownloadObserver: NSObject, CKDownloadQueueObserver { } func downloadQueue(_ queue: CKDownloadQueue, statusChangedFor download: SSDownload) { - guard download.metadata.itemIdentifier == purchase.itemIdentifier, + guard + download.metadata.itemIdentifier == purchase.itemIdentifier, let status = download.status else { return @@ -42,7 +43,8 @@ class PurchaseDownloadObserver: NSObject, CKDownloadQueueObserver { } func downloadQueue(_: CKDownloadQueue, changedWithRemoval download: SSDownload) { - guard download.metadata.itemIdentifier == purchase.itemIdentifier, + guard + download.metadata.itemIdentifier == purchase.itemIdentifier, let status = download.status else { return diff --git a/Sources/mas/Controllers/MasStoreSearch.swift b/Sources/mas/Controllers/MasStoreSearch.swift index e7bb192..a046778 100644 --- a/Sources/mas/Controllers/MasStoreSearch.swift +++ b/Sources/mas/Controllers/MasStoreSearch.swift @@ -85,7 +85,8 @@ class MasStoreSearch: StoreSearch { self.scrapeAppStoreVersion(pageURL) } .map { pageVersion in - guard let pageVersion, + guard + let pageVersion, let searchVersion = Version(tolerant: result.version), pageVersion > searchVersion else { @@ -125,7 +126,8 @@ class MasStoreSearch: StoreSearch { networkManager.loadData(from: pageURL) } .map { data in - guard let html = String(data: data, encoding: .utf8), + guard + let html = String(data: data, encoding: .utf8), let capture = Self.appVersionExpression.firstMatch(in: html)?.captures[0], let version = Version(tolerant: capture) else { diff --git a/Sources/mas/Models/SoftwareProduct.swift b/Sources/mas/Models/SoftwareProduct.swift index 7b882c5..29c393f 100644 --- a/Sources/mas/Models/SoftwareProduct.swift +++ b/Sources/mas/Models/SoftwareProduct.swift @@ -45,7 +45,8 @@ extension SoftwareProduct { // The App Store does not enforce semantic versioning, but we assume most apps follow versioning // schemes that increase numerically over time. - guard let semanticBundleVersion = Version(tolerant: bundleVersion), + guard + let semanticBundleVersion = Version(tolerant: bundleVersion), let semanticAppStoreVersion = Version(tolerant: storeApp.version) else { // If a version string can't be parsed as a Semantic Version, our best effort is to check for diff --git a/Tests/masTests/Extensions/Bundle+JSON.swift b/Tests/masTests/Extensions/Bundle+JSON.swift index 3c9628c..d74c2c0 100644 --- a/Tests/masTests/Extensions/Bundle+JSON.swift +++ b/Tests/masTests/Extensions/Bundle+JSON.swift @@ -30,7 +30,8 @@ extension Bundle { .bundleURL .deletingLastPathComponent() .appendingPathComponent("mas_masTests.bundle") - guard let bundle = Bundle(url: bundleURL), + guard + let bundle = Bundle(url: bundleURL), let url = bundle.url(for: fileName) else { fatalError("Unable to load file \(fileName)") diff --git a/docs/sample.swift b/docs/sample.swift index fd7091e..17fc5d4 100644 --- a/docs/sample.swift +++ b/docs/sample.swift @@ -90,11 +90,14 @@ private extension MyClass { guard let singleTest = somethingFailable() else { return } guard statementThatShouldBeTrue else { return } -// If there is one long expression to guard or multiple expressions -// move else to next line -guard let oneItem = somethingFailable(), +// If a guard clause requires multiple lines, chop down, then start `else` new line +// In this case, always chop down else clause. +guard + let oneItem = somethingFailable(), let secondItem = somethingFailable2() -else { return } +else { + return +} // If the return in else is long, move to next line guard let something = somethingFailable() else {