From 964d08098b3269b38056f46464b4adeaabbda61d Mon Sep 17 00:00:00 2001 From: Blake McAnally Date: Tue, 9 Jul 2024 20:03:40 -0500 Subject: [PATCH] Run swiftlint --fix over the project --- .../ExternalNotificationConfigEntityExtension.swift | 2 +- Meshtastic/Helpers/BLEManager.swift | 5 ++--- Meshtastic/Helpers/CommonRegex.swift | 3 +-- Meshtastic/Helpers/MeshPackets.swift | 2 +- Meshtastic/Persistence/Persistence.swift | 6 +++--- Meshtastic/Persistence/UpdateCoreData.swift | 2 +- .../Views/Nodes/Helpers/Map/MapContent/MeshMapContent.swift | 2 +- Meshtastic/Views/Nodes/Helpers/NodeDetail.swift | 6 +++--- Meshtastic/Views/Nodes/NodeList.swift | 2 +- 9 files changed, 14 insertions(+), 16 deletions(-) diff --git a/Meshtastic/Extensions/CoreData/ExternalNotificationConfigEntityExtension.swift b/Meshtastic/Extensions/CoreData/ExternalNotificationConfigEntityExtension.swift index 72853b43..5fa8589c 100644 --- a/Meshtastic/Extensions/CoreData/ExternalNotificationConfigEntityExtension.swift +++ b/Meshtastic/Extensions/CoreData/ExternalNotificationConfigEntityExtension.swift @@ -23,7 +23,7 @@ extension ExternalNotificationConfigEntity { self.nagTimeout = Int32(config.nagTimeout) self.useI2SAsBuzzer = config.useI2SAsBuzzer } - + func update(with config: ModuleConfig.ExternalNotificationConfig) { enabled = config.enabled usePWM = config.usePwm diff --git a/Meshtastic/Helpers/BLEManager.swift b/Meshtastic/Helpers/BLEManager.swift index f15ba040..054728a9 100644 --- a/Meshtastic/Helpers/BLEManager.swift +++ b/Meshtastic/Helpers/BLEManager.swift @@ -559,7 +559,7 @@ class BLEManager: NSObject, CBPeripheralDelegate, MqttClientProxyManagerDelegate Logger.radio.debug("📟 \(log, privacy: .public)") } } - + func peripheral(_ peripheral: CBPeripheral, didUpdateValueFor characteristic: CBCharacteristic, error: Error?) { if let error { @@ -600,8 +600,7 @@ class BLEManager: NSObject, CBPeripheralDelegate, MqttClientProxyManagerDelegate message = "DEBUG | \(message)" } handleRadioLog(radioLog: message) - } - catch { + } catch { // Ignore fail to parse as LogRecord } diff --git a/Meshtastic/Helpers/CommonRegex.swift b/Meshtastic/Helpers/CommonRegex.swift index 683f8fd7..3cc788d1 100644 --- a/Meshtastic/Helpers/CommonRegex.swift +++ b/Meshtastic/Helpers/CommonRegex.swift @@ -8,8 +8,7 @@ import Foundation import RegexBuilder -class CommonRegex -{ +class CommonRegex { static let COORDS_REGEX = Regex { Capture { Regex { diff --git a/Meshtastic/Helpers/MeshPackets.swift b/Meshtastic/Helpers/MeshPackets.swift index d81d9fe9..51883abe 100644 --- a/Meshtastic/Helpers/MeshPackets.swift +++ b/Meshtastic/Helpers/MeshPackets.swift @@ -681,7 +681,7 @@ func telemetryPacket(packet: MeshPacket, connectedNode: Int64, context: NSManage telemetry.snr = packet.rxSnr telemetry.rssi = packet.rxRssi telemetry.time = Date(timeIntervalSince1970: TimeInterval(Int64(truncatingIfNeeded: telemetryMessage.time))) - + guard let mutableTelemetries = fetchedNode[0].telemetries!.mutableCopy() as? NSMutableOrderedSet else { return } diff --git a/Meshtastic/Persistence/Persistence.swift b/Meshtastic/Persistence/Persistence.swift index 25f9a3e2..96808c73 100644 --- a/Meshtastic/Persistence/Persistence.swift +++ b/Meshtastic/Persistence/Persistence.swift @@ -142,11 +142,11 @@ extension NSPersistentContainer { /// - Parameter backupURL: A file URL containing backup copies of all currently loaded persistent stores. /// - Throws: `CopyPersistentStoreError` in various situations. /// - Returns: Nothing. If no errors are thrown, the restore is complete. - func restorePersistentStore(from backupURL: URL) throws -> Void { + func restorePersistentStore(from backupURL: URL) throws { guard backupURL.isFileURL else { throw CopyPersistentStoreErrors.invalidSource("Backup URL must be a file URL") } - + var isDirectory: ObjCBool = false if FileManager.default.fileExists(atPath: backupURL.path, isDirectory: &isDirectory) { if !isDirectory.boolValue { @@ -185,7 +185,7 @@ extension NSPersistentContainer { /// - overwriting: If `true`, any existing copies of the persistent store will be replaced or updated. If `false`, existing copies will not be changed or remoted. When this is `false`, the destination persistent store file must not already exist. /// - Throws: `CopyPersistentStoreError` /// - Returns: Nothing. If no errors are thrown, all loaded persistent stores will be copied to the destination directory. - func copyPersistentStores(to destinationURL: URL, overwriting: Bool = false) throws -> Void { + func copyPersistentStores(to destinationURL: URL, overwriting: Bool = false) throws { guard !destinationURL.relativeString.contains("/0/") else { throw CopyPersistentStoreErrors.invalidDestination("Invalid 0 Node Id") diff --git a/Meshtastic/Persistence/UpdateCoreData.swift b/Meshtastic/Persistence/UpdateCoreData.swift index 381db194..c5aaa87d 100644 --- a/Meshtastic/Persistence/UpdateCoreData.swift +++ b/Meshtastic/Persistence/UpdateCoreData.swift @@ -262,7 +262,7 @@ func upsertNodeInfoPacket (packet: MeshPacket, context: NSManagedObjectContext) if fetchedNode[0].user == nil { let newUser = createUser(num: Int64(truncatingIfNeeded: packet.from), context: context) fetchedNode[0].user! = newUser - + } do { try context.save() diff --git a/Meshtastic/Views/Nodes/Helpers/Map/MapContent/MeshMapContent.swift b/Meshtastic/Views/Nodes/Helpers/Map/MapContent/MeshMapContent.swift index 2c943be9..527a896e 100644 --- a/Meshtastic/Views/Nodes/Helpers/Map/MapContent/MeshMapContent.swift +++ b/Meshtastic/Views/Nodes/Helpers/Map/MapContent/MeshMapContent.swift @@ -76,7 +76,7 @@ struct MeshMapContent: MapContent { } } } - .onTapGesture { location in + .onTapGesture { _ in selectedPosition = (selectedPosition == position ? nil : position) } } diff --git a/Meshtastic/Views/Nodes/Helpers/NodeDetail.swift b/Meshtastic/Views/Nodes/Helpers/NodeDetail.swift index 0f197e77..9addcde5 100644 --- a/Meshtastic/Views/Nodes/Helpers/NodeDetail.swift +++ b/Meshtastic/Views/Nodes/Helpers/NodeDetail.swift @@ -18,11 +18,11 @@ struct NodeDetail: View { // The node the device is currently connected to var connectedNode: NodeInfoEntity? - + // The node information being displayed on the detail screen @ObservedObject var node: NodeInfoEntity - + var columnVisibility = NavigationSplitViewVisibility.all var favoriteNodeAction: some View { @@ -251,7 +251,7 @@ struct NodeDetail: View { bleManager: bleManager, node: node ) - + if let connectedNode { if node.isStoreForwardRouter { ClientHistoryButton( diff --git a/Meshtastic/Views/Nodes/NodeList.swift b/Meshtastic/Views/Nodes/NodeList.swift index 096261ad..d8f6fc1c 100644 --- a/Meshtastic/Views/Nodes/NodeList.swift +++ b/Meshtastic/Views/Nodes/NodeList.swift @@ -35,7 +35,7 @@ struct NodeList: View { sortDescriptors: [ NSSortDescriptor(key: "favorite", ascending: false), NSSortDescriptor(key: "lastHeard", ascending: false), - NSSortDescriptor(key: "user.longName", ascending: true), + NSSortDescriptor(key: "user.longName", ascending: true) ], animation: .default )