From 82a8336e35a44c18d76eb86d3d19b14a211ec260 Mon Sep 17 00:00:00 2001 From: Garth Vander Houwen Date: Sun, 2 Jun 2024 20:13:40 -0700 Subject: [PATCH] Additional swift lint fixes --- Meshtastic/Export/WriteCsvFile.swift | 2 -- Meshtastic/Helpers/BLEManager.swift | 9 ++++----- Meshtastic/Helpers/MeshPackets.swift | 2 +- Meshtastic/Views/Messages/ChannelList.swift | 2 +- Meshtastic/Views/Nodes/MeshMap.swift | 16 ++++++++-------- Meshtastic/Views/Nodes/TraceRouteLog.swift | 6 +----- 6 files changed, 15 insertions(+), 22 deletions(-) diff --git a/Meshtastic/Export/WriteCsvFile.swift b/Meshtastic/Export/WriteCsvFile.swift index c43fe7a1..521dc937 100644 --- a/Meshtastic/Export/WriteCsvFile.swift +++ b/Meshtastic/Export/WriteCsvFile.swift @@ -116,8 +116,6 @@ func positionToCsvFile(positions: [PositionEntity]) -> String { func routeToCsvFile(locations: [LocationEntity]) -> String { var csvString: String = "" - let localeDateFormat = DateFormatter.dateFormat(fromTemplate: "yyMMddjmma", options: 0, locale: Locale.current) - let dateFormatString = (localeDateFormat ?? "MM/dd/YY j:mma").replacingOccurrences(of: ",", with: "") // Create Position Header csvString = "Id, Latitude, Longitude, Altitude, Speed, Heading" for loc in locations { diff --git a/Meshtastic/Helpers/BLEManager.swift b/Meshtastic/Helpers/BLEManager.swift index 9c59a12f..d96b89c5 100644 --- a/Meshtastic/Helpers/BLEManager.swift +++ b/Meshtastic/Helpers/BLEManager.swift @@ -729,20 +729,19 @@ class BLEManager: NSObject, CBPeripheralDelegate, MqttClientProxyManagerDelegate } case .neighborinfoApp: if let neighborInfo = try? NeighborInfo(serializedData: decodedInfo.packet.decoded.payload) { - MeshLogger.log("🕸️ MESH PACKET received for Neighbor Info App UNHANDLED") - // MeshLogger.log("🕸️ MESH PACKET received for Neighbor Info App UNHANDLED \(neighborInfo)") + // MeshLogger.log("🕸️ MESH PACKET received for Neighbor Info App UNHANDLED") + MeshLogger.log("🕸️ MESH PACKET received for Neighbor Info App UNHANDLED \(neighborInfo)") } case .paxcounterApp: paxCounterPacket(packet: decodedInfo.packet, context: context!) case .mapReportApp: - MeshLogger.log("🕸️ MESH PACKET received for Map Report App UNHANDLED\(try! decodedInfo.packet.jsonString())") + MeshLogger.log("🕸️ MESH PACKET received Map Report App UNHANDLED \((try? decodedInfo.packet.jsonString()) ?? "JSON Decode Failure")") case .UNRECOGNIZED: - MeshLogger.log("🕸️ MESH PACKET received for Other App UNHANDLED \(try! decodedInfo.packet.jsonString())") + MeshLogger.log("🕸️ MESH PACKET received UNRECOGNIZED App UNHANDLED \((try? decodedInfo.packet.jsonString()) ?? "JSON Decode Failure")") case .max: logger.info("MAX PORT NUM OF 511") case .atakPlugin: MeshLogger.log("🕸️ MESH PACKET received for ATAK Plugin App UNHANDLED \((try? decodedInfo.packet.jsonString()) ?? "JSON Decode Failure")") - } if decodedInfo.configCompleteID != 0 && decodedInfo.configCompleteID == configNonce { diff --git a/Meshtastic/Helpers/MeshPackets.swift b/Meshtastic/Helpers/MeshPackets.swift index 369e022b..2d407016 100644 --- a/Meshtastic/Helpers/MeshPackets.swift +++ b/Meshtastic/Helpers/MeshPackets.swift @@ -517,7 +517,7 @@ func adminAppPacket (packet: MeshPacket, context: NSManagedObjectContext) { let ringtone = adminMessage.getRingtoneResponse upsertRtttlConfigPacket(ringtone: ringtone, nodeNum: Int64(packet.from), context: context) } else { - MeshLogger.log("🕸️ MESH PACKET received for Admin App \(try! packet.decoded.jsonString())") + MeshLogger.log("🕸️ MESH PACKET received Admin App UNHANDLED \((try? packet.decoded.jsonString()) ?? "JSON Decode Failure")") } // Save an ack for the admin message log for each admin message response received as we stopped sending acks if there is also a response to reduce airtime. adminResponseAck(packet: packet, context: context) diff --git a/Meshtastic/Views/Messages/ChannelList.swift b/Meshtastic/Views/Messages/ChannelList.swift index c1c47a89..2d0e2a7e 100644 --- a/Meshtastic/Views/Messages/ChannelList.swift +++ b/Meshtastic/Views/Messages/ChannelList.swift @@ -127,7 +127,7 @@ struct ChannelList: View { } catch { context.rollback() - print("💥 Save Channel Mute Error") + logger.error("💥 Save Channel Mute Error") } } label: { Label(channel.mute ? "Show Alerts" : "Hide Alerts", systemImage: channel.mute ? "bell" : "bell.slash") diff --git a/Meshtastic/Views/Nodes/MeshMap.swift b/Meshtastic/Views/Nodes/MeshMap.swift index 18a61228..261ea393 100644 --- a/Meshtastic/Views/Nodes/MeshMap.swift +++ b/Meshtastic/Views/Nodes/MeshMap.swift @@ -109,25 +109,25 @@ struct MeshMap: View { // // if ((newPath?.hasPrefix("meshtastic://open-waypoint")) != nil) { // guard let url = URL(string: appState.navigationPath ?? "NONE") else { -// print("Invalid URL") +// logger.error("Invalid URL") // return // } // guard let components = URLComponents(url: url, resolvingAgainstBaseURL: true) else { -// print("Invalid URL Components") +// logger.error("Invalid URL Components") // return // } // guard let action = components.host, action == "open-waypoint" else { -// print("Unknown waypoint URL action") +// logger.error("Unknown waypoint URL action") // return // } // guard let waypointId = components.queryItems?.first(where: { $0.name == "id" })?.value else { -// print("Waypoint id not found") +// logger.error("Waypoint id not found") +// return +// } +// guard let waypoint = waypoints.first(where: { $0.id == Int64(waypointId) }) else { +// logger.error("Waypoint not found") // return // } -//// guard let waypoint = waypoints.first(where: { $0.id == Int64(waypointId) }) else { -//// print("Waypoint not found") -//// return -//// } // //showWaypoints = true // //position = .camera(MapCamera(centerCoordinate: waypoint.coordinate, distance: 1000, heading: 0, pitch: 60)) // } diff --git a/Meshtastic/Views/Nodes/TraceRouteLog.swift b/Meshtastic/Views/Nodes/TraceRouteLog.swift index 55dd6d20..cd44cd30 100644 --- a/Meshtastic/Views/Nodes/TraceRouteLog.swift +++ b/Meshtastic/Views/Nodes/TraceRouteLog.swift @@ -64,10 +64,6 @@ struct TraceRouteLog: View { .font(.title2) } - let hopsArray = selectedRoute?.hops?.array as? [TraceRouteHopEntity] ?? [] - let lineCoords = hopsArray.compactMap({(hop) -> CLLocationCoordinate2D in - return hop.coordinate ?? LocationHelper.DefaultLocation - }) if selectedRoute?.response ?? false { if selectedRoute?.hasPositions ?? false { Map(position: $position, bounds: MapCameraBounds(minimumDistance: 1, maximumDistance: .infinity), scope: mapScope) { @@ -83,7 +79,7 @@ struct TraceRouteLog: View { // Direct Trace Route if selectedRoute?.response ?? false && selectedRoute?.hops?.count ?? 0 == 0 { if selectedRoute?.node?.positions?.count ?? 0 > 0, let mostRecent = selectedRoute?.node?.positions?.lastObject as? PositionEntity { - var traceRouteCoords: [CLLocationCoordinate2D] = [selectedRoute?.coordinate ?? LocationsHandler.DefaultLocation, mostRecent.coordinate] + let traceRouteCoords: [CLLocationCoordinate2D] = [selectedRoute?.coordinate ?? LocationsHandler.DefaultLocation, mostRecent.coordinate] Annotation(selectedRoute?.node?.user?.shortName ?? "???", coordinate: mostRecent.nodeCoordinate ?? LocationHelper.DefaultLocation) { ZStack { Circle()