SwiftFormat redundantReturn

This commit is contained in:
Nindi Gill 2023-11-19 19:34:55 +11:00
parent c01ff511aa
commit cf47a3b06c
No known key found for this signature in database
GPG key ID: FF9A7FD590D4F4B1
15 changed files with 83 additions and 83 deletions

View file

@ -17,13 +17,13 @@ extension Double {
func bytesString() -> String {
if self < .kilobyte {
return "\(Int(self)) bytes"
"\(Int(self)) bytes"
} else if self < .megabyte {
return String(format: "%5.2f KB", self / .kilobyte)
String(format: "%5.2f KB", self / .kilobyte)
} else if self < .gigabyte {
return String(format: "%5.2f MB", self / .megabyte)
String(format: "%5.2f MB", self / .megabyte)
} else {
return String(format: "%5.2f GB", self / .gigabyte)
String(format: "%5.2f GB", self / .gigabyte)
}
}
}

View file

@ -10,9 +10,9 @@ import SwiftUI
extension Scene {
func fixedWindow() -> some Scene {
if #available(macOS 13.0, *) {
return self.windowResizability(.contentSize)
self.windowResizability(.contentSize)
} else {
return self
self
}
}
}

View file

@ -17,13 +17,13 @@ extension UInt64 {
func bytesString() -> String {
if self < .kilobyte {
return "\(self) bytes"
"\(self) bytes"
} else if self < .megabyte {
return String(format: "%5.2f KB", Double(self) / Double(.kilobyte))
String(format: "%5.2f KB", Double(self) / Double(.kilobyte))
} else if self < .gigabyte {
return String(format: "%5.2f MB", Double(self) / Double(.megabyte))
String(format: "%5.2f MB", Double(self) / Double(.megabyte))
} else {
return String(format: "%5.2f GB", Double(self) / Double(.gigabyte))
String(format: "%5.2f GB", Double(self) / Double(.gigabyte))
}
}

View file

@ -18,9 +18,9 @@ enum Architecture: String {
var description: String {
switch self {
case .appleSilicon:
return "Apple Silicon"
"Apple Silicon"
case .intel:
return "Intel-based"
"Intel-based"
}
}
}

View file

@ -22,13 +22,13 @@ enum CatalogType: String, CaseIterable, Comparable, Decodable {
private var sortOrder: Int {
switch self {
case .sonoma:
return 0
0
case .ventura:
return 1
1
case .monterey:
return 2
2
case .bigSur:
return 3
3
}
}
@ -42,52 +42,52 @@ enum CatalogType: String, CaseIterable, Comparable, Decodable {
case .sonoma:
switch seedType {
case .standard:
return "https://swscan.apple.com/content/catalogs/others/index-14-13-12-10.16-10.15-10.14-10.13-10.12-10.11-10.10-10.9-mountainlion-lion-snowleopard-leopard.merged-1.sucatalog.gz"
"https://swscan.apple.com/content/catalogs/others/index-14-13-12-10.16-10.15-10.14-10.13-10.12-10.11-10.10-10.9-mountainlion-lion-snowleopard-leopard.merged-1.sucatalog.gz"
case .customer:
// swiftlint:disable:next line_length
return "https://swscan.apple.com/content/catalogs/others/index-14customerseed-14-13-12-10.16-10.15-10.14-10.13-10.12-10.11-10.10-10.9-mountainlion-lion-snowleopard-leopard.merged-1.sucatalog.gz"
"https://swscan.apple.com/content/catalogs/others/index-14customerseed-14-13-12-10.16-10.15-10.14-10.13-10.12-10.11-10.10-10.9-mountainlion-lion-snowleopard-leopard.merged-1.sucatalog.gz"
case .developer:
// swiftlint:disable:next line_length
return "https://swscan.apple.com/content/catalogs/others/index-14seed-14-13-12-10.16-10.15-10.14-10.13-10.12-10.11-10.10-10.9-mountainlion-lion-snowleopard-leopard.merged-1.sucatalog.gz"
"https://swscan.apple.com/content/catalogs/others/index-14seed-14-13-12-10.16-10.15-10.14-10.13-10.12-10.11-10.10-10.9-mountainlion-lion-snowleopard-leopard.merged-1.sucatalog.gz"
case .public:
// swiftlint:disable:next line_length
return "https://swscan.apple.com/content/catalogs/others/index-14beta-14-13-12-10.16-10.15-10.14-10.13-10.12-10.11-10.10-10.9-mountainlion-lion-snowleopard-leopard.merged-1.sucatalog.gz"
"https://swscan.apple.com/content/catalogs/others/index-14beta-14-13-12-10.16-10.15-10.14-10.13-10.12-10.11-10.10-10.9-mountainlion-lion-snowleopard-leopard.merged-1.sucatalog.gz"
}
case .ventura:
switch seedType {
case .standard:
return "https://swscan.apple.com/content/catalogs/others/index-13-12-10.16-10.15-10.14-10.13-10.12-10.11-10.10-10.9-mountainlion-lion-snowleopard-leopard.merged-1.sucatalog.gz"
"https://swscan.apple.com/content/catalogs/others/index-13-12-10.16-10.15-10.14-10.13-10.12-10.11-10.10-10.9-mountainlion-lion-snowleopard-leopard.merged-1.sucatalog.gz"
case .customer:
// swiftlint:disable:next line_length
return "https://swscan.apple.com/content/catalogs/others/index-13customerseed-13-12-10.16-10.15-10.14-10.13-10.12-10.11-10.10-10.9-mountainlion-lion-snowleopard-leopard.merged-1.sucatalog.gz"
"https://swscan.apple.com/content/catalogs/others/index-13customerseed-13-12-10.16-10.15-10.14-10.13-10.12-10.11-10.10-10.9-mountainlion-lion-snowleopard-leopard.merged-1.sucatalog.gz"
case .developer:
return "https://swscan.apple.com/content/catalogs/others/index-13seed-13-12-10.16-10.15-10.14-10.13-10.12-10.11-10.10-10.9-mountainlion-lion-snowleopard-leopard.merged-1.sucatalog.gz"
"https://swscan.apple.com/content/catalogs/others/index-13seed-13-12-10.16-10.15-10.14-10.13-10.12-10.11-10.10-10.9-mountainlion-lion-snowleopard-leopard.merged-1.sucatalog.gz"
case .public:
return "https://swscan.apple.com/content/catalogs/others/index-13beta-13-12-10.16-10.15-10.14-10.13-10.12-10.11-10.10-10.9-mountainlion-lion-snowleopard-leopard.merged-1.sucatalog.gz"
"https://swscan.apple.com/content/catalogs/others/index-13beta-13-12-10.16-10.15-10.14-10.13-10.12-10.11-10.10-10.9-mountainlion-lion-snowleopard-leopard.merged-1.sucatalog.gz"
}
case .monterey:
switch seedType {
case .standard:
return "https://swscan.apple.com/content/catalogs/others/index-12-10.16-10.15-10.14-10.13-10.12-10.11-10.10-10.9-mountainlion-lion-snowleopard-leopard.merged-1.sucatalog.gz"
"https://swscan.apple.com/content/catalogs/others/index-12-10.16-10.15-10.14-10.13-10.12-10.11-10.10-10.9-mountainlion-lion-snowleopard-leopard.merged-1.sucatalog.gz"
case .customer:
// swiftlint:disable:next line_length
return "https://swscan.apple.com/content/catalogs/others/index-12customerseed-12-10.16-10.15-10.14-10.13-10.12-10.11-10.10-10.9-mountainlion-lion-snowleopard-leopard.merged-1.sucatalog.gz"
"https://swscan.apple.com/content/catalogs/others/index-12customerseed-12-10.16-10.15-10.14-10.13-10.12-10.11-10.10-10.9-mountainlion-lion-snowleopard-leopard.merged-1.sucatalog.gz"
case .developer:
return "https://swscan.apple.com/content/catalogs/others/index-12seed-12-10.16-10.15-10.14-10.13-10.12-10.11-10.10-10.9-mountainlion-lion-snowleopard-leopard.merged-1.sucatalog.gz"
"https://swscan.apple.com/content/catalogs/others/index-12seed-12-10.16-10.15-10.14-10.13-10.12-10.11-10.10-10.9-mountainlion-lion-snowleopard-leopard.merged-1.sucatalog.gz"
case .public:
return "https://swscan.apple.com/content/catalogs/others/index-12beta-12-10.16-10.15-10.14-10.13-10.12-10.11-10.10-10.9-mountainlion-lion-snowleopard-leopard.merged-1.sucatalog.gz"
"https://swscan.apple.com/content/catalogs/others/index-12beta-12-10.16-10.15-10.14-10.13-10.12-10.11-10.10-10.9-mountainlion-lion-snowleopard-leopard.merged-1.sucatalog.gz"
}
case .bigSur:
switch seedType {
case .standard:
return "https://swscan.apple.com/content/catalogs/others/index-10.16-10.15-10.14-10.13-10.12-10.11-10.10-10.9-mountainlion-lion-snowleopard-leopard.merged-1.sucatalog.gz"
"https://swscan.apple.com/content/catalogs/others/index-10.16-10.15-10.14-10.13-10.12-10.11-10.10-10.9-mountainlion-lion-snowleopard-leopard.merged-1.sucatalog.gz"
case .customer:
// swiftlint:disable:next line_length
return "https://swscan.apple.com/content/catalogs/others/index-10.16customerseed-10.16-10.15-10.14-10.13-10.12-10.11-10.10-10.9-mountainlion-lion-snowleopard-leopard.merged-1.sucatalog.gz"
"https://swscan.apple.com/content/catalogs/others/index-10.16customerseed-10.16-10.15-10.14-10.13-10.12-10.11-10.10-10.9-mountainlion-lion-snowleopard-leopard.merged-1.sucatalog.gz"
case .developer:
return "https://swscan.apple.com/content/catalogs/others/index-10.16seed-10.16-10.15-10.14-10.13-10.12-10.11-10.10-10.9-mountainlion-lion-snowleopard-leopard.merged-1.sucatalog.gz"
"https://swscan.apple.com/content/catalogs/others/index-10.16seed-10.16-10.15-10.14-10.13-10.12-10.11-10.10-10.9-mountainlion-lion-snowleopard-leopard.merged-1.sucatalog.gz"
case .public:
return "https://swscan.apple.com/content/catalogs/others/index-10.16beta-10.16-10.15-10.14-10.13-10.12-10.11-10.10-10.9-mountainlion-lion-snowleopard-leopard.merged-1.sucatalog.gz"
"https://swscan.apple.com/content/catalogs/others/index-10.16beta-10.16-10.15-10.14-10.13-10.12-10.11-10.10-10.9-mountainlion-lion-snowleopard-leopard.merged-1.sucatalog.gz"
}
}
}

View file

@ -20,26 +20,26 @@ enum ExportListType: String, CaseIterable, Identifiable {
var description: String {
switch self {
case .csv:
return "CSV (Comma Separated Values)"
"CSV (Comma Separated Values)"
case .json:
return "JSON (JavaScript Object Notation)"
"JSON (JavaScript Object Notation)"
case .plist:
return "Plist (Apple Property List)"
"Plist (Apple Property List)"
case .yaml:
return "YAML (YAML Ain't Markup Language)"
"YAML (YAML Ain't Markup Language)"
}
}
var contentType: UTType {
switch self {
case .csv:
return .commaSeparatedText
.commaSeparatedText
case .json:
return .json
.json
case .plist:
return .propertyList
.propertyList
case .yaml:
return .yaml
.yaml
}
}
}

View file

@ -29,11 +29,11 @@ enum Hardware {
static var deviceID: String? {
switch architecture {
case .appleSilicon:
return registryProperty(for: "compatible")?.components(separatedBy: "\0").first?.uppercased()
registryProperty(for: "compatible")?.components(separatedBy: "\0").first?.uppercased()
case .intel:
return registryProperty(for: "bridge-model")?.uppercased()
registryProperty(for: "bridge-model")?.uppercased()
default:
return nil
nil
}
}

View file

@ -22,13 +22,13 @@ enum InstallerExportType: String, CaseIterable, Identifiable {
var systemName: String {
switch self {
case .application:
return "macwindow"
"macwindow"
case .diskImage:
return "opticaldiscdrive"
"opticaldiscdrive"
case .iso:
return "opticaldisc"
"opticaldisc"
case .package:
return "shippingbox"
"shippingbox"
}
}
}

View file

@ -16,26 +16,26 @@ enum MistTaskState: String {
var imageName: String {
switch self {
case .pending:
return "hourglass.circle.fill"
"hourglass.circle.fill"
case .inProgress:
return "gear.circle.fill"
"gear.circle.fill"
case .complete:
return "checkmark.circle.fill"
"checkmark.circle.fill"
case .error:
return "xmark.circle.fill"
"xmark.circle.fill"
}
}
var color: Color {
switch self {
case .pending:
return .orange
.orange
case .inProgress:
return .blue
.blue
case .complete:
return .green
.green
case .error:
return .red
.red
}
}
}

View file

@ -21,30 +21,30 @@ enum RefreshState: String, CaseIterable, Identifiable {
var systemName: String {
switch self {
case .pending:
return "hourglass.circle.fill"
"hourglass.circle.fill"
case .inProgress:
return "gear.circle.fill"
"gear.circle.fill"
case .complete:
return "checkmark.circle.fill"
"checkmark.circle.fill"
case .warning:
return "exclamationmark.triangle.fill"
"exclamationmark.triangle.fill"
case .error:
return "x.circle.fill"
"x.circle.fill"
}
}
var color: Color {
switch self {
case .pending:
return .orange
.orange
case .inProgress:
return .blue
.blue
case .complete:
return .green
.green
case .warning:
return .yellow
.yellow
case .error:
return .red
.red
}
}
}

View file

@ -46,9 +46,9 @@ struct ActivityView: View {
private var buttonText: String {
switch taskManager.currentState {
case .pending, .inProgress:
return "Cancel"
"Cancel"
case .complete, .error:
return "Close"
"Close"
}
}
@ -111,14 +111,14 @@ struct ActivityView: View {
.alert(isPresented: $showAlert) {
switch alertType {
case .cancel:
return Alert(
Alert(
title: Text("Are you sure you want to cancel?"),
message: Text("This process cannot be resumed once it has been cancelled."),
primaryButton: .default(Text("Resume")),
secondaryButton: .destructive(Text("Cancel"), action: { cancel() })
)
case .error:
return Alert(
Alert(
title: Text("An error has occurred!"),
message: Text(error?.description ?? ""),
dismissButton: .default(Text("OK"))

View file

@ -67,21 +67,21 @@ struct ListRowFirmware: View {
.alert(isPresented: $showAlert) {
switch alertType {
case .compatibility:
return Alert(
Alert(
title: Text("macOS Firmware not compatible!"),
message: Text(compatibilityMessage),
primaryButton: .default(Text("Cancel")),
secondaryButton: .default(Text("Continue")) { Task { validate() } }
)
case .helperTool:
return Alert(
Alert(
title: Text("Privileged Helper Tool not installed!"),
message: Text("The Mist Privileged Helper Tool is required to perform Administrator tasks when downloading macOS Firmwares."),
primaryButton: .default(Text("Install...")) { Task { installPrivilegedHelperTool() } },
secondaryButton: .default(Text("Cancel"))
)
case .error:
return Alert(
Alert(
title: Text("An error has occured!"),
message: Text(errorMessage),
dismissButton: .default(Text("OK"))

View file

@ -312,35 +312,35 @@ struct ListRowInstaller: View {
private func alert(for alertType: InstallerAlertType) -> Alert {
switch alertType {
case .compatibility:
return Alert(
Alert(
title: Text("macOS Installer not compatible!"),
message: Text(compatibilityMessage),
primaryButton: .default(Text("Cancel")),
secondaryButton: .default(Text("Continue")) { Task { validate() } }
)
case .helperTool:
return Alert(
Alert(
title: Text("Privileged Helper Tool not installed!"),
message: Text("The Mist Privileged Helper Tool is required to perform Administrator tasks when creating macOS Installers."),
primaryButton: .default(Text("Install...")) { Task { installPrivilegedHelperTool() } },
secondaryButton: .default(Text("Cancel"))
)
case .fullDiskAccess:
return Alert(
Alert(
title: Text("Full Disk Access required!"),
message: Text("Mist requires Full Disk Access to perform Administrator tasks when creating macOS Installers."),
primaryButton: .default(Text("Allow...")) { openFullDiskAccessPreferences() },
secondaryButton: .default(Text("Cancel"))
)
case .cacheDirectory:
return Alert(
Alert(
title: Text("Cache directory settings incorrect!"),
message: Text(cacheDirectoryMessage),
primaryButton: .default(Text("Repair...")) { Task { try await repairCacheDirectoryOwnershipAndPermissions() } },
secondaryButton: .default(Text("Cancel"))
)
case .error:
return Alert(
Alert(
title: Text("An error has occured!"),
message: Text(errorMessage),
dismissButton: .default(Text("OK"))

View file

@ -64,7 +64,7 @@ struct SettingsInstallersCacheView: View {
.alert(isPresented: $showAlert) {
switch alertType {
case .confirmation:
return Alert(
Alert(
title: Text("Remove Cached Installer?"),
message: Text(removalMessage),
primaryButton: .cancel(),
@ -76,7 +76,7 @@ struct SettingsInstallersCacheView: View {
}
)
case .error:
return Alert(
Alert(
title: Text("An error has occured!"),
message: Text("There was an error removing the cached Installer directory. Show in Finder to remove manually."),
primaryButton: .default(Text("OK")) { },

View file

@ -51,13 +51,13 @@ struct SettingsInstallersCatalogsView: View {
get: {
switch catalogSeedType {
case .standard:
return catalog.standard
catalog.standard
case .customer:
return catalog.customerSeed
catalog.customerSeed
case .developer:
return catalog.developerSeed
catalog.developerSeed
case .public:
return catalog.publicSeed
catalog.publicSeed
}
},
set: {