diff --git a/Sources/mas/AppStore/PurchaseDownloadObserver.swift b/Sources/mas/AppStore/PurchaseDownloadObserver.swift index d3cbad5b6..6f9a81172 100644 --- a/Sources/mas/AppStore/PurchaseDownloadObserver.swift +++ b/Sources/mas/AppStore/PurchaseDownloadObserver.swift @@ -24,7 +24,7 @@ class PurchaseDownloadObserver: CKDownloadQueueObserver { } deinit { - // do nothing + // Do nothing } func downloadQueue(_ queue: CKDownloadQueue, statusChangedFor download: SSDownload) { @@ -65,7 +65,7 @@ class PurchaseDownloadObserver: CKDownloadQueueObserver { } func downloadQueue(_: CKDownloadQueue, changedWithAddition _: SSDownload) { - // do nothing + // Do nothing } func downloadQueue(_: CKDownloadQueue, changedWithRemoval download: SSDownload) { diff --git a/Sources/mas/Commands/Upgrade.swift b/Sources/mas/Commands/Upgrade.swift index 25d246d1f..69bc9c1b8 100644 --- a/Sources/mas/Commands/Upgrade.swift +++ b/Sources/mas/Commands/Upgrade.swift @@ -65,7 +65,7 @@ extension MAS { ? installedApps : appIDOrNames.flatMap { appIDOrName in if let appID = AppID(appIDOrName) { - // argument is an AppID, lookup apps by id using argument + // Argument is an AppID, lookup apps by id using argument let installedApps = installedApps.filter { $0.id == appID } if installedApps.isEmpty { printError(appID.unknownMessage) @@ -73,7 +73,7 @@ extension MAS { return installedApps } - // argument is not an AppID, lookup apps by name using argument + // Argument is not an AppID, lookup apps by name using argument let installedApps = installedApps.filter { $0.name == appIDOrName } if installedApps.isEmpty { printError("Unknown app name '", appIDOrName, "'", separator: "") diff --git a/Sources/mas/Formatters/AppListFormatter.swift b/Sources/mas/Formatters/AppListFormatter.swift index ccfd1efda..08f5d92b2 100644 --- a/Sources/mas/Formatters/AppListFormatter.swift +++ b/Sources/mas/Formatters/AppListFormatter.swift @@ -15,7 +15,7 @@ enum AppListFormatter { /// - Parameter installedApps: List of installed apps. /// - Returns: Multiline text output. static func format(_ installedApps: [InstalledApp]) -> String { - // longest app name for right space padding + // Longest app name for right space padding guard let maxAppNameLength = installedApps.map(\.name.count).max() else { return "" } diff --git a/Sources/mas/Formatters/SearchResultFormatter.swift b/Sources/mas/Formatters/SearchResultFormatter.swift index 50092cf77..78f4caab6 100644 --- a/Sources/mas/Formatters/SearchResultFormatter.swift +++ b/Sources/mas/Formatters/SearchResultFormatter.swift @@ -15,7 +15,7 @@ enum SearchResultFormatter { /// - includePrice: Indicates whether to include prices in the output /// - Returns: Multiline text output. static func format(_ results: [SearchResult], includePrice: Bool = false) -> String { - // longest app name for right space padding + // Longest app name for right space padding guard let maxAppNameLength = results.map(\.trackName.count).max() else { return "" } diff --git a/Tests/masTests/Formatters/AppListFormatterSpec.swift b/Tests/masTests/Formatters/AppListFormatterSpec.swift index 7a2e4faa0..40dedc3c4 100644 --- a/Tests/masTests/Formatters/AppListFormatterSpec.swift +++ b/Tests/masTests/Formatters/AppListFormatterSpec.swift @@ -13,7 +13,7 @@ import Quick final class AppListFormatterSpec: QuickSpec { override static func spec() { - // static func reference + // Static func reference let format = AppListFormatter.format(_:) describe("app list formatter") { diff --git a/Tests/masTests/Formatters/SearchResultFormatterSpec.swift b/Tests/masTests/Formatters/SearchResultFormatterSpec.swift index 5b8039f12..a3b58141b 100644 --- a/Tests/masTests/Formatters/SearchResultFormatterSpec.swift +++ b/Tests/masTests/Formatters/SearchResultFormatterSpec.swift @@ -13,7 +13,7 @@ import Quick final class SearchResultFormatterSpec: QuickSpec { override static func spec() { - // static func reference + // Static func reference let format = SearchResultFormatter.format(_:includePrice:) describe("search results formatter") { diff --git a/docs/sample.swift b/docs/sample.swift index cbf2c56ca..6150ae510 100644 --- a/docs/sample.swift +++ b/docs/sample.swift @@ -1,4 +1,4 @@ -// Don't include generated header comments +// Don't include generated header comments. // MARK: Types and naming @@ -6,28 +6,28 @@ struct User { let name: String - /// if the first letter of an acronym is lowercase, the entire thing should + /// If the first letter of an acronym is lowercase, the entire thing should /// be lowercase. let json: Any - /// if the first letter of an acronym is uppercase, the entire thing should + /// If the first letter of an acronym is uppercase, the entire thing should /// be uppercase. static func decode(from json: JSON) -> Self { Self(json: json) } } -/// Use () for void arguments and Void for void return types. +/// Use `()` for void arguments and `Void` for void return types. let closure: () -> Void = { // Do nothing } -/// When using classes, default to marking them as final. +/// When using classes, default to marking them as `final`. final class MyClass { // Empty class } -/// Use typealias when closures are referenced in multiple places. +/// Use `typealias` when closures are referenced in multiple places. typealias CoolClosure = (Int) -> Bool /// Use aliased parameter names when function parameters are ambiguous. @@ -35,17 +35,16 @@ func yTown(some: Int, withCallback callback: CoolClosure) -> Bool { callback(some) } -/// It's OK to use $ variable references if the closure is very short and -/// readability is maintained. +/// Use `$` variable references if the closure fits on one line. let cool = yTown(5) { $0 == 6 } -/// Use full variable names when closures are more complex. +/// Use explicit variable names if the closure is on multiple lines. let cool = yTown(5) { foo in max(foo, 0) // … } -// Strongify weak references in async closures +// Strongify weak references in async closures. APIClient.getAwesomeness { [weak self] result in guard let self else { return @@ -61,7 +60,7 @@ func someUnauditedAPI(thing: String?) { } } -/// When the type is known you can let the compiler infer. +/// When the type is known, let the compiler infer. let response: Response = .success(NSData()) func doSomeWork() -> Response { @@ -87,25 +86,11 @@ private extension MyClass { // MARK: Breaking up long lines -// One expression to evaluate and short or no return -guard let singleTest = somethingFailable() else { - return -} - -guard statementThatShouldBeTrue else { - return -} - -// If a guard clause requires multiple lines, chop down, then start `else` new line -// In this case, always chop down else clause. +// If a guard clause requires multiple lines, chop it down, then start the else +// clause on a new line. guard let oneItem = somethingFailable(), let secondItem = somethingFailable2() else { return } - -// If the return in else is long, move to next line -guard let something = somethingFailable() else { - return someFunctionThatDoesSomethingInManyWordsOrLines() -}