diff --git a/Mist/AppDelegate.swift b/Mist/AppDelegate.swift index f17aabb..16c31e1 100644 --- a/Mist/AppDelegate.swift +++ b/Mist/AppDelegate.swift @@ -10,13 +10,13 @@ import UserNotifications class AppDelegate: NSObject, NSApplicationDelegate { // swiftlint:disable:next weak_delegate - private let userNotificationCenterDelegate: UserNotificationCenterDelegate = UserNotificationCenterDelegate() + private let userNotificationCenterDelegate: UserNotificationCenterDelegate = .init() func applicationDidFinishLaunching(_ notification: Notification) { UNUserNotificationCenter.current().delegate = userNotificationCenterDelegate - let show: UNNotificationAction = UNNotificationAction(identifier: UNNotificationAction.Identifier.show, title: "Show", options: .foreground) - let success: UNNotificationCategory = UNNotificationCategory(identifier: UNNotificationCategory.Identifier.success, actions: [show], intentIdentifiers: [], options: []) - let failure: UNNotificationCategory = UNNotificationCategory(identifier: UNNotificationCategory.Identifier.failure, actions: [], intentIdentifiers: [], options: []) + let show: UNNotificationAction = .init(identifier: UNNotificationAction.Identifier.show, title: "Show", options: .foreground) + let success: UNNotificationCategory = .init(identifier: UNNotificationCategory.Identifier.success, actions: [show], intentIdentifiers: [], options: []) + let failure: UNNotificationCategory = .init(identifier: UNNotificationCategory.Identifier.failure, actions: [], intentIdentifiers: [], options: []) UNUserNotificationCenter.current().setNotificationCategories([success, failure]) NSWindow.allowsAutomaticWindowTabbing = false @@ -35,7 +35,7 @@ class AppDelegate: NSObject, NSApplicationDelegate { } let identifier: String = UUID().uuidString - let content: UNMutableNotificationContent = UNMutableNotificationContent() + let content: UNMutableNotificationContent = .init() content.title = title content.body = body content.sound = .default @@ -46,8 +46,8 @@ class AppDelegate: NSObject, NSApplicationDelegate { content.userInfo = ["URL": url.path] } - let trigger: UNTimeIntervalNotificationTrigger = UNTimeIntervalNotificationTrigger(timeInterval: 1, repeats: false) - let request: UNNotificationRequest = UNNotificationRequest(identifier: identifier, content: content, trigger: trigger) + let trigger: UNTimeIntervalNotificationTrigger = .init(timeInterval: 1, repeats: false) + let request: UNNotificationRequest = .init(identifier: identifier, content: content, trigger: trigger) notificationCenter.add(request) { error in diff --git a/Mist/Extensions/URL+Extension.swift b/Mist/Extensions/URL+Extension.swift index d77b0d8..3a1e4b1 100644 --- a/Mist/Extensions/URL+Extension.swift +++ b/Mist/Extensions/URL+Extension.swift @@ -36,7 +36,7 @@ extension URL { fileHandle.closeFile() } - var shasum: Insecure.SHA1 = Insecure.SHA1() + var shasum: Insecure.SHA1 = .init() while try autoreleasepool(invoking: { try Task.checkCancellation() @@ -49,7 +49,7 @@ extension URL { return !data.isEmpty }) { } - let data: Data = Data(shasum.finalize()) + let data: Data = .init(shasum.finalize()) return data.map { String(format: "%02hhx", $0) }.joined() } catch { print(error.localizedDescription) diff --git a/Mist/Helpers/DirectoryRemover.swift b/Mist/Helpers/DirectoryRemover.swift index 7f2cf59..556e183 100644 --- a/Mist/Helpers/DirectoryRemover.swift +++ b/Mist/Helpers/DirectoryRemover.swift @@ -22,8 +22,8 @@ enum DirectoryRemover { } let arguments: [String] = [url.path] - let client: XPCClient = XPCClient.forMachService(named: .helperIdentifier) - let request: HelperToolCommandRequest = HelperToolCommandRequest(type: .remove, arguments: arguments, environment: [:]) + let client: XPCClient = .forMachService(named: .helperIdentifier) + let request: HelperToolCommandRequest = .init(type: .remove, arguments: arguments, environment: [:]) let response: HelperToolCommandResponse = try await client.sendMessage(request, to: XPCRoute.commandRoute) guard response.terminationStatus == 0 else { diff --git a/Mist/Helpers/DownloadManager.swift b/Mist/Helpers/DownloadManager.swift index 4272adc..b8696d9 100644 --- a/Mist/Helpers/DownloadManager.swift +++ b/Mist/Helpers/DownloadManager.swift @@ -8,9 +8,9 @@ import Foundation class DownloadManager: NSObject, ObservableObject { - static let shared: DownloadManager = DownloadManager() + static let shared: DownloadManager = .init() private var task: URLSessionDownloadTask? - private var progress: Progress = Progress() + private var progress: Progress = .init() var currentValue: Double { progress.fractionCompleted } @@ -21,7 +21,7 @@ class DownloadManager: NSObject, ObservableObject { return } - let semaphore: DispatchSemaphore = DispatchSemaphore(value: 0) + let semaphore: DispatchSemaphore = .init(value: 0) var mistError: MistError? var urlError: URLError? var retries: Int = 0 diff --git a/Mist/Helpers/FileAttributesUpdater.swift b/Mist/Helpers/FileAttributesUpdater.swift index 56a96e5..2677506 100644 --- a/Mist/Helpers/FileAttributesUpdater.swift +++ b/Mist/Helpers/FileAttributesUpdater.swift @@ -23,8 +23,8 @@ enum FileAttributesUpdater { } let arguments: [String] = [url.path, ownerAccountName] - let client: XPCClient = XPCClient.forMachService(named: .helperIdentifier) - let request: HelperToolCommandRequest = HelperToolCommandRequest(type: .fileAttributes, arguments: arguments, environment: [:]) + let client: XPCClient = .forMachService(named: .helperIdentifier) + let request: HelperToolCommandRequest = .init(type: .fileAttributes, arguments: arguments, environment: [:]) let response: HelperToolCommandResponse = try await client.sendMessage(request, to: XPCRoute.commandRoute) guard response.terminationStatus == 0 else { diff --git a/Mist/Helpers/InstallMediaCreator.swift b/Mist/Helpers/InstallMediaCreator.swift index 584b839..0f3667a 100644 --- a/Mist/Helpers/InstallMediaCreator.swift +++ b/Mist/Helpers/InstallMediaCreator.swift @@ -26,8 +26,8 @@ enum InstallMediaCreator { arguments += ["--applicationpath", applicationPath] } - let client: XPCClient = XPCClient.forMachService(named: .helperIdentifier) - let request: HelperToolCommandRequest = HelperToolCommandRequest(type: .createinstallmedia, arguments: arguments, environment: [:]) + let client: XPCClient = .forMachService(named: .helperIdentifier) + let request: HelperToolCommandRequest = .init(type: .createinstallmedia, arguments: arguments, environment: [:]) let response: HelperToolCommandResponse = try await client.sendMessage(request, to: XPCRoute.commandRoute) guard response.terminationStatus == 0 else { diff --git a/Mist/Helpers/InstallerCreator.swift b/Mist/Helpers/InstallerCreator.swift index b7ee30a..d7a0761 100644 --- a/Mist/Helpers/InstallerCreator.swift +++ b/Mist/Helpers/InstallerCreator.swift @@ -49,10 +49,10 @@ enum InstallerCreator { } let variables: [String: String] = ["CM_BUILD": "CM_BUILD"] - let client: XPCClient = XPCClient.forMachService(named: .helperIdentifier) + let client: XPCClient = .forMachService(named: .helperIdentifier) for arguments in argumentsArrays { - let request: HelperToolCommandRequest = HelperToolCommandRequest(type: .installer, arguments: arguments, environment: variables) + let request: HelperToolCommandRequest = .init(type: .installer, arguments: arguments, environment: variables) let response: HelperToolCommandResponse = try await client.sendMessage(request, to: XPCRoute.commandRoute) guard response.terminationStatus == 0 else { diff --git a/Mist/Helpers/PrivilegedHelperTool.swift b/Mist/Helpers/PrivilegedHelperTool.swift index 7ef93f9..a47e72d 100644 --- a/Mist/Helpers/PrivilegedHelperTool.swift +++ b/Mist/Helpers/PrivilegedHelperTool.swift @@ -10,9 +10,9 @@ import Foundation /// Helper struct to perform lookups on the Privilged Helper Tool executable. enum 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)") + static let availableURL: URL = .init(fileURLWithPath: "\(Bundle.main.bundlePath)/Contents/Library/LaunchServices/\(String.helperIdentifier)") /// The URL of the Privileged Helper Tool within /Library/PrivilegedHelperTools. - static let installedURL: URL = URL(fileURLWithPath: .helperURL) + static let installedURL: URL = .init(fileURLWithPath: .helperURL) /// Determines if the Privileged Helper Tool is installed correctly. /// diff --git a/Mist/Helpers/ProcessKiller.swift b/Mist/Helpers/ProcessKiller.swift index ddaa6e6..1022a5b 100644 --- a/Mist/Helpers/ProcessKiller.swift +++ b/Mist/Helpers/ProcessKiller.swift @@ -13,8 +13,8 @@ enum ProcessKiller { /// /// - Throws: A `MistError` if the process fails to be killed. static func kill() async throws { - let client: XPCClient = XPCClient.forMachService(named: .helperIdentifier) - let request: HelperToolCommandRequest = HelperToolCommandRequest(type: .kill, arguments: [], environment: [:]) + let client: XPCClient = .forMachService(named: .helperIdentifier) + let request: HelperToolCommandRequest = .init(type: .kill, arguments: [], environment: [:]) let response: HelperToolCommandResponse = try await client.sendMessage(request, to: XPCRoute.commandRoute) guard response.terminationStatus == 0 else { diff --git a/Mist/Helpers/TaskManager.swift b/Mist/Helpers/TaskManager.swift index c4ca7bb..6743056 100644 --- a/Mist/Helpers/TaskManager.swift +++ b/Mist/Helpers/TaskManager.swift @@ -11,7 +11,7 @@ import System // swiftlint:disable file_length // swiftlint:disable:next type_body_length class TaskManager: ObservableObject { - static let shared: TaskManager = TaskManager() + static let shared: TaskManager = .init() @Published var taskGroups: [(section: MistTaskSection, tasks: [MistTask])] var task: Task = Task { } @@ -38,7 +38,7 @@ 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) + let temporaryDirectoryURL: URL = .init(fileURLWithPath: .temporaryDirectory) guard let destinationURL: URL = destinationURL else { throw MistError.invalidDestinationURL @@ -145,8 +145,8 @@ class TaskManager: ObservableObject { packageSigningIdentity: String ) throws -> [(section: MistTaskSection, tasks: [MistTask])] { var taskGroups: [(section: MistTaskSection, tasks: [MistTask])] = [] - let cacheDirectoryURL: URL = URL(fileURLWithPath: cacheDirectory).appendingPathComponent(installer.id) - let temporaryDirectoryURL: URL = URL(fileURLWithPath: .temporaryDirectory) + let cacheDirectoryURL: URL = .init(fileURLWithPath: cacheDirectory).appendingPathComponent(installer.id) + let temporaryDirectoryURL: URL = .init(fileURLWithPath: .temporaryDirectory) guard let destinationURL: URL = destinationURL else { throw MistError.invalidDestinationURL @@ -232,8 +232,8 @@ class TaskManager: ObservableObject { delay retryDelay: Int, volume: InstallerVolume ) throws -> [(section: MistTaskSection, tasks: [MistTask])] { - let cacheDirectoryURL: URL = URL(fileURLWithPath: cacheDirectory).appendingPathComponent(installer.id) - let temporaryDirectoryURL: URL = URL(fileURLWithPath: .temporaryDirectory) + let cacheDirectoryURL: URL = .init(fileURLWithPath: cacheDirectory).appendingPathComponent(installer.id) + let temporaryDirectoryURL: URL = .init(fileURLWithPath: .temporaryDirectory) let taskGroups: [(section: MistTaskSection, tasks: [MistTask])] = [ ( section: .download, @@ -279,7 +279,7 @@ class TaskManager: ObservableObject { throw MistError.missingFileAttributes } - let filePermissions: FilePermissions = FilePermissions(rawValue: CModeT(posixPermissions.int16Value)) + let filePermissions: FilePermissions = .init(rawValue: CModeT(posixPermissions.int16Value)) if filePermissions != [.ownerReadWriteExecute, .groupReadExecute, .otherReadExecute] || ownerAccountName != NSUserName() || groupOwnerAccountName != "wheel" { tasks += [ @@ -326,8 +326,8 @@ class TaskManager: ObservableObject { if installer.sierraOrOlder, let package: Package = installer.packages.first { - let legacyDiskImageURL: URL = URL(fileURLWithPath: "\(cacheDirectory)/\(installer.id)/\(package.filename)") - let legacyDiskImageMountPointURL: URL = URL(fileURLWithPath: "/Volumes/Install \(installer.name)") + let legacyDiskImageURL: URL = .init(fileURLWithPath: "\(cacheDirectory)/\(installer.id)/\(package.filename)") + let legacyDiskImageMountPointURL: URL = .init(fileURLWithPath: "/Volumes/Install \(installer.name)") tasks += [ MistTask(type: .mount, description: "Installer Disk Image") { @@ -450,7 +450,7 @@ class TaskManager: ObservableObject { return } - let url: URL = URL(fileURLWithPath: "/Volumes/Install macOS \(major) beta") + let url: URL = .init(fileURLWithPath: "/Volumes/Install macOS \(major) beta") if FileManager.default.fileExists(atPath: url.path) { try await DiskImageUnmounter.unmount(url) @@ -518,7 +518,7 @@ class TaskManager: ObservableObject { private static func bootableInstallerTasks(for installer: Installer, volume: InstallerVolume) -> [MistTask] { let createInstallMediaURL: URL = installer.temporaryInstallerURL.appendingPathComponent("Contents/Resources/createinstallmedia") - let mountPointURL: URL = URL(fileURLWithPath: volume.path) + let mountPointURL: URL = .init(fileURLWithPath: volume.path) let tasks: [MistTask] = [ MistTask(type: .create, description: "Bootable Installer") { // Workaround to make macOS Sierra 10.12 createinstallmedia work diff --git a/Mist/MistApp.swift b/Mist/MistApp.swift index 7fae008..46187c7 100644 --- a/Mist/MistApp.swift +++ b/Mist/MistApp.swift @@ -12,7 +12,7 @@ struct MistApp: App { // swiftlint:disable:next weak_delegate @NSApplicationDelegateAdaptor(AppDelegate.self) var appDelegate: AppDelegate - @StateObject var sparkleUpdater: SparkleUpdater = SparkleUpdater() + @StateObject var sparkleUpdater: SparkleUpdater = .init() @State private var refreshing: Bool = false @State private var tasksInProgress: Bool = false diff --git a/Mist/Model/Catalog.swift b/Mist/Model/Catalog.swift index f620dec..1cafa1f 100644 --- a/Mist/Model/Catalog.swift +++ b/Mist/Model/Catalog.swift @@ -20,7 +20,7 @@ struct Catalog: Identifiable, Decodable, Equatable { Catalog(type: .ventura, standard: true, customerSeed: false, developerSeed: false, publicSeed: false) } - var id: UUID = UUID() + var id: UUID = .init() var type: CatalogType var standard: Bool var customerSeed: Bool diff --git a/Mist/Model/Chunklist.swift b/Mist/Model/Chunklist.swift index 9bfd4d6..8dc9af9 100644 --- a/Mist/Model/Chunklist.swift +++ b/Mist/Model/Chunklist.swift @@ -61,7 +61,7 @@ struct Chunklist { throw MistError.chunklistValidationError("Invalid file size: '\(data.count)', should be '\(size)'") } - let array: [UInt8] = [UInt8](data) + let array: [UInt8] = .init(data) magicHeader = array.uInt32(at: 0x00) headerSize = array.uInt32(at: 0x04) fileVersion = array.uInt8(at: 0x08) @@ -124,7 +124,7 @@ struct Chunklist { for offset in 0.. [Installer] { var installers: [Installer] = [] - let dateFormatter: DateFormatter = DateFormatter() + let dateFormatter: DateFormatter = .init() dateFormatter.dateFormat = "yyyy-MM-dd" for (key, value) in dictionary { diff --git a/Mist/Views/Settings/SettingsGeneralNotificationsView.swift b/Mist/Views/Settings/SettingsGeneralNotificationsView.swift index 31b1cff..7267cf2 100644 --- a/Mist/Views/Settings/SettingsGeneralNotificationsView.swift +++ b/Mist/Views/Settings/SettingsGeneralNotificationsView.swift @@ -55,7 +55,7 @@ struct SettingsGeneralNotificationsView: View { } private func request() { - let userNotificationCenter: UNUserNotificationCenter = UNUserNotificationCenter.current() + let userNotificationCenter: UNUserNotificationCenter = .current() let options: UNAuthorizationOptions = [.alert, .badge, .sound] userNotificationCenter.requestAuthorization(options: options) { success, _ in diff --git a/Mist/Views/Settings/SettingsInstallersCacheView.swift b/Mist/Views/Settings/SettingsInstallersCacheView.swift index 2148af8..449a6c2 100644 --- a/Mist/Views/Settings/SettingsInstallersCacheView.swift +++ b/Mist/Views/Settings/SettingsInstallersCacheView.swift @@ -11,7 +11,7 @@ struct SettingsInstallersCacheView: View { @Binding var cacheDownloads: Bool @Binding var cacheDirectory: String @State private var cacheSize: UInt64 = 0 - @State private var openPanel: NSOpenPanel = NSOpenPanel() + @State private var openPanel: NSOpenPanel = .init() @State private var installers: [Installer] = [] @State private var selectedInstallerId: String? @State private var showAlert: Bool = false @@ -106,7 +106,7 @@ struct SettingsInstallersCacheView: View { } private func retrieveCache() { - let url: URL = URL(fileURLWithPath: cacheDirectory) + let url: URL = .init(fileURLWithPath: cacheDirectory) var isDirectory: ObjCBool = false do { @@ -214,7 +214,7 @@ struct SettingsInstallersCacheView: View { return } - let url: URL = URL(fileURLWithPath: "\(cacheDirectory)/\(id)") + let url: URL = .init(fileURLWithPath: "\(cacheDirectory)/\(id)") NSWorkspace.shared.open(url) } @@ -223,7 +223,7 @@ struct SettingsInstallersCacheView: View { return } - let url: URL = URL(fileURLWithPath: "\(cacheDirectory)/\(id)") + let url: URL = .init(fileURLWithPath: "\(cacheDirectory)/\(id)") do { try await DirectoryRemover.remove(url) diff --git a/Mist/Views/Settings/SettingsInstallersView.swift b/Mist/Views/Settings/SettingsInstallersView.swift index b80e769..bce9d1e 100644 --- a/Mist/Views/Settings/SettingsInstallersView.swift +++ b/Mist/Views/Settings/SettingsInstallersView.swift @@ -51,7 +51,7 @@ struct SettingsInstallersView: View { let catalogTypes: [CatalogType] = catalogs.map { $0.type } for catalogType in CatalogType.allCases where !catalogTypes.contains(catalogType) { - let catalog: Catalog = Catalog(type: catalogType, standard: true, customerSeed: false, developerSeed: false, publicSeed: false) + let catalog: Catalog = .init(type: catalogType, standard: true, customerSeed: false, developerSeed: false, publicSeed: false) catalogs.append(catalog) } diff --git a/Shared/ShellExecutor.swift b/Shared/ShellExecutor.swift index 506b8f1..53d7412 100644 --- a/Shared/ShellExecutor.swift +++ b/Shared/ShellExecutor.swift @@ -9,8 +9,8 @@ import Foundation /// Helper class used to execute shell commands. class ShellExecutor: NSObject { - static var shared: ShellExecutor = ShellExecutor() - private var process: Process = Process() + static var shared: ShellExecutor = .init() + private var process: Process = .init() /// Executes custom shell commands. /// @@ -27,8 +27,8 @@ class ShellExecutor: NSObject { environment variables: [String: String] = [:], currentDirectoryPath: String? = nil ) throws -> HelperToolCommandResponse { - let outputPipe: Pipe = Pipe() - let errorPipe: Pipe = Pipe() + let outputPipe: Pipe = .init() + let errorPipe: Pipe = .init() process = Process() process.launchPath = "/usr/bin/env" process.arguments = arguments