SwiftFormat blankLinesAtStartOfScope

This commit is contained in:
Nindi Gill 2023-11-19 19:27:13 +11:00
parent f4e7be977e
commit 6ac54e9a3d
No known key found for this signature in database
GPG key ID: FF9A7FD590D4F4B1
67 changed files with 0 additions and 157 deletions

View file

@ -51,7 +51,6 @@ struct AppCommands: Commands {
}
private func help() {
guard let url: URL = URL(string: .repositoryURL) else {
return
}

View file

@ -9,7 +9,6 @@ import AppKit
import UserNotifications
class AppDelegate: NSObject, NSApplicationDelegate {
// swiftlint:disable:next weak_delegate
private let userNotificationCenterDelegate: UserNotificationCenterDelegate = UserNotificationCenterDelegate()
@ -28,7 +27,6 @@ class AppDelegate: NSObject, NSApplicationDelegate {
}
func sendUpdateNotification(title: String, body: String, success: Bool, url: URL?) {
let notificationCenter: UNUserNotificationCenter = .current()
notificationCenter.getNotificationSettings { settings in

View file

@ -6,7 +6,6 @@
//
extension Array where Element == UInt8 {
func uInt8(at offset: Int) -> UInt8 {
self[offset]
}

View file

@ -8,7 +8,6 @@
import Authorized
extension AuthorizationError: Equatable {
public static func == (lhs: AuthorizationError, rhs: AuthorizationError) -> Bool {
lhs.localizedDescription == rhs.localizedDescription
}

View file

@ -8,7 +8,6 @@
import SwiftUI
extension ButtonStyle where Self == MistActionButtonStyle {
static var mistAction: Self {
.init()
}

View file

@ -6,9 +6,7 @@
//
extension Dictionary where Key == String {
func firmwareCSVString() -> String {
guard let signed: Bool = self["signed"] as? Bool,
let name: String = self["name"] as? String,
let version: String = self["version"] as? String,
@ -24,7 +22,6 @@ extension Dictionary where Key == String {
}
func installerCSVString() -> String {
guard let identifier: String = self["identifier"] as? String,
let name: String = self["name"] as? String,
let version: String = self["version"] as? String,

View file

@ -8,7 +8,6 @@
import Foundation
extension Double {
/// kilobytes constant
static let kilobyte: Double = 1_000
/// megabytes constant
@ -17,7 +16,6 @@ extension Double {
static let gigabyte: Double = .megabyte * 1_000
func bytesString() -> String {
if self < .kilobyte {
return "\(Int(self)) bytes"
} else if self < .megabyte {

View file

@ -8,9 +8,7 @@
import Foundation
extension FileManager {
func sizeOfDirectory(at url: URL) throws -> UInt64 {
var enumeratorError: Error?
let urlResourceKeys: Set<URLResourceKey> = [
@ -29,7 +27,6 @@ extension FileManager {
var size: UInt64 = 0
for item in enumerator {
if enumeratorError != nil {
break
}

View file

@ -8,7 +8,6 @@
import SwiftUI
extension Scene {
func fixedWindow() -> some Scene {
if #available(macOS 13.0, *) {
return self.windowResizability(.contentSize)

View file

@ -9,7 +9,6 @@ import Foundation
import Yams
extension Sequence where Iterator.Element == [String: Any] {
func firmwaresCSVString() -> String {
"Signed,Name,Version,Build,Size,Date,Compatible\n" + self.map { $0.firmwareCSVString() }.joined()
}

View file

@ -8,7 +8,6 @@
import Foundation
extension String {
static let appName: String = "mist"
static let appIdentifier: String = "com.ninxsoft.\(appName)"
static let helperIdentifier: String = "\(appIdentifier).helper"

View file

@ -8,7 +8,6 @@
import Foundation
extension UInt32 {
func hexString() -> String {
String(format: "0x%08X", self)
}

View file

@ -8,7 +8,6 @@
import Foundation
extension UInt64 {
/// kilobytes constant
static let kilobyte: UInt64 = 1_000
/// megabytes constant
@ -17,7 +16,6 @@ extension UInt64 {
static let gigabyte: UInt64 = .megabyte * 1_000
func bytesString() -> String {
if self < .kilobyte {
return "\(self) bytes"
} else if self < .megabyte {

View file

@ -8,7 +8,6 @@
import Foundation
extension UInt8 {
func hexString() -> String {
String(format: "0x%02X", self)
}

View file

@ -8,7 +8,6 @@
import UserNotifications
extension UNNotificationAction {
struct Identifier {
/// Show Identifier
static let show: String = "Show"

View file

@ -8,7 +8,6 @@
import UserNotifications
extension UNNotificationCategory {
struct Identifier {
/// Success Identifier
static let success: String = "Success"

View file

@ -9,9 +9,7 @@ import CryptoKit
import Foundation
extension URL {
func fileSize() throws -> UInt64 {
let urlResourceKeys: Set<URLResourceKey> = [
.isRegularFileKey,
.fileAllocatedSizeKey,
@ -29,7 +27,6 @@ extension URL {
}
func shasum() -> String? {
let length: Int = 1_024 * 1_024 * 50 // 50 MB
do {

View file

@ -9,7 +9,6 @@ import Foundation
/// Helper struct to codesign a file (ie. Disk Image).
struct Codesigner {
/// Sign a file with the provided signing identity.
///
/// - Parameters:

View file

@ -9,7 +9,6 @@ import Foundation
/// Helper struct to create directories.
struct DirectoryCreator {
/// Create a directory at the provided URL.
///
/// - Parameters:

View file

@ -10,7 +10,6 @@ import SecureXPC
/// Helper struct to remove directories
struct DirectoryRemover {
/// Remove directory at the provided URL.
///
/// - Parameters:
@ -18,7 +17,6 @@ struct DirectoryRemover {
///
/// - Throws: An `Error` if the command failed to execute.
static func remove(_ url: URL) async throws {
guard FileManager.default.fileExists(atPath: url.path) else {
return
}

View file

@ -9,7 +9,6 @@ import Foundation
/// Helper struct to create disk images.
struct DiskImageCreator {
/// Create an empty Disk Image of fixed size.
///
/// - Parameters:
@ -18,7 +17,6 @@ struct DiskImageCreator {
///
/// - Throws: An `MistError` if the command failed to execute.
static func create(_ url: URL, size: Double) async throws {
let arguments: [String] = [
"hdiutil", "create",
"-fs", "JHFS+",
@ -38,7 +36,6 @@ struct DiskImageCreator {
///
/// - Throws: An `MistError` if the command failed to execute.
static func create(_ url: URL, from source: URL) async throws {
let arguments: [String] = [
"hdiutil", "create",
"-fs", "HFS+",
@ -57,7 +54,6 @@ struct DiskImageCreator {
///
/// - Throws: An `MistError` if the command failed to execute.
private static func create(_ url: URL, with arguments: [String]) async throws {
try await DirectoryRemover.remove(url)
let response: HelperToolCommandResponse = try ShellExecutor.shared.execute(arguments)

View file

@ -9,7 +9,6 @@ import Foundation
/// Helper struct to mount Disk Images.
struct DiskImageMounter {
/// Mount a Disk Image at the provided mount point.
///
/// - Parameters:
@ -18,7 +17,6 @@ struct DiskImageMounter {
///
/// - Throws: A `MistError` if the command failed to execute.
static func mount(_ url: URL, mountPoint: URL) async throws {
do {
try await DiskImageUnmounter.unmount(mountPoint)
} catch {

View file

@ -9,7 +9,6 @@ import Foundation
/// Helper struct to unmount Disk Images.
struct DiskImageUnmounter {
/// Unmount a Disk Image at the provided mount point.
///
/// - Parameters:

View file

@ -8,7 +8,6 @@
import Foundation
class DownloadManager: NSObject, ObservableObject {
static let shared: DownloadManager = DownloadManager()
private var task: URLSessionDownloadTask?
private var progress: Progress = Progress()
@ -18,7 +17,6 @@ class DownloadManager: NSObject, ObservableObject {
// swiftlint:disable:next cyclomatic_complexity function_body_length
func download(_ url: URL, to destination: URL, retries retriesMaximum: Int, delay retryDelay: Int) async throws {
guard !FileManager.default.fileExists(atPath: destination.path) else {
return
}
@ -32,7 +30,6 @@ class DownloadManager: NSObject, ObservableObject {
let completionHandler: (URL?, URLResponse?, Error?) -> Void = { url, _, error in
if let error: URLError = error as? URLError {
guard error.code != .cancelled else {
mistError = .userCancelled
completed = true
@ -74,13 +71,11 @@ class DownloadManager: NSObject, ObservableObject {
}
while !completed {
guard retries < retriesMaximum else {
throw MistError.maximumRetriesReached
}
if let error: URLError = urlError {
guard let data: Data = error.downloadTaskResumeData else {
throw MistError.invalidDownloadResumeData
}

View file

@ -10,7 +10,6 @@ import SecureXPC
/// Helper struct to update file / directory attributes
struct FileAttributesUpdater {
/// Update file / directory attributes at the provided URL.
///
/// - Parameters:
@ -19,7 +18,6 @@ struct FileAttributesUpdater {
///
/// - Throws: An `Error` if the command failed to execute.
static func update(url: URL, ownerAccountName: String) async throws {
guard FileManager.default.fileExists(atPath: url.path) else {
return
}

View file

@ -9,7 +9,6 @@ import Foundation
/// Helper struct to copy files.
struct FileCopier {
/// Copy a file from one location to another.
///
/// - Parameters:

View file

@ -9,7 +9,6 @@ import Foundation
/// Helper struct to move files.
struct FileMover {
/// Move a file from one location to another.
///
/// - Parameters:

View file

@ -9,7 +9,6 @@ import Foundation
/// Helper struct to convert Disk Images to ISOs.
struct ISOConverter {
/// Convert a Disk Image to an ISO.
///
/// - Parameters:

View file

@ -10,7 +10,6 @@ import SecureXPC
/// Helper struct to execute the `createinstallmedia` command found in macOS Install app bundles.
struct InstallMediaCreator {
/// Create the macOS Install Media at the specified mount point.
///
/// - Parameters:

View file

@ -10,7 +10,6 @@ import SecureXPC
/// Helper Struct used to create macOS Installers.
struct InstallerCreator {
/// Creates a recently downloaded macOS Installer.
///
/// - Parameters:
@ -20,11 +19,9 @@ struct InstallerCreator {
///
/// - Throws: A `MistError` if the downloaded macOS Installer fails to generate.
static func create(_ installer: Installer, mountPoint: URL, cacheDirectory: String) async throws {
let packageURL: URL
if installer.sierraOrOlder {
guard let package: Package = installer.packages.first else {
throw MistError.invalidData
}

View file

@ -9,7 +9,6 @@ import Foundation
/// Helper struct to create macOS Installer Packages.
struct PackageCreator {
/// Create a macOS Installer Package based off the passed in `Installer` struct.
///
/// - Parameters:
@ -20,7 +19,6 @@ struct PackageCreator {
///
/// - Throws: An `Error` if the command failed to execute.
static func create(_ url: URL, from installer: Installer, identifier: String, identity: String? = nil) async throws {
var arguments: [String] = [
"pkgbuild",
"--identifier", identifier,
@ -45,7 +43,6 @@ struct PackageCreator {
///
/// - Throws: An `MistError` if the command failed to execute.
private static func create(_ url: URL, with arguments: [String]) async throws {
try await DirectoryRemover.remove(url)
let response: HelperToolCommandResponse = try ShellExecutor.shared.execute(arguments)

View file

@ -9,7 +9,6 @@ import Foundation
/// Helper struct to perform lookups on the Privilged Helper Tool executable.
struct PrivilegedHelperTool {
/// The URL of the Privileged Helper Tool within the Mist app bundle.
static let availableURL: URL = URL(fileURLWithPath: "\(Bundle.main.bundlePath)/Contents/Library/LaunchServices/\(String.helperIdentifier)")
/// The URL of the Privileged Helper Tool within /Library/PrivilegedHelperTools.
@ -19,7 +18,6 @@ struct PrivilegedHelperTool {
///
/// - Returns: `true` if the Privileged Helper Tool is installed, otherwise `false`.
static func isInstalled() -> Bool {
do {
// launchctl service is loaded
let arguments: [String] = ["launchctl", "print", "system/\(String.helperIdentifier)"]

View file

@ -9,7 +9,6 @@ import SecureXPC
/// Helper struct to kill the child process of the Privileted Helper Tool.
struct ProcessKiller {
/// Attempts to kill the child process of the Privileged Helper Tool.
///
/// - Throws: A `MistError` if the process fails to be killed.

View file

@ -9,7 +9,6 @@ import Foundation
/// Helper struct to update a Property List key-pair value.
struct PropertyListUpdater {
/// Update a key-pair value in a Property List.
///
/// - Parameters:
@ -19,7 +18,6 @@ struct PropertyListUpdater {
///
/// - Throws: An `Error` if the command failed to execute.
static func update(_ url: URL, key: String, value: AnyHashable) throws {
let input: String = try String(contentsOf: url, encoding: .utf8)
guard var data: Data = input.data(using: .utf8) else {

View file

@ -11,13 +11,11 @@ import System
// swiftlint:disable file_length
// swiftlint:disable:next type_body_length
class TaskManager: ObservableObject {
static let shared: TaskManager = TaskManager()
@Published var taskGroups: [(section: MistTaskSection, tasks: [MistTask])]
var task: Task<Any, Error> = Task { }
var currentState: MistTaskState {
let states: Set<MistTaskState> = Set(taskGroups.flatMap { $0.tasks }.map { $0.state })
if states.contains(.inProgress) {
@ -40,7 +38,6 @@ class TaskManager: ObservableObject {
}
static func taskGroups(for firmware: Firmware, destination destinationURL: URL?, retries: Int, delay retryDelay: Int) throws -> [(section: MistTaskSection, tasks: [MistTask])] {
let temporaryDirectoryURL: URL = URL(fileURLWithPath: .temporaryDirectory)
guard let destinationURL: URL = destinationURL else {
@ -265,7 +262,6 @@ class TaskManager: ObservableObject {
}
private static func downloadTasks(for installer: Installer, cacheDirectory cacheDirectoryURL: URL, retries: Int, delay retryDelay: Int) throws -> [MistTask] {
var tasks: [MistTask] = []
if !FileManager.default.fileExists(atPath: cacheDirectoryURL.path) {
@ -295,7 +291,6 @@ class TaskManager: ObservableObject {
}
for package in installer.allDownloads {
guard let packageURL: URL = URL(string: package.url) else {
throw MistError.invalidURL(package.url)
}
@ -316,7 +311,6 @@ class TaskManager: ObservableObject {
}
private static func installTasks(for installer: Installer, temporaryDirectory temporaryDirectoryURL: URL, mountPoint mountPointURL: URL, cacheDirectory: String) -> [MistTask] {
let imageURL: URL = temporaryDirectoryURL.appendingPathComponent("\(installer.id) Temp.dmg")
var tasks: [MistTask] = [
MistTask(type: .configure, description: "temporary directory") {
@ -371,7 +365,6 @@ class TaskManager: ObservableObject {
}
private static func applicationTasks(for installer: Installer, filename: String, destination destinationURL: URL) -> [MistTask] {
let applicationURL: URL = destinationURL.appendingPathComponent(filename.stringWithSubstitutions(name: installer.name, version: installer.version, build: installer.build))
return [
@ -390,7 +383,6 @@ class TaskManager: ObservableObject {
destination destinationURL: URL,
temporaryDirectory temporaryDirectoryURL: URL
) -> [MistTask] {
let imageDirectoryURL: URL = temporaryDirectoryURL.appendingPathComponent(installer.id)
let applicationURL: URL = imageDirectoryURL.appendingPathComponent(installer.temporaryInstallerURL.lastPathComponent)
let temporaryImageURL: URL = temporaryDirectoryURL.appendingPathComponent("\(installer.id).dmg")
@ -427,7 +419,6 @@ class TaskManager: ObservableObject {
}
private static func isoTasks(for installer: Installer, filename: String, destination destinationURL: URL, temporaryDirectory temporaryDirectoryURL: URL) -> [MistTask] {
let temporaryImageURL: URL = temporaryDirectoryURL.appendingPathComponent("\(installer.id).dmg")
let createInstallMediaURL: URL = installer.temporaryInstallerURL.appendingPathComponent("Contents/Resources/createinstallmedia")
let temporaryCDRURL: URL = temporaryDirectoryURL.appendingPathComponent("\(installer.id).cdr")
@ -442,7 +433,6 @@ class TaskManager: ObservableObject {
try await DiskImageMounter.mount(temporaryImageURL, mountPoint: installer.temporaryISOMountPointURL)
},
MistTask(type: .create, description: "macOS Installer in temporary Disk Image") {
// Workaround to make macOS Sierra 10.12 createinstallmedia work
if installer.version.hasPrefix("10.12") {
let infoPlistURL: URL = installer.temporaryInstallerURL.appendingPathComponent("Contents/Info.plist")
@ -497,7 +487,6 @@ class TaskManager: ObservableObject {
temporaryDirectory temporaryDirectoryURL: URL,
cacheDirectory cacheDirectoryURL: URL
) -> [MistTask] {
let packageURL: URL = destinationURL.appendingPathComponent(filename.stringWithSubstitutions(name: installer.name, version: installer.version, build: installer.build))
var tasks: [MistTask] = []
@ -532,7 +521,6 @@ class TaskManager: ObservableObject {
let mountPointURL: URL = URL(fileURLWithPath: volume.path)
let tasks: [MistTask] = [
MistTask(type: .create, description: "Bootable Installer") {
// Workaround to make macOS Sierra 10.12 createinstallmedia work
if installer.version.hasPrefix("10.12") {
let infoPlistURL: URL = installer.temporaryInstallerURL.appendingPathComponent("Contents/Info.plist")
@ -547,7 +535,6 @@ class TaskManager: ObservableObject {
}
private static func cleanupTasks(mountPoint mountPointURL: URL, temporaryDirectory temporaryDirectoryURL: URL, cacheDownloads: Bool, cacheDirectory cacheDirectoryURL: URL) -> [MistTask] {
var tasks: [MistTask] = [
MistTask(type: .unmount, description: "Disk Image") {
try await DiskImageUnmounter.unmount(mountPointURL)

View file

@ -10,7 +10,6 @@ import Foundation
/// Helper struct used to validate Firmware and Installer checksums.
struct Validator {
/// Validates a Firmware's checksum.
///
/// - Parameters:
@ -19,7 +18,6 @@ struct Validator {
///
/// - Throws: A `MistError` if the validation fails.
static func validate(_ firmware: Firmware, at destination: URL) async throws {
guard let shasum: String = destination.shasum() else {
throw MistError.invalidData
}
@ -37,7 +35,6 @@ struct Validator {
///
/// - Throws: A `MistError` if the validation fails.
static func validate(_ package: Package, at destination: URL) async throws {
guard !package.url.hasSuffix("English.dist") else {
return
}

View file

@ -33,9 +33,7 @@ struct MistApp: App {
}
func hideZoomButton() {
for window in NSApplication.shared.windows {
guard let button: NSButton = window.standardWindowButton(NSWindow.ButtonType.zoomButton) else {
continue
}

View file

@ -8,7 +8,6 @@
import Foundation
struct Catalog: Identifiable, Decodable, Equatable {
enum CodingKeys: String, CodingKey {
// swiftlint:disable:next redundant_string_enum_value
case type = "type"

View file

@ -38,7 +38,6 @@ enum CatalogType: String, CaseIterable, Comparable, Decodable {
// swiftlint:disable:next cyclomatic_complexity
func url(for seedType: CatalogSeedType) -> String {
switch self {
case .sonoma:
switch seedType {

View file

@ -9,7 +9,6 @@ import Foundation
/// Struct used to store all elements of the Chunklist.
struct Chunklist {
/// Chunklist Magic Header constant
static let magicHeader: UInt32 = 0x4C4B4E43
/// Chunklist Header Size constant
@ -56,7 +55,6 @@ struct Chunklist {
///
/// - Throws: A `MistError` if the Chunklist validation fails
init(from url: URL, size: Int) throws {
let data: Data = try Data(contentsOf: url)
guard data.count == size else {
@ -121,7 +119,6 @@ struct Chunklist {
///
/// - Returns: An array of Chunk structs.
private static func chunks(_ array: [UInt8], totalChunks: Int) -> [Chunk] {
var chunks: [Chunk] = []
for offset in 0..<totalChunks {

View file

@ -8,7 +8,6 @@
import Foundation
struct Firmware: Decodable, Hashable, Identifiable {
enum CodingKeys: String, CodingKey {
case version = "version"
case build = "buildid"
@ -49,7 +48,6 @@ struct Firmware: Decodable, Hashable, Identifiable {
"\(String.appIdentifier).\(version)-\(build)"
}
var name: String {
var name: String = ""
if version.range(of: "^14", options: .regularExpression) != nil {
@ -113,7 +111,6 @@ struct Firmware: Decodable, Hashable, Identifiable {
///
/// - Returns: An array of Firmware build strings.
static func supportedBuilds() throws -> [String] {
guard let architecture: Architecture = Hardware.architecture,
architecture == .appleSilicon,
let modelIdentifier: String = Hardware.modelIdentifier,
@ -134,7 +131,6 @@ struct Firmware: Decodable, Hashable, Identifiable {
}
extension Firmware: Equatable {
static func == (lhs: Firmware, rhs: Firmware) -> Bool {
lhs.version == rhs.version && lhs.build == rhs.build
}

View file

@ -9,7 +9,6 @@ import Foundation
/// Hardware Struct used to retrieve Hardware information.
struct Hardware {
/// Hardware Architecture (Apple Silicon or Intel).
static var architecture: Architecture? {
#if arch(arm64)
@ -27,7 +26,6 @@ struct Hardware {
}
/// Hardware Device ID (Apple Silicon or Intel T2).
static var deviceID: String? {
switch architecture {
case .appleSilicon:
return registryProperty(for: "compatible")?.components(separatedBy: "\0").first?.uppercased()
@ -49,7 +47,6 @@ struct Hardware {
///
/// - Returns: The entity property for the provided key.
private static func registryProperty(for key: String) -> String? {
let entry: io_service_t = IOServiceGetMatchingService(kIOMainPortDefault, IOServiceMatching("IOPlatformExpertDevice"))
defer {

View file

@ -10,7 +10,6 @@ import Foundation
// swiftlint:disable file_length
// swiftlint:disable:next type_body_length
struct Installer: Decodable, Hashable, Identifiable {
enum CodingKeys: String, CodingKey {
case id = "Identifier"
case version = "Version"
@ -654,7 +653,6 @@ struct Installer: Decodable, Hashable, Identifiable {
let deviceIDs: [String]
let unsupportedModelIdentifiers: [String]
var name: String {
var name: String = ""
if version.range(of: "^14", options: .regularExpression) != nil {
@ -710,7 +708,6 @@ struct Installer: Decodable, Hashable, Identifiable {
// Model Identifier (Apple Silicon or Intel)
// macOS Catalina 10.15 or older
if version.range(of: "^10\\.", options: .regularExpression) != nil {
if let architecture: Architecture = Hardware.architecture,
architecture == .appleSilicon {
return false
@ -790,7 +787,6 @@ struct Installer: Decodable, Hashable, Identifiable {
}
extension Installer: Equatable {
static func == (lhs: Installer, rhs: Installer) -> Bool {
lhs.version == rhs.version && lhs.build == rhs.build
}

View file

@ -16,7 +16,6 @@ struct MistTask: Identifiable {
let operation: @Sendable () async throws -> Void
var currentDescription: String {
var prefix: String = type.rawValue
var suffix: String = description
@ -46,14 +45,12 @@ struct MistTask: Identifiable {
}
extension MistTask: Equatable {
static func == (lhs: MistTask, rhs: MistTask) -> Bool {
lhs.id == rhs.id
}
}
extension MistTask: Hashable {
func hash(into hasher: inout Hasher) {
hasher.combine(id)
}

View file

@ -9,9 +9,7 @@ import AppKit
import UserNotifications
class UserNotificationCenterDelegate: NSObject, UNUserNotificationCenterDelegate {
func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse) async {
guard response.actionIdentifier == UNNotificationAction.Identifier.show,
let string: String = response.notification.request.content.userInfo["URL"] as? String else {
return

View file

@ -126,7 +126,6 @@ struct ActivityView: View {
}
private func performTasks() async {
for taskGroupIndex in taskManager.taskGroups.indices {
for taskIndex in taskManager.taskGroups[taskGroupIndex].tasks.indices {
currentTaskId = "\(taskManager.taskGroups[taskGroupIndex].section.id).\(taskIndex)"
@ -165,7 +164,6 @@ struct ActivityView: View {
}
if showInFinder {
guard let url: URL = destinationURL else {
return
}
@ -175,7 +173,6 @@ struct ActivityView: View {
}
private func checkForUserCancellation(_ failure: Error) -> Bool {
if failure as? CancellationError != nil {
return true
}
@ -214,7 +211,6 @@ struct ActivityView: View {
}
private func stop() {
switch taskManager.currentState {
case .pending, .inProgress:
alertType = .cancel

View file

@ -8,7 +8,6 @@
import SwiftUI
struct PathControl: NSViewRepresentable {
@Binding var path: String
func makeNSView(context: Context) -> NSPathControl {

View file

@ -33,14 +33,12 @@ struct TextFieldStepperView: View {
}
private func increment() {
if value < maximum {
value += 1
}
}
private func decrement() {
if value > minimum {
value -= 1
}

View file

@ -124,14 +124,12 @@ struct ContentView: View {
}
private func releaseNames(for type: DownloadType) -> [String] {
var releaseNames: [String] = []
switch type {
case .firmware:
for firmware in filteredFirmwares {
let releaseName: String = firmware.name.replacingOccurrences(of: " beta", with: "")
if !releaseNames.contains(releaseName) {
@ -141,7 +139,6 @@ struct ContentView: View {
case .installer:
for installer in filteredInstallers {
let releaseName: String = installer.name.replacingOccurrences(of: " beta", with: "")
if !releaseNames.contains(releaseName) {

View file

@ -33,7 +33,6 @@ struct FooterView: View {
}
private func export() {
dateFormatter.dateFormat = "yyyy-MM-dd"
let date: String = dateFormatter.string(from: Date())

View file

@ -70,7 +70,6 @@ struct InstallerExportView: View {
}
private func updateExports() {
var exports: [InstallerExportType] = []
if !isoCompatible && exportISO {

View file

@ -62,7 +62,6 @@ struct InstallerVolumeSelectionView: View {
}
private func getAvailableVolumes() -> [InstallerVolume] {
var volumes: [InstallerVolume] = []
let keys: [URLResourceKey] = [.volumeNameKey, .volumeLocalizedFormatDescriptionKey, .volumeIsReadOnlyKey, .volumeTotalCapacityKey]

View file

@ -28,7 +28,6 @@ struct ListRowFirmware: View {
private let spacing: CGFloat = 5
private let padding: CGFloat = 3
private var compatibilityMessage: String {
guard let architecture: Architecture = Hardware.architecture else {
return "Invalid architecture!"
}
@ -36,7 +35,6 @@ struct ListRowFirmware: View {
return "This macOS Firmware download cannot be used to restore macOS on this \(architecture.description) Mac.\n\nAre you sure you want to continue?"
}
private var errorMessage: String {
if let error: BlessError = error as? BlessError {
return error.description
}
@ -136,7 +134,6 @@ struct ListRowFirmware: View {
}
private func validate() {
guard PrivilegedHelperTool.isInstalled() else {
alertType = .helperTool
showAlert = true
@ -158,7 +155,6 @@ struct ListRowFirmware: View {
}
struct ListRowFirmware_Previews: PreviewProvider {
static var previews: some View {
ListRowFirmware(firmware: .example, savePanel: .constant(NSSavePanel()), tasksInProgress: .constant(false), taskManager: .shared)
}

View file

@ -53,7 +53,6 @@ struct ListRowInstaller: View {
private let spacing: CGFloat = 5
private let padding: CGFloat = 3
private var compatibilityMessage: String {
guard let architecture: Architecture = Hardware.architecture else {
return "Invalid architecture!"
}
@ -64,7 +63,6 @@ struct ListRowInstaller: View {
"The cache directory has incorrect ownership and/or permissions, which will cause issues caching macOS Installers.\n\nRepair the cache directory ownership and/or permissions and try again."
}
private var errorMessage: String {
if let error: BlessError = error as? BlessError {
return error.description
}
@ -203,7 +201,6 @@ struct ListRowInstaller: View {
}
private func createBootableInstaller() {
guard let volume: InstallerVolume = volume else {
return
}
@ -230,7 +227,6 @@ struct ListRowInstaller: View {
}
private func validate() {
guard PrivilegedHelperTool.isInstalled() else {
alertType = .helperTool
showAlert = true
@ -244,7 +240,6 @@ struct ListRowInstaller: View {
}
if cacheDownloads {
do {
var isDirectory: ObjCBool = false
@ -299,7 +294,6 @@ struct ListRowInstaller: View {
}
private func openFullDiskAccessPreferences() {
guard let url: URL = URL(string: "x-apple.systempreferences:com.apple.preference.security?Privacy_AllFiles") else {
return
}

View file

@ -98,7 +98,6 @@ struct RefreshView: View {
}
private func retrieveFirmwares() throws -> [Firmware] {
var firmwares: [Firmware] = []
guard let firmwaresURL: URL = URL(string: Firmware.firmwaresURL) else {
@ -119,7 +118,6 @@ struct RefreshView: View {
let supportedBuilds: [String] = try Firmware.supportedBuilds()
for (identifier, device) in devices {
guard identifier.contains("Mac"),
let device: [String: Any] = device as? [String: Any],
let firmwaresArray: [[String: Any]] = device["firmwares"] as? [[String: Any]] else {
@ -127,7 +125,6 @@ struct RefreshView: View {
}
for var firmwareDictionary in firmwaresArray {
if let url: String = firmwareDictionary["url"] as? String,
url.contains("http://updates-http.cdn-apple.com") {
firmwareDictionary["url"] = url.replacingOccurrences(of: "http://updates-http.cdn-apple.com", with: "https://updates.cdn-apple.com")
@ -156,7 +153,6 @@ struct RefreshView: View {
let catalogURLs: [String] = getCatalogURLs()
for catalogURL in catalogURLs {
guard let url: URL = URL(string: catalogURL) else {
continue
}
@ -196,7 +192,6 @@ struct RefreshView: View {
}
private func getCatalogURLs() -> [String] {
var catalogURLs: [String] = []
var catalogs: [Catalog] = []
let defaultCatalogs: [Catalog] = CatalogType.allCases.map { Catalog(type: $0, standard: true, customerSeed: false, developerSeed: false, publicSeed: false) }
@ -239,13 +234,11 @@ struct RefreshView: View {
}
private func getInstallers(from dictionary: [String: Any]) -> [Installer] {
var installers: [Installer] = []
let dateFormatter: DateFormatter = DateFormatter()
dateFormatter.dateFormat = "yyyy-MM-dd"
for (key, value) in dictionary {
guard var value: [String: Any] = value as? [String: Any],
let date: Date = value["PostDate"] as? Date,
let extendedMetaInfo: [String: Any] = value["ExtendedMetaInfo"] as? [String: Any],
@ -296,7 +289,6 @@ struct RefreshView: View {
}
private func nameFromDistribution(_ string: String) -> String? {
guard string.contains("suDisabledGroupID") else {
return nil
}
@ -307,7 +299,6 @@ struct RefreshView: View {
}
private func versionFromDistribution(_ string: String) -> String? {
guard string.contains("<key>VERSION</key>") else {
return nil
}
@ -317,7 +308,6 @@ struct RefreshView: View {
}
private func buildFromDistribution(_ string: String) -> String? {
guard string.contains("<key>BUILD</key>") else {
return nil
}
@ -327,7 +317,6 @@ struct RefreshView: View {
}
private func boardIDsFromDistribution(_ string: String) -> [String] {
guard string.contains("supportedBoardIDs") || string.contains("boardIds") else {
return []
}
@ -341,7 +330,6 @@ struct RefreshView: View {
}
private func deviceIDsFromDistribution(_ string: String) -> [String] {
guard string.contains("supportedDeviceIDs") else {
return []
}
@ -356,7 +344,6 @@ struct RefreshView: View {
}
private func unsupportedModelIdentifiersFromDistribution(_ string: String) -> [String] {
guard string.contains("nonSupportedModels") else {
return []
}

View file

@ -49,7 +49,6 @@ struct SettingsAboutView: View {
}
private func visitHomepage() {
guard let url: URL = URL(string: .repositoryURL) else {
return
}

View file

@ -48,7 +48,6 @@ struct SettingsDiskImagesView: View {
}
private func updateCodesigningIdentities() {
var codesigningIdentities: [String] = []
let query: [String: Any] = [

View file

@ -19,7 +19,6 @@ struct SettingsGeneralHelperView: View {
@State private var error: Error?
private let length: CGFloat = 16
private var status: String {
guard installed,
let installed: HelperToolInfoPropertyList = installedInfoPropertyList else {
return "Not Installed"
@ -29,7 +28,6 @@ struct SettingsGeneralHelperView: View {
return "Installed (\(version.major).\(version.minor).\(version.patch))"
}
private var errorMessage: String {
if let error: BlessError = error as? BlessError {
return error.description
}
@ -70,7 +68,6 @@ struct SettingsGeneralHelperView: View {
}
private func install() {
processing = true
do {

View file

@ -44,7 +44,6 @@ struct SettingsGeneralNotificationsView: View {
}
private func validateNotifications() {
let notificationCenter: UNUserNotificationCenter = .current()
notificationCenter.getNotificationSettings { settings in
@ -56,7 +55,6 @@ struct SettingsGeneralNotificationsView: View {
}
private func request() {
let userNotificationCenter: UNUserNotificationCenter = UNUserNotificationCenter.current()
let options: UNAuthorizationOptions = [.alert, .badge, .sound]
@ -71,7 +69,6 @@ struct SettingsGeneralNotificationsView: View {
}
private func openNotifications() {
guard let url: URL = URL(string: "x-apple.systempreferences:com.apple.preference.notifications?Notifications") else {
return
}

View file

@ -106,7 +106,6 @@ struct SettingsInstallersCacheView: View {
}
private func retrieveCache() {
let url: URL = URL(fileURLWithPath: cacheDirectory)
var isDirectory: ObjCBool = false
@ -143,7 +142,6 @@ struct SettingsInstallersCacheView: View {
}
private func installer(for url: URL) -> Installer? {
let id: String = url.lastPathComponent
do {
@ -194,7 +192,6 @@ struct SettingsInstallersCacheView: View {
}
private func versionFromDistribution(_ string: String) -> String? {
guard string.contains("<key>VERSION</key>") else {
return nil
}
@ -204,7 +201,6 @@ struct SettingsInstallersCacheView: View {
}
private func buildFromDistribution(_ string: String) -> String? {
guard string.contains("<key>BUILD</key>") else {
return nil
}
@ -214,7 +210,6 @@ struct SettingsInstallersCacheView: View {
}
private func showInFinder() {
guard let id: String = selectedInstallerId else {
return
}
@ -224,7 +219,6 @@ struct SettingsInstallersCacheView: View {
}
private func emptyCache(for id: String?) async {
guard let id: String = id else {
return
}

View file

@ -42,7 +42,6 @@ struct SettingsInstallersView: View {
}
private func getCatalogs() -> [Catalog] {
guard let array: [[String: Any]] = UserDefaults.standard.array(forKey: "catalogs") as? [[String: Any]] else {
return defaultCatalogs
}

View file

@ -61,7 +61,6 @@ struct SettingsPackagesView: View {
}
private func updateCodesigningIdentities() {
var codesigningIdentities: [String] = []
let query: [String: Any] = [

View file

@ -10,7 +10,6 @@ import SecureXPC
/// Helper Tool struct to run a command sent from the main application.
struct HelperToolCommandRunner {
/// Run the requested command and return the status and output.
///
/// - Parameters:
@ -20,7 +19,6 @@ struct HelperToolCommandRunner {
///
/// - Returns: A `HelperToolCommandResponse` struct containing the termination status, standard output and standard error.
static func run(_ request: HelperToolCommandRequest) throws -> HelperToolCommandResponse {
switch request.type {
case .remove:

View file

@ -8,7 +8,6 @@
import XCTest
final class MistTests: XCTestCase {
func test() throws {
XCTAssertTrue(true)
}

View file

@ -9,7 +9,6 @@ import EmbeddedPropertyList
import Foundation
struct HelperToolInfoPropertyList: Decodable, Equatable {
private enum CodingKeys: String, CodingKey {
case buildHash = "BuildHash"
case bundleIdentifier = "CFBundleIdentifier"

View file

@ -9,7 +9,6 @@ import EmbeddedPropertyList
import Foundation
struct HelperToolLaunchdPropertyList: Decodable, Equatable {
private enum CodingKeys: String, CodingKey {
case machServices = "MachServices"
case label = "Label"

View file

@ -9,7 +9,6 @@ import Foundation
/// Helper class used to execute shell commands.
class ShellExecutor: NSObject {
static var shared: ShellExecutor = ShellExecutor()
private var process: Process = Process()
@ -60,7 +59,6 @@ class ShellExecutor: NSObject {
}
func terminate() {
guard process.isRunning else {
return
}