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 { func bytesString() -> String {
if self < .kilobyte { if self < .kilobyte {
return "\(Int(self)) bytes" "\(Int(self)) bytes"
} else if self < .megabyte { } else if self < .megabyte {
return String(format: "%5.2f KB", self / .kilobyte) String(format: "%5.2f KB", self / .kilobyte)
} else if self < .gigabyte { } else if self < .gigabyte {
return String(format: "%5.2f MB", self / .megabyte) String(format: "%5.2f MB", self / .megabyte)
} else { } 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 { extension Scene {
func fixedWindow() -> some Scene { func fixedWindow() -> some Scene {
if #available(macOS 13.0, *) { if #available(macOS 13.0, *) {
return self.windowResizability(.contentSize) self.windowResizability(.contentSize)
} else { } else {
return self self
} }
} }
} }

View file

@ -17,13 +17,13 @@ extension UInt64 {
func bytesString() -> String { func bytesString() -> String {
if self < .kilobyte { if self < .kilobyte {
return "\(self) bytes" "\(self) bytes"
} else if self < .megabyte { } 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 { } else if self < .gigabyte {
return String(format: "%5.2f MB", Double(self) / Double(.megabyte)) String(format: "%5.2f MB", Double(self) / Double(.megabyte))
} else { } 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 { var description: String {
switch self { switch self {
case .appleSilicon: case .appleSilicon:
return "Apple Silicon" "Apple Silicon"
case .intel: case .intel:
return "Intel-based" "Intel-based"
} }
} }
} }

View file

@ -22,13 +22,13 @@ enum CatalogType: String, CaseIterable, Comparable, Decodable {
private var sortOrder: Int { private var sortOrder: Int {
switch self { switch self {
case .sonoma: case .sonoma:
return 0 0
case .ventura: case .ventura:
return 1 1
case .monterey: case .monterey:
return 2 2
case .bigSur: case .bigSur:
return 3 3
} }
} }
@ -42,52 +42,52 @@ enum CatalogType: String, CaseIterable, Comparable, Decodable {
case .sonoma: case .sonoma:
switch seedType { switch seedType {
case .standard: 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: case .customer:
// swiftlint:disable:next line_length // 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: case .developer:
// swiftlint:disable:next line_length // 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: case .public:
// swiftlint:disable:next line_length // 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: case .ventura:
switch seedType { switch seedType {
case .standard: 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: case .customer:
// swiftlint:disable:next line_length // 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: 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: 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: case .monterey:
switch seedType { switch seedType {
case .standard: 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: case .customer:
// swiftlint:disable:next line_length // 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: 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: 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: case .bigSur:
switch seedType { switch seedType {
case .standard: 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: case .customer:
// swiftlint:disable:next line_length // 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: 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: 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 { var description: String {
switch self { switch self {
case .csv: case .csv:
return "CSV (Comma Separated Values)" "CSV (Comma Separated Values)"
case .json: case .json:
return "JSON (JavaScript Object Notation)" "JSON (JavaScript Object Notation)"
case .plist: case .plist:
return "Plist (Apple Property List)" "Plist (Apple Property List)"
case .yaml: case .yaml:
return "YAML (YAML Ain't Markup Language)" "YAML (YAML Ain't Markup Language)"
} }
} }
var contentType: UTType { var contentType: UTType {
switch self { switch self {
case .csv: case .csv:
return .commaSeparatedText .commaSeparatedText
case .json: case .json:
return .json .json
case .plist: case .plist:
return .propertyList .propertyList
case .yaml: case .yaml:
return .yaml .yaml
} }
} }
} }

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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