diff --git a/MasKit/AppStore/Downloader.swift b/MasKit/AppStore/Downloader.swift index 8c034a9..936a7e7 100644 --- a/MasKit/AppStore/Downloader.swift +++ b/MasKit/AppStore/Downloader.swift @@ -19,7 +19,7 @@ func download(_ adamId: UInt64) -> MASError? { } guard let storeAccount = account as? ISStoreAccount - else { fatalError("Unable to cast StoreAccount to ISStoreAccount") } + else { fatalError("Unable to cast StoreAccount to ISStoreAccount") } let purchase = SSPurchase(adamId: adamId, account: storeAccount) var purchaseError: MASError? diff --git a/MasKit/AppStore/ISStoreAccount.swift b/MasKit/AppStore/ISStoreAccount.swift index ea7fa02..e2211a4 100644 --- a/MasKit/AppStore/ISStoreAccount.swift +++ b/MasKit/AppStore/ISStoreAccount.swift @@ -6,8 +6,8 @@ // Copyright (c) 2015 Andrew Naylor. All rights reserved. // -import StoreFoundation import CommerceKit +import StoreFoundation extension ISStoreAccount: StoreAccount { static var primaryAccountIsPresentAndSignedIn: Bool { diff --git a/MasKit/AppStore/PurchaseDownloadObserver.swift b/MasKit/AppStore/PurchaseDownloadObserver.swift index 8db8242..c488ad6 100644 --- a/MasKit/AppStore/PurchaseDownloadObserver.swift +++ b/MasKit/AppStore/PurchaseDownloadObserver.swift @@ -31,7 +31,7 @@ import StoreFoundation } } - func downloadQueue(_ queue: CKDownloadQueue, changedWithAddition download: SSDownload) { + func downloadQueue(_: CKDownloadQueue, changedWithAddition download: SSDownload) { guard download.metadata.itemIdentifier == purchase.itemIdentifier else { return } @@ -39,9 +39,9 @@ import StoreFoundation printInfo("Downloading \(download.metadata.title)") } - func downloadQueue(_ queue: CKDownloadQueue, changedWithRemoval download: SSDownload) { + func downloadQueue(_: CKDownloadQueue, changedWithRemoval download: SSDownload) { guard download.metadata.itemIdentifier == purchase.itemIdentifier, - let status = download.status else { + let status = download.status else { return } @@ -76,7 +76,7 @@ func progress(_ state: ProgressState) { let completeLength = Int(state.percentComplete * Float(barLength)) var bar = "" - for index in 0.. Result<(), MASError> { + public func run(_: Options) -> Result<(), MASError> { if let account = ISStoreAccount.primaryAccount { print(String(describing: account.identifier)) } else { diff --git a/MasKit/Commands/Home.swift b/MasKit/Commands/Home.swift index 192a990..11a1dc7 100644 --- a/MasKit/Commands/Home.swift +++ b/MasKit/Commands/Home.swift @@ -31,9 +31,9 @@ public struct HomeCommand: CommandProtocol { public func run(_ options: HomeOptions) -> Result<(), MASError> { do { guard let result = try storeSearch.lookup(app: options.appId) - else { - print("No results found") - return .failure(.noSearchResultsFound) + else { + print("No results found") + return .failure(.noSearchResultsFound) } do { diff --git a/MasKit/Commands/Info.swift b/MasKit/Commands/Info.swift index bd936fa..17daae6 100644 --- a/MasKit/Commands/Info.swift +++ b/MasKit/Commands/Info.swift @@ -7,8 +7,8 @@ // import Commandant -import Result import Foundation +import Result /// Displays app details. Uses the iTunes Lookup API: /// https://affiliate.itunes.apple.com/resources/documentation/itunes-store-web-service-search-api/#lookup @@ -27,9 +27,9 @@ public struct InfoCommand: CommandProtocol { public func run(_ options: InfoOptions) -> Result<(), MASError> { do { guard let result = try storeSearch.lookup(app: options.appId) - else { - print("No results found") - return .failure(.noSearchResultsFound) + else { + print("No results found") + return .failure(.noSearchResultsFound) } print(AppInfoFormatter.format(app: result)) diff --git a/MasKit/Commands/Install.swift b/MasKit/Commands/Install.swift index 7202d7d..7284e41 100644 --- a/MasKit/Commands/Install.swift +++ b/MasKit/Commands/Install.swift @@ -7,8 +7,8 @@ // import Commandant -import Result import CommerceKit +import Result /// Installs previously purchased apps from the Mac App Store. public struct InstallCommand: CommandProtocol { @@ -54,7 +54,7 @@ public struct InstallOptions: OptionsProtocol { public static func create(_ appIds: [Int]) -> (_ forceInstall: Bool) -> InstallOptions { return { forceInstall in - return InstallOptions(appIds: appIds.map {UInt64($0)}, forceInstall: forceInstall) + InstallOptions(appIds: appIds.map { UInt64($0) }, forceInstall: forceInstall) } } diff --git a/MasKit/Commands/List.swift b/MasKit/Commands/List.swift index 357c86f..9af6d0f 100644 --- a/MasKit/Commands/List.swift +++ b/MasKit/Commands/List.swift @@ -25,7 +25,7 @@ public struct ListCommand: CommandProtocol { } /// Runs the command. - public func run(_ options: Options) -> Result<(), MASError> { + public func run(_: Options) -> Result<(), MASError> { let products = appLibrary.installedApps if products.isEmpty { print("No installed apps found") diff --git a/MasKit/Commands/Lucky.swift b/MasKit/Commands/Lucky.swift index 89e5981..88265ab 100644 --- a/MasKit/Commands/Lucky.swift +++ b/MasKit/Commands/Lucky.swift @@ -7,8 +7,8 @@ // import Commandant -import Result import CommerceKit +import Result /// Command which installs the first search result. This is handy as many MAS titles /// can be long with embedded keywords. @@ -89,7 +89,7 @@ public struct LuckyOptions: OptionsProtocol { public static func create(_ appName: String) -> (_ forceInstall: Bool) -> LuckyOptions { return { forceInstall in - return LuckyOptions(appName: appName, forceInstall: forceInstall) + LuckyOptions(appName: appName, forceInstall: forceInstall) } } diff --git a/MasKit/Commands/Open.swift b/MasKit/Commands/Open.swift index 01e4008..3768387 100644 --- a/MasKit/Commands/Open.swift +++ b/MasKit/Commands/Open.swift @@ -27,7 +27,7 @@ public struct OpenCommand: CommandProtocol { public init(storeSearch: StoreSearch = MasStoreSearch(), openCommand: ExternalCommand = OpenSystemCommand()) { self.storeSearch = storeSearch - self.systemOpen = openCommand + systemOpen = openCommand } /// Runs the command. @@ -40,20 +40,20 @@ public struct OpenCommand: CommandProtocol { } guard let appId = Int(options.appId) - else { - print("Invalid app ID") - return .failure(.noSearchResultsFound) + else { + print("Invalid app ID") + return .failure(.noSearchResultsFound) } guard let result = try storeSearch.lookup(app: appId) - else { - print("No results found") - return .failure(.noSearchResultsFound) + else { + print("No results found") + return .failure(.noSearchResultsFound) } guard var url = URLComponents(string: result.trackViewUrl) - else { - return .failure(.searchFailed) + else { + return .failure(.searchFailed) } url.scheme = masScheme diff --git a/MasKit/Commands/Outdated.swift b/MasKit/Commands/Outdated.swift index 758b397..fe1a3f5 100644 --- a/MasKit/Commands/Outdated.swift +++ b/MasKit/Commands/Outdated.swift @@ -7,8 +7,8 @@ // import Commandant -import Result import CommerceKit +import Result /// Command which displays a list of installed apps which have available updates /// ready to be installed from the Mac App Store. @@ -27,15 +27,15 @@ public struct OutdatedCommand: CommandProtocol { } /// Runs the command. - public func run(_ options: Options) -> Result<(), MASError> { + public func run(_: Options) -> Result<(), MASError> { let updateController = CKUpdateController.shared() let updates = updateController?.availableUpdates() for update in updates! { if let installed = appLibrary.installedApp(forBundleId: update.bundleID) { // Display version of installed app compared to available update. print(""" - \(update.itemIdentifier) \(update.title) (\(installed.bundleVersion) -> \(update.bundleVersion)) - """) + \(update.itemIdentifier) \(update.title) (\(installed.bundleVersion) -> \(update.bundleVersion)) + """) } else { print("\(update.itemIdentifier) \(update.title) (unknown -> \(update.bundleVersion))") } diff --git a/MasKit/Commands/Reset.swift b/MasKit/Commands/Reset.swift index 06f190a..9ebc3da 100644 --- a/MasKit/Commands/Reset.swift +++ b/MasKit/Commands/Reset.swift @@ -7,8 +7,8 @@ // import Commandant -import Result import CommerceKit +import Result /// Kills several macOS processes as a means to reset the app store. public struct ResetCommand: CommandProtocol { @@ -21,22 +21,22 @@ public struct ResetCommand: CommandProtocol { /// Runs the command. public func run(_ options: Options) -> Result<(), MASError> { /* - The "Reset Application" command in the Mac App Store debug menu performs - the following steps - + The "Reset Application" command in the Mac App Store debug menu performs + the following steps + - killall Dock - killall storeagent (storeagent no longer exists) - rm com.apple.appstore download directory - clear cookies (appears to be a no-op) - As storeagent no longer exists we will implement a slight variant and kill all - App Store-associated processes + As storeagent no longer exists we will implement a slight variant and kill all + App Store-associated processes - storeaccountd - storeassetd - storedownloadd - storeinstalld - storelegacy - */ + */ // Kill processes let killProcs = [ @@ -60,7 +60,7 @@ public struct ResetCommand: CommandProtocol { kill.launch() kill.waitUntilExit() - if kill.terminationStatus != 0 && options.debug { + if kill.terminationStatus != 0, options.debug { let output = stderr.fileHandleForReading.readDataToEndOfFile() printInfo("killall failed:\r\n\(String(data: output, encoding: String.Encoding.utf8)!)") } diff --git a/MasKit/Commands/SignIn.swift b/MasKit/Commands/SignIn.swift index 830b47b..f1c1878 100644 --- a/MasKit/Commands/SignIn.swift +++ b/MasKit/Commands/SignIn.swift @@ -31,7 +31,7 @@ public struct SignInCommand: CommandProtocol { printInfo("Signing in to Apple ID: \(options.username)") let password: String = { - if options.password == "" && !options.dialog { + if options.password == "", !options.dialog { return String(validatingUTF8: getpass("Password: "))! } return options.password @@ -56,8 +56,8 @@ public struct SignInOptions: OptionsProtocol { static func create(username: String) -> (_ password: String) -> (_ dialog: Bool) -> SignInOptions { return { password in { dialog in - return SignInOptions(username: username, password: password, dialog: dialog) - }} + SignInOptions(username: username, password: password, dialog: dialog) + } } } public static func evaluate(_ mode: CommandMode) -> Result> { diff --git a/MasKit/Commands/SignOut.swift b/MasKit/Commands/SignOut.swift index f027549..501803c 100644 --- a/MasKit/Commands/SignOut.swift +++ b/MasKit/Commands/SignOut.swift @@ -7,8 +7,8 @@ // import Commandant -import Result import CommerceKit +import Result public struct SignOutCommand: CommandProtocol { public typealias Options = NoOptions @@ -18,7 +18,7 @@ public struct SignOutCommand: CommandProtocol { public init() {} /// Runs the command. - public func run(_ options: Options) -> Result<(), MASError> { + public func run(_: Options) -> Result<(), MASError> { if #available(macOS 10.13, *) { let accountService: ISAccountService = ISServiceProxy.genericShared().accountService accountService.signOut() diff --git a/MasKit/Commands/Uninstall.swift b/MasKit/Commands/Uninstall.swift index ad40284..af63268 100644 --- a/MasKit/Commands/Uninstall.swift +++ b/MasKit/Commands/Uninstall.swift @@ -7,8 +7,8 @@ // import Commandant -import Result import CommerceKit +import Result import StoreFoundation /// Command which uninstalls apps managed by the Mac App Store. @@ -64,7 +64,7 @@ public struct UninstallOptions: OptionsProtocol { static func create(_ appId: Int) -> (_ dryRun: Bool) -> UninstallOptions { return { dryRun in - return UninstallOptions(appId: appId, dryRun: dryRun) + UninstallOptions(appId: appId, dryRun: dryRun) } } diff --git a/MasKit/Commands/Upgrade.swift b/MasKit/Commands/Upgrade.swift index cb4ebfe..fb993d1 100644 --- a/MasKit/Commands/Upgrade.swift +++ b/MasKit/Commands/Upgrade.swift @@ -7,8 +7,8 @@ // import Commandant -import Result import CommerceKit +import Result /// Command which upgrades apps with new versions available in the Mac App Store. public struct UpgradeCommand: CommandProtocol { diff --git a/MasKit/Commands/Vendor.swift b/MasKit/Commands/Vendor.swift index dfc6904..74f7c53 100644 --- a/MasKit/Commands/Vendor.swift +++ b/MasKit/Commands/Vendor.swift @@ -31,13 +31,13 @@ public struct VendorCommand: CommandProtocol { public func run(_ options: VendorOptions) -> Result<(), MASError> { do { guard let result = try storeSearch.lookup(app: options.appId) - else { - print("No results found") - return .failure(.noSearchResultsFound) + else { + print("No results found") + return .failure(.noSearchResultsFound) } guard let vendorWebsite = result.sellerUrl - else { throw MASError.noVendorWebsite } + else { throw MASError.noVendorWebsite } do { try openCommand.run(arguments: vendorWebsite) diff --git a/MasKit/Commands/Version.swift b/MasKit/Commands/Version.swift index ad091d2..64c2e33 100644 --- a/MasKit/Commands/Version.swift +++ b/MasKit/Commands/Version.swift @@ -18,7 +18,7 @@ public struct VersionCommand: CommandProtocol { public init() {} /// Runs the command. - public func run(_ options: Options) -> Result<(), MASError> { + public func run(_: Options) -> Result<(), MASError> { let plist = Bundle.main.infoDictionary if let versionString = plist?["CFBundleShortVersionString"] { print(versionString) diff --git a/MasKit/Controllers/MasAppLibrary.swift b/MasKit/Controllers/MasAppLibrary.swift index 8c1f5b8..99dbe23 100644 --- a/MasKit/Controllers/MasAppLibrary.swift +++ b/MasKit/Controllers/MasAppLibrary.swift @@ -17,7 +17,7 @@ public class MasAppLibrary: AppLibrary { public lazy var installedApps: [SoftwareProduct] = { var appList = [SoftwareProduct]() guard let products = softwareMap.allProducts() - else { return appList } + else { return appList } appList.append(contentsOf: products) return products }() diff --git a/MasKit/Controllers/MasStoreSearch.swift b/MasKit/Controllers/MasStoreSearch.swift index 0d9cb0c..b4f6778 100644 --- a/MasKit/Controllers/MasStoreSearch.swift +++ b/MasKit/Controllers/MasStoreSearch.swift @@ -22,17 +22,17 @@ public class MasStoreSearch: StoreSearch { /// - Throws: Error if there is a problem with the network request. public func search(for appName: String) throws -> SearchResultList { guard let url = searchURL(for: appName) - else { throw MASError.urlEncoding } + else { throw MASError.urlEncoding } let result = networkManager.loadDataSync(from: url) // Unwrap network result guard case let .success(data) = result - else { - if case let .failure(error) = result { - throw error - } - throw MASError.noData + else { + if case let .failure(error) = result { + throw error + } + throw MASError.noData } do { @@ -50,24 +50,24 @@ public class MasStoreSearch: StoreSearch { /// - Throws: Error if there is a problem with the network request. public func lookup(app appId: Int) throws -> SearchResult? { guard let url = lookupURL(forApp: appId) - else { throw MASError.urlEncoding } + else { throw MASError.urlEncoding } let result = networkManager.loadDataSync(from: url) // Unwrap network result guard case let .success(data) = result - else { - if case let .failure(error) = result { - throw error - } - throw MASError.noData + else { + if case let .failure(error) = result { + throw error + } + throw MASError.noData } do { let results = try JSONDecoder().decode(SearchResultList.self, from: data) guard let searchResult = results.results.first - else { return nil } + else { return nil } return searchResult } catch { diff --git a/MasKit/Errors/MASError.swift b/MasKit/Errors/MASError.swift index 6d738b6..17d8b2f 100644 --- a/MasKit/Errors/MASError.swift +++ b/MasKit/Errors/MASError.swift @@ -41,7 +41,7 @@ public enum MASError: Error, CustomStringConvertible, Equatable { "\nFor more info see: " + "https://github.com/mas-cli/mas/issues/164" - case .signInFailed(let error): + case let .signInFailed(error): if let error = error { return "Sign in failed: \(error.localizedDescription)" } else { @@ -51,14 +51,14 @@ public enum MASError: Error, CustomStringConvertible, Equatable { case .alreadySignedIn: return "Already signed in" - case .purchaseFailed(let error): + case let .purchaseFailed(error): if let error = error { return "Download request failed: \(error.localizedDescription)" } else { return "Download request failed" } - case .downloadFailed(let error): + case let .downloadFailed(error): if let error = error { return "Download failed: \(error.localizedDescription)" } else { diff --git a/MasKit/ExternalCommands/ExternalCommand.swift b/MasKit/ExternalCommands/ExternalCommand.swift index 6dd48f2..bf606c0 100644 --- a/MasKit/ExternalCommands/ExternalCommand.swift +++ b/MasKit/ExternalCommands/ExternalCommand.swift @@ -61,7 +61,7 @@ extension ExternalCommand { try process.run() } catch { printError("Unable to launch command") - //return throw Error() + // return throw Error() } } else { process.launchPath = binaryPath diff --git a/MasKit/Models/SearchResult.swift b/MasKit/Models/SearchResult.swift index d01c8fc..9f11899 100644 --- a/MasKit/Models/SearchResult.swift +++ b/MasKit/Models/SearchResult.swift @@ -33,8 +33,7 @@ public struct SearchResult: Decodable { trackCensoredName: String = "", trackName: String = "", trackViewUrl: String = "", - version: String = "" - ) { + version: String = "") { self.bundleId = bundleId self.currentVersionReleaseDate = currentVersionReleaseDate self.fileSizeBytes = fileSizeBytes diff --git a/MasKit/Network/NetworkManager.swift b/MasKit/Network/NetworkManager.swift index 03e3f0c..547d6bb 100644 --- a/MasKit/Network/NetworkManager.swift +++ b/MasKit/Network/NetworkManager.swift @@ -8,7 +8,7 @@ import Foundation -/// Network abstraction +/// Network abstraction public class NetworkManager { enum NetworkError: Error { case timeout diff --git a/MasKit/Network/NetworkResult.swift b/MasKit/Network/NetworkResult.swift index e3c7b2e..ee76979 100644 --- a/MasKit/Network/NetworkResult.swift +++ b/MasKit/Network/NetworkResult.swift @@ -14,10 +14,10 @@ enum NetworkResult { extension NetworkResult: Equatable { static func == (lhs: NetworkResult, rhs: NetworkResult) -> Bool { switch (lhs, rhs) { - case (let .success(data1), let .success(data2)): + case let (.success(data1), .success(data2)): return data1 == data2 - case (let .failure(error1), let .failure(error2)): + case let (.failure(error1), .failure(error2)): return error1.localizedDescription == error2.localizedDescription // case (.none, .none): diff --git a/MasKit/Network/URLSession+NetworkSession.swift b/MasKit/Network/URLSession+NetworkSession.swift index 92af759..2fce267 100644 --- a/MasKit/Network/URLSession+NetworkSession.swift +++ b/MasKit/Network/URLSession+NetworkSession.swift @@ -10,7 +10,7 @@ import Foundation extension URLSession: NetworkSession { @objc open func loadData(from url: URL, completionHandler: @escaping (Data?, Error?) -> Void) { - let task = dataTask(with: url) { (data, _, error) in + let task = dataTask(with: url) { data, _, error in completionHandler(data, error) } task.resume() diff --git a/MasKitTests/Commands/AccountCommandSpec.swift b/MasKitTests/Commands/AccountCommandSpec.swift index 41a5543..135b588 100644 --- a/MasKitTests/Commands/AccountCommandSpec.swift +++ b/MasKitTests/Commands/AccountCommandSpec.swift @@ -7,9 +7,9 @@ // @testable import MasKit -import Result -import Quick import Nimble +import Quick +import Result class AccountCommandSpec: QuickSpec { override func spec() { diff --git a/MasKitTests/Commands/HomeCommandSpec.swift b/MasKitTests/Commands/HomeCommandSpec.swift index 3997538..7a97be0 100644 --- a/MasKitTests/Commands/HomeCommandSpec.swift +++ b/MasKitTests/Commands/HomeCommandSpec.swift @@ -7,9 +7,9 @@ // @testable import MasKit -import Result -import Quick import Nimble +import Quick +import Result class HomeCommandSpec: QuickSpec { override func spec() { diff --git a/MasKitTests/Commands/InfoCommandSpec.swift b/MasKitTests/Commands/InfoCommandSpec.swift index 42dcf7c..d6b06fd 100644 --- a/MasKitTests/Commands/InfoCommandSpec.swift +++ b/MasKitTests/Commands/InfoCommandSpec.swift @@ -7,9 +7,9 @@ // @testable import MasKit -import Result -import Quick import Nimble +import Quick +import Result class InfoCommandSpec: QuickSpec { override func spec() { @@ -27,14 +27,14 @@ class InfoCommandSpec: QuickSpec { let storeSearch = StoreSearchMock() let cmd = InfoCommand(storeSearch: storeSearch) let expectedOutput = """ - Awesome App 1.0 [2.0] - By: Awesome Dev - Released: Jan 7, 2019 - Minimum OS: 10.14 - Size: 1 KB - From: https://awesome.app + Awesome App 1.0 [2.0] + By: Awesome Dev + Released: Jan 7, 2019 + Minimum OS: 10.14 + Size: 1 KB + From: https://awesome.app - """ + """ describe("Info command") { beforeEach { diff --git a/MasKitTests/Commands/InstallCommandSpec.swift b/MasKitTests/Commands/InstallCommandSpec.swift index e59d97b..861da86 100644 --- a/MasKitTests/Commands/InstallCommandSpec.swift +++ b/MasKitTests/Commands/InstallCommandSpec.swift @@ -7,9 +7,9 @@ // @testable import MasKit -import Result -import Quick import Nimble +import Quick +import Result class InstallCommandSpec: QuickSpec { override func spec() { diff --git a/MasKitTests/Commands/ListCommandSpec.swift b/MasKitTests/Commands/ListCommandSpec.swift index 339eea4..967dcf5 100644 --- a/MasKitTests/Commands/ListCommandSpec.swift +++ b/MasKitTests/Commands/ListCommandSpec.swift @@ -7,9 +7,9 @@ // @testable import MasKit -import Result -import Quick import Nimble +import Quick +import Result class ListCommandSpec: QuickSpec { override func spec() { diff --git a/MasKitTests/Commands/LuckyCommandSpec.swift b/MasKitTests/Commands/LuckyCommandSpec.swift index a84a18c..0008055 100644 --- a/MasKitTests/Commands/LuckyCommandSpec.swift +++ b/MasKitTests/Commands/LuckyCommandSpec.swift @@ -7,9 +7,9 @@ // @testable import MasKit -import Result -import Quick import Nimble +import Quick +import Result class LuckyCommandSpec: QuickSpec { override func spec() { diff --git a/MasKitTests/Commands/OpenCommandSpec.swift b/MasKitTests/Commands/OpenCommandSpec.swift index 98605ca..d358881 100644 --- a/MasKitTests/Commands/OpenCommandSpec.swift +++ b/MasKitTests/Commands/OpenCommandSpec.swift @@ -7,9 +7,9 @@ // @testable import MasKit -import Result -import Quick import Nimble +import Quick +import Result class OpenCommandSpec: QuickSpec { override func spec() { diff --git a/MasKitTests/Commands/OutdatedCommandSpec.swift b/MasKitTests/Commands/OutdatedCommandSpec.swift index c985cb3..808f246 100644 --- a/MasKitTests/Commands/OutdatedCommandSpec.swift +++ b/MasKitTests/Commands/OutdatedCommandSpec.swift @@ -7,9 +7,9 @@ // @testable import MasKit -import Result -import Quick import Nimble +import Quick +import Result class OutdatedCommandSpec: QuickSpec { override func spec() { diff --git a/MasKitTests/Commands/ResetCommandSpec.swift b/MasKitTests/Commands/ResetCommandSpec.swift index 694c285..fd9d2c2 100644 --- a/MasKitTests/Commands/ResetCommandSpec.swift +++ b/MasKitTests/Commands/ResetCommandSpec.swift @@ -7,9 +7,9 @@ // @testable import MasKit -import Result -import Quick import Nimble +import Quick +import Result class ResetCommandSpec: QuickSpec { override func spec() { diff --git a/MasKitTests/Commands/SearchCommandSpec.swift b/MasKitTests/Commands/SearchCommandSpec.swift index e781c6e..89db580 100644 --- a/MasKitTests/Commands/SearchCommandSpec.swift +++ b/MasKitTests/Commands/SearchCommandSpec.swift @@ -7,9 +7,9 @@ // @testable import MasKit -import Result -import Quick import Nimble +import Quick +import Result class SearchCommandSpec: QuickSpec { override func spec() { diff --git a/MasKitTests/Commands/SignInCommandSpec.swift b/MasKitTests/Commands/SignInCommandSpec.swift index c080c28..991f69a 100644 --- a/MasKitTests/Commands/SignInCommandSpec.swift +++ b/MasKitTests/Commands/SignInCommandSpec.swift @@ -7,9 +7,9 @@ // @testable import MasKit -import Result -import Quick import Nimble +import Quick +import Result class SignInCommandSpec: QuickSpec { override func spec() { diff --git a/MasKitTests/Commands/SignOutCommandSpec.swift b/MasKitTests/Commands/SignOutCommandSpec.swift index 825bdc5..b0dbc8c 100644 --- a/MasKitTests/Commands/SignOutCommandSpec.swift +++ b/MasKitTests/Commands/SignOutCommandSpec.swift @@ -7,9 +7,9 @@ // @testable import MasKit -import Result -import Quick import Nimble +import Quick +import Result class SignOutCommandSpec: QuickSpec { override func spec() { diff --git a/MasKitTests/Commands/UninstallCommandSpec.swift b/MasKitTests/Commands/UninstallCommandSpec.swift index a5b964f..e0f60cd 100644 --- a/MasKitTests/Commands/UninstallCommandSpec.swift +++ b/MasKitTests/Commands/UninstallCommandSpec.swift @@ -7,9 +7,9 @@ // @testable import MasKit -import Result -import Quick import Nimble +import Quick +import Result class UninstallCommandSpec: QuickSpec { override func spec() { diff --git a/MasKitTests/Commands/UpgradeCommandSpec.swift b/MasKitTests/Commands/UpgradeCommandSpec.swift index 878169a..b92513f 100644 --- a/MasKitTests/Commands/UpgradeCommandSpec.swift +++ b/MasKitTests/Commands/UpgradeCommandSpec.swift @@ -7,9 +7,9 @@ // @testable import MasKit -import Result -import Quick import Nimble +import Quick +import Result class UpgradeCommandSpec: QuickSpec { override func spec() { diff --git a/MasKitTests/Commands/VendorCommandSpec.swift b/MasKitTests/Commands/VendorCommandSpec.swift index 7b9f6f4..e1ad009 100644 --- a/MasKitTests/Commands/VendorCommandSpec.swift +++ b/MasKitTests/Commands/VendorCommandSpec.swift @@ -7,9 +7,9 @@ // @testable import MasKit -import Result -import Quick import Nimble +import Quick +import Result class VendorCommandSpec: QuickSpec { override func spec() { diff --git a/MasKitTests/Commands/VersionCommandSpec.swift b/MasKitTests/Commands/VersionCommandSpec.swift index 5c1315a..acfb363 100644 --- a/MasKitTests/Commands/VersionCommandSpec.swift +++ b/MasKitTests/Commands/VersionCommandSpec.swift @@ -7,9 +7,9 @@ // @testable import MasKit -import Result -import Quick import Nimble +import Quick +import Result class VersionCommandSpec: QuickSpec { override func spec() { diff --git a/MasKitTests/Controllers/AppLibraryMock.swift b/MasKitTests/Controllers/AppLibraryMock.swift index aaa9e94..b591754 100644 --- a/MasKitTests/Controllers/AppLibraryMock.swift +++ b/MasKitTests/Controllers/AppLibraryMock.swift @@ -15,13 +15,13 @@ class AppLibraryMock: AppLibrary { /// /// - Parameter bundleId: Bundle identifier of app. /// - Returns: Software Product of app if found; nil otherwise. - public func installedApp(forBundleId bundleId: String) -> SoftwareProduct? { + public func installedApp(forBundleId _: String) -> SoftwareProduct? { return nil } func uninstallApp(app: SoftwareProduct) throws { if !installedApps.contains(where: { (product) -> Bool in - return app.itemIdentifier == product.itemIdentifier + app.itemIdentifier == product.itemIdentifier }) { throw MASError.notInstalled } // Special case for testing where we pretend the trash command failed diff --git a/MasKitTests/Controllers/MasStoreSearchSpec.swift b/MasKitTests/Controllers/MasStoreSearchSpec.swift index ff39e86..7280dc8 100644 --- a/MasKitTests/Controllers/MasStoreSearchSpec.swift +++ b/MasKitTests/Controllers/MasStoreSearchSpec.swift @@ -7,9 +7,9 @@ // @testable import MasKit -import Result -import Quick import Nimble +import Quick +import Result class MasStoreSearchSpec: QuickSpec { override func spec() { @@ -25,7 +25,7 @@ class MasStoreSearchSpec: QuickSpec { expect(searchList.results.count) == 6 } catch { let maserror = error as! MASError - if case .jsonParsing(let nserror) = maserror { + if case let .jsonParsing(nserror) = maserror { fail("\(maserror) \(nserror!)") } } @@ -33,7 +33,7 @@ class MasStoreSearchSpec: QuickSpec { } describe("store lookup") { it("can find slack") { - let appId = 803453959 + let appId = 803_453_959 let networkSession = NetworkSessionMockFromFile(responseFile: "lookup/slack.json") let storeSearch = MasStoreSearch(networkManager: NetworkManager(session: networkSession)) @@ -42,7 +42,7 @@ class MasStoreSearchSpec: QuickSpec { lookup = try storeSearch.lookup(app: appId) } catch { let maserror = error as! MASError - if case .jsonParsing(let nserror) = maserror { + if case let .jsonParsing(nserror) = maserror { fail("\(maserror) \(nserror!)") } } diff --git a/MasKitTests/Controllers/StoreSearchMock.swift b/MasKitTests/Controllers/StoreSearchMock.swift index bcb996c..e899e65 100644 --- a/MasKitTests/Controllers/StoreSearchMock.swift +++ b/MasKitTests/Controllers/StoreSearchMock.swift @@ -23,7 +23,7 @@ class StoreSearchMock: StoreSearch { } guard let result = apps[appId] - else { throw MASError.noSearchResultsFound } + else { throw MASError.noSearchResultsFound } return result } diff --git a/MasKitTests/Controllers/StoreSearchSpec.swift b/MasKitTests/Controllers/StoreSearchSpec.swift index e44837c..ae22517 100644 --- a/MasKitTests/Controllers/StoreSearchSpec.swift +++ b/MasKitTests/Controllers/StoreSearchSpec.swift @@ -6,14 +6,14 @@ // Copyright © 2019 mas-cli. All rights reserved. // @testable import MasKit -import Result -import Quick import Nimble +import Quick +import Result /// Protocol minimal implementation struct StoreSearchForTesting: StoreSearch { - func lookup(app appId: Int) throws -> SearchResult? { return nil } - func search(for appName: String) throws -> SearchResultList { return SearchResultList(resultCount: 0, results: []) } + func lookup(app _: Int) throws -> SearchResult? { return nil } + func search(for _: String) throws -> SearchResultList { return SearchResultList(resultCount: 0, results: []) } } class StoreSearchSpec: QuickSpec { @@ -25,14 +25,14 @@ class StoreSearchSpec: QuickSpec { let appName = "myapp" let urlString = storeSearch.searchURLString(forApp: appName) expect(urlString) == - "https://itunes.apple.com/search?entity=macSoftware&term=\(appName)&attribute=allTrackTerm" + "https://itunes.apple.com/search?entity=macSoftware&term=\(appName)&attribute=allTrackTerm" } it("contains the encoded app name") { let appName = "My App" let appNameEncoded = "My%20App" let urlString = storeSearch.searchURLString(forApp: appName) expect(urlString) == - "https://itunes.apple.com/search?entity=macSoftware&term=\(appNameEncoded)&attribute=allTrackTerm" + "https://itunes.apple.com/search?entity=macSoftware&term=\(appNameEncoded)&attribute=allTrackTerm" } // Find a character that causes addingPercentEncoding(withAllowedCharacters to return nil xit("is nil when app name cannot be url encoded") { diff --git a/MasKitTests/Errors/MASErrorTestCase.swift b/MasKitTests/Errors/MASErrorTestCase.swift index 82e85a5..3ec8e2f 100644 --- a/MasKitTests/Errors/MASErrorTestCase.swift +++ b/MasKitTests/Errors/MASErrorTestCase.swift @@ -7,8 +7,8 @@ // @testable import MasKit -import XCTest import Foundation +import XCTest class MASErrorTestCase: XCTestCase { private let errorDomain = "MAS" @@ -21,8 +21,8 @@ class MASErrorTestCase: XCTestCase { var localizedDescription: String { get { return "dummy value" } set { - NSError.setUserInfoValueProvider(forDomain: errorDomain) { (error: Error, userInfoKey: String) -> Any? in - return newValue + NSError.setUserInfoValueProvider(forDomain: errorDomain) { (_: Error, _: String) -> Any? in + newValue } } } diff --git a/MasKitTests/Extensions/Bundle+JSON.swift b/MasKitTests/Extensions/Bundle+JSON.swift index a1286db..b8e57b7 100644 --- a/MasKitTests/Extensions/Bundle+JSON.swift +++ b/MasKitTests/Extensions/Bundle+JSON.swift @@ -25,7 +25,7 @@ extension Bundle { guard let path = self.path(forResource: fileName.fileNameWithoutExtension, ofType: fileName.fileExtension, inDirectory: "JSON") - else { fatalError("Unable to load file \(fileName)") } + else { fatalError("Unable to load file \(fileName)") } return URL(fileURLWithPath: path) } diff --git a/MasKitTests/Formatters/SearchResultFormatterSpec.swift b/MasKitTests/Formatters/SearchResultFormatterSpec.swift index 38070c0..0da40a0 100644 --- a/MasKitTests/Formatters/SearchResultFormatterSpec.swift +++ b/MasKitTests/Formatters/SearchResultFormatterSpec.swift @@ -7,9 +7,9 @@ // @testable import MasKit -import Result -import Quick import Nimble +import Quick +import Result class SearchResultsFormatterSpec: QuickSpec { override func spec() { diff --git a/MasKitTests/Network/NetworkSessionMock.swift b/MasKitTests/Network/NetworkSessionMock.swift index 87e3ff7..81b15f9 100644 --- a/MasKitTests/Network/NetworkSessionMock.swift +++ b/MasKitTests/Network/NetworkSessionMock.swift @@ -23,7 +23,7 @@ class NetworkSessionMock: NetworkSession { /// - url: unused /// - completionHandler: Closure which is delivered both data and error properties (only one should be non-nil) /// - Returns: Mock data task - func dataTask(with url: URL, completionHandler: @escaping CompletionHandler) -> URLSessionDataTask { + func dataTask(with _: URL, completionHandler: @escaping CompletionHandler) -> URLSessionDataTask { let data = self.data let error = self.error @@ -37,7 +37,7 @@ class NetworkSessionMock: NetworkSession { /// - Parameters: /// - url: unused /// - completionHandler: Closure which is delivered either data or an error. - @objc func loadData(from url: URL, completionHandler: @escaping (Data?, Error?) -> Void) { + @objc func loadData(from _: URL, completionHandler: @escaping (Data?, Error?) -> Void) { completionHandler(data, error) } } diff --git a/MasKitTests/Network/NetworkSessionMockFromFile.swift b/MasKitTests/Network/NetworkSessionMockFromFile.swift index d4aa0fd..e9d69e1 100644 --- a/MasKitTests/Network/NetworkSessionMockFromFile.swift +++ b/MasKitTests/Network/NetworkSessionMockFromFile.swift @@ -25,9 +25,9 @@ class NetworkSessionMockFromFile: NetworkSessionMock { /// - Parameters: /// - url: unused /// - completionHandler: Closure which is delivered either data or an error. - @objc override func loadData(from url: URL, completionHandler: @escaping (Data?, Error?) -> Void) { + @objc override func loadData(from _: URL, completionHandler: @escaping (Data?, Error?) -> Void) { guard let fileURL = Bundle.jsonResponse(fileName: responseFile) - else { fatalError("Unable to load file \(responseFile)") } + else { fatalError("Unable to load file \(responseFile)") } do { let data = try Data(contentsOf: fileURL, options: .mappedIfSafe) diff --git a/MasKitTests/Network/TestURLSessionDelegate.swift b/MasKitTests/Network/TestURLSessionDelegate.swift index 11558af..e131aae 100644 --- a/MasKitTests/Network/TestURLSessionDelegate.swift +++ b/MasKitTests/Network/TestURLSessionDelegate.swift @@ -10,13 +10,12 @@ import Foundation /// Delegate for network requests initiated from tests. class TestURLSessionDelegate: NSObject, URLSessionDelegate { - func urlSession(_ session: URLSession, + func urlSession(_: URLSession, didReceive challenge: URLAuthenticationChallenge, completionHandler: (URLSession.AuthChallengeDisposition, - URLCredential?) -> Void) { - + URLCredential?) -> Void) { // For example, you may want to override this to accept some self-signed certs here. - if challenge.protectionSpace.authenticationMethod == NSURLAuthenticationMethodServerTrust && + if challenge.protectionSpace.authenticationMethod == NSURLAuthenticationMethodServerTrust, Constants.selfSignedHosts.contains(challenge.protectionSpace.host) { // Allow the self-signed cert. let credential = URLCredential(trust: challenge.protectionSpace.serverTrust!) diff --git a/MasKitTests/Network/URLSessionConfiguration+Tests.swift b/MasKitTests/Network/URLSessionConfiguration+Tests.swift index 7ee754d..06fc2c7 100644 --- a/MasKitTests/Network/URLSessionConfiguration+Tests.swift +++ b/MasKitTests/Network/URLSessionConfiguration+Tests.swift @@ -14,7 +14,7 @@ extension URLSessionConfiguration { /// newly created session configuration object, customised /// from the default to your requirements. class func testSessionConfiguration() -> URLSessionConfiguration { - let config = self.default + let config = `default` // Eg we think 60s is too long a timeout time. config.timeoutIntervalForRequest = 20 diff --git a/MasKitTests/Nimble/ResultPredicates.swift b/MasKitTests/Nimble/ResultPredicates.swift index 40d4bfb..e6384cb 100644 --- a/MasKitTests/Nimble/ResultPredicates.swift +++ b/MasKitTests/Nimble/ResultPredicates.swift @@ -7,8 +7,8 @@ // @testable import MasKit -import Result import Nimble +import Result /// Nimble predicate for result enum success case, no associated value func beSuccess() -> Predicate> { diff --git a/MasKitTests/OutputListenerSpec.swift b/MasKitTests/OutputListenerSpec.swift index fff9750..5fc7383 100644 --- a/MasKitTests/OutputListenerSpec.swift +++ b/MasKitTests/OutputListenerSpec.swift @@ -6,8 +6,8 @@ // Copyright © 2019 mas-cli. All rights reserved. // -import Quick import Nimble +import Quick class OutputListenerSpec: QuickSpec { override func spec() { @@ -31,9 +31,9 @@ class OutputListenerSpec: QuickSpec { output.openConsolePipe() let expectedOutput = """ - hi there + hi there - """ + """ print("hi there") diff --git a/docs/sample.swift b/docs/sample.swift index 1f62b62..793d947 100644 --- a/docs/sample.swift +++ b/docs/sample.swift @@ -40,7 +40,7 @@ let cool = yTown(5) { $0 == 6 } // Use full variable names when closures are more complex let cool = yTown(5) { foo in - if foo > 5 && foo < 0 { + if foo > 5, foo < 0 { return true } else { return false @@ -81,7 +81,7 @@ case let .failure(error): // Group methods into specific extensions for each level of access control private extension MyClass { - func doSomethingPrivate() { } + func doSomethingPrivate() {} } // MARK: Breaking up long lines @@ -94,7 +94,7 @@ guard statementThatShouldBeTrue else { return } // move else to next line 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 { diff --git a/mas/main.swift b/mas/main.swift index d721dfa..c3dfbd8 100644 --- a/mas/main.swift +++ b/mas/main.swift @@ -6,9 +6,9 @@ // Copyright © 2015 Andrew Naylor. All rights reserved. // -import MasKit import Commandant import Foundation +import MasKit public struct StderrOutputStream: TextOutputStream { public mutating func write(_ string: String) {