Skip to content

Commit

Permalink
Lint
Browse files Browse the repository at this point in the history
  • Loading branch information
garthvh committed Aug 27, 2023
1 parent b165df9 commit a990d7f
Show file tree
Hide file tree
Showing 53 changed files with 92 additions and 550 deletions.
4 changes: 4 additions & 0 deletions Meshtastic.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@
DDDEE5E129DA3E1100A8E078 /* NodeInfoView.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDDEE5E029DA3E1100A8E078 /* NodeInfoView.swift */; };
DDE0F7C5295F77B700B8AAB3 /* AppSettingsEnums.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDE0F7C4295F77B700B8AAB3 /* AppSettingsEnums.swift */; };
DDF6B2482A9AEBF500BA6931 /* StoreForward.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDF6B2472A9AEBF500BA6931 /* StoreForward.swift */; };
DDF6B24A2A9B09A100BA6931 /* swiftlint.yml in Resources */ = {isa = PBXBuildFile; fileRef = DDF6B2492A9B09A100BA6931 /* swiftlint.yml */; };
DDF924CA26FBB953009FE055 /* ConnectedDevice.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDF924C926FBB953009FE055 /* ConnectedDevice.swift */; };
DDFEB3BB29900C1200EE7472 /* CurrentConditionsCompact.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDFEB3BA29900C1200EE7472 /* CurrentConditionsCompact.swift */; };
/* End PBXBuildFile section */
Expand Down Expand Up @@ -369,6 +370,7 @@
DDEE03EC29544A1000FCAD57 /* MeshtasticDataModelV4.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = MeshtasticDataModelV4.xcdatamodel; sourceTree = "<group>"; };
DDF6B2462A9AEB9E00BA6931 /* MeshtasticDataModelV17.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = MeshtasticDataModelV17.xcdatamodel; sourceTree = "<group>"; };
DDF6B2472A9AEBF500BA6931 /* StoreForward.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StoreForward.swift; sourceTree = "<group>"; };
DDF6B2492A9B09A100BA6931 /* swiftlint.yml */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.yaml; path = swiftlint.yml; sourceTree = "<group>"; };
DDF924C926FBB953009FE055 /* ConnectedDevice.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConnectedDevice.swift; sourceTree = "<group>"; };
DDFEB3BA29900C1200EE7472 /* CurrentConditionsCompact.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CurrentConditionsCompact.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */
Expand Down Expand Up @@ -597,6 +599,7 @@
DDC2E14B26CE248E0042C5E4 = {
isa = PBXGroup;
children = (
DDF6B2492A9B09A100BA6931 /* swiftlint.yml */,
DDCDC6CD29481FCC004C1DDA /* Localizable.strings */,
DD3CC6BA28E366DF00FA9159 /* Meshtastic.xcdatamodeld */,
DDC2E15626CE248E0042C5E4 /* Meshtastic */,
Expand Down Expand Up @@ -953,6 +956,7 @@
buildActionMask = 2147483647;
files = (
DDC2E15F26CE248F0042C5E4 /* Preview Assets.xcassets in Resources */,
DDF6B24A2A9B09A100BA6931 /* swiftlint.yml in Resources */,
DDCDC6CB29481FCC004C1DDA /* Localizable.strings in Resources */,
DDDE5A1329AFEAB900490C6C /* Assets.xcassets in Resources */,
DDB75A1A2A05EB67006ED576 /* alpha.png in Resources */,
Expand Down
15 changes: 0 additions & 15 deletions Meshtastic/Enums/AppSettingsEnums.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,13 @@ import Foundation
import MapKit

enum MeshMapTypes: Int, CaseIterable, Identifiable {

case standard = 0
case mutedStandard = 5
case hybrid = 2
case hybridFlyover = 4
case satellite = 1
case satelliteFlyover = 3

var id: Int { self.rawValue }

var description: String {
switch self {
case .standard:
Expand All @@ -36,7 +33,6 @@ enum MeshMapTypes: Int, CaseIterable, Identifiable {
}
}
func MKMapTypeValue() -> MKMapType {

switch self {
case .standard:
return MKMapType.standard
Expand All @@ -55,13 +51,10 @@ enum MeshMapTypes: Int, CaseIterable, Identifiable {
}

enum UserTrackingModes: Int, CaseIterable, Identifiable {

case none = 0
case follow = 1
case followWithHeading = 2

var id: Int { self.rawValue }

var description: String {
switch self {
case .none:
Expand All @@ -80,7 +73,6 @@ enum UserTrackingModes: Int, CaseIterable, Identifiable {
}
}
func MKUserTrackingModeValue() -> MKUserTrackingMode {

switch self {
case .none:
return MKUserTrackingMode.none
Expand All @@ -93,7 +85,6 @@ enum UserTrackingModes: Int, CaseIterable, Identifiable {
}

enum LocationUpdateInterval: Int, CaseIterable, Identifiable {

case fiveSeconds = 5
case tenSeconds = 10
case fifteenSeconds = 15
Expand All @@ -103,7 +94,6 @@ enum LocationUpdateInterval: Int, CaseIterable, Identifiable {
case fiveMinutes = 300
case tenMinutes = 600
case fifteenMinutes = 900

var id: Int { self.rawValue }
var description: String {
switch self {
Expand Down Expand Up @@ -138,7 +128,6 @@ enum MapLayer: String, CaseIterable, Equatable {
}

enum MapTileServer: String, CaseIterable, Identifiable {

case openStreetMap
case openStreetMapDE
case openStreetMapFR
Expand All @@ -154,8 +143,6 @@ enum MapTileServer: String, CaseIterable, Identifiable {
var id: String { self.rawValue }
var attribution: String {
switch self {


case .openStreetMap:
return "Map and data © [OpenStreetMap](http://www.openstreetmap.org) and contributors, [CC-BY-SA](http://creativecommons.org/licenses/by-sa/2.0/)"
case .openStreetMapDE:
Expand Down Expand Up @@ -276,7 +263,6 @@ enum OverlayType: String, CaseIterable, Equatable {
}

enum MapOverlayServer: String, CaseIterable, Identifiable {

case baseReReflectivityCurrent
case baseReReflectivityOneHourAgo
case echoTopsEetCurrent
Expand All @@ -290,7 +276,6 @@ enum MapOverlayServer: String, CaseIterable, Identifiable {
var id: String { self.rawValue }
var overlayType: OverlayType {
switch self {

case .baseReReflectivityCurrent:
return .tileServer
case .baseReReflectivityOneHourAgo:
Expand Down
3 changes: 0 additions & 3 deletions Meshtastic/Enums/HardwareModels.swift
Original file line number Diff line number Diff line change
Expand Up @@ -307,9 +307,7 @@ enum HardwareModels: String, CaseIterable, Identifiable {
}
}


enum HardwarePlatforms: String, CaseIterable, Identifiable {

case none
case esp32
case nrf52
Expand All @@ -319,7 +317,6 @@ enum HardwarePlatforms: String, CaseIterable, Identifiable {
var id: String { self.rawValue }
var description: String {
switch self {

case .none:
return "None"
case .esp32:
Expand Down
5 changes: 1 addition & 4 deletions Meshtastic/Extensions/Color.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,13 @@ extension Color {
}

extension UIColor {

/// Returns a boolean indicating if a color is light
/// - Returns: true if the color is light
func isLight() -> Bool {
guard let components = cgColor.components, components.count > 2 else {return false}
let brightness = ((components[0] * 299) + (components[1] * 587) + (components[2] * 114)) / 1000
return (brightness > 0.5)
}

/// Returns a UInt32 from a UIColor
/// - Returns: UInt32
var hex: UInt32 {
Expand All @@ -41,15 +39,14 @@ extension UIColor {
value += UInt32(blue * 255)
return value
}

/// Returns a UIColor from a UInt32 value
/// - Parameter hex: UInt32 value to convert to a color
/// - Returns: UIColor
convenience init(hex: UInt32) {
let red = CGFloat((hex & 0xFF0000) >> 16)
let green = CGFloat((hex & 0x00FF00) >> 8)
let blue = CGFloat((hex & 0x0000FF))
//print("\(red) - \(green) - \(blue)")
/// print("\(red) - \(green) - \(blue)")
self.init(red: red/255.0, green: green/255.0, blue: blue/255.0, alpha: 1.0)
}
}
1 change: 0 additions & 1 deletion Meshtastic/Extensions/Double.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import Foundation

extension Double {

var toBytes: String {
let formatter = MeasurementFormatter()
let measurement = Measurement(value: self, unit: UnitInformationStorage.bytes)
Expand Down
4 changes: 2 additions & 2 deletions Meshtastic/Extensions/FileManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import Foundation
let allocatedSizeResourceKeys: Set<URLResourceKey> = [
.isRegularFileKey,
.fileAllocatedSizeKey,
.totalFileAllocatedSizeKey,
.totalFileAllocatedSizeKey
]

public extension FileManager {
Expand All @@ -26,7 +26,7 @@ public extension FileManager {
func allocatedSizeOfDirectory(at directoryURL: URL) -> String {

// The error handler simply stores the error and stops traversal
var enumeratorError: Error? = nil
var enumeratorError: Error?
func errorHandler(_: URL, error: Error) -> Bool {
enumeratorError = error
return false
Expand Down
4 changes: 0 additions & 4 deletions Meshtastic/Extensions/String.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@ extension String {
}

var localized: String { NSLocalizedString(self, comment: self) }



func isEmoji() -> Bool {
// Emoji are no more than 4 bytes
if self.count > 4 {
Expand All @@ -45,7 +42,6 @@ extension String {
}
}
}

func onlyEmojis() -> Bool {
return count > 0 && !contains { !$0.isEmoji }
}
Expand Down
1 change: 0 additions & 1 deletion Meshtastic/Extensions/Url.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ extension URL {
guard resourceValues.isRegularFile ?? false else {
return 0
}

return UInt64(resourceValues.totalFileAllocatedSize ?? resourceValues.fileAllocatedSize ?? 0)
}
}
15 changes: 0 additions & 15 deletions Meshtastic/Extensions/UserDefaults.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import Foundation

extension UserDefaults {

enum Keys: String, CaseIterable {
case meshtasticUsername
case preferredPeripheralId
Expand All @@ -26,7 +25,6 @@ extension UserDefaults {
func reset() {
Keys.allCases.forEach { removeObject(forKey: $0.rawValue) }
}

static var meshtasticUsername: String {
get {
UserDefaults.standard.string(forKey: "meshtasticUsername") ?? ""
Expand All @@ -44,15 +42,13 @@ extension UserDefaults {
UserDefaults.standard.set(newValue, forKey: "preferredPeripheralId")
}
}

static var provideLocation: Bool {
get {
UserDefaults.standard.bool(forKey: "provideLocation")
} set {
UserDefaults.standard.set(newValue, forKey: "provideLocation")
}
}

static var provideLocationInterval: Int {
get {
UserDefaults.standard.integer(forKey: "provideLocationInterval")
Expand All @@ -61,7 +57,6 @@ extension UserDefaults {
UserDefaults.standard.set(newValue, forKey: "provideLocationInterval")
}
}

static var mapLayer: MapLayer {
get {
MapLayer(rawValue: UserDefaults.standard.string(forKey: "mapLayer") ?? MapLayer.standard.rawValue) ?? MapLayer.standard
Expand All @@ -70,7 +65,6 @@ extension UserDefaults {
UserDefaults.standard.set(newValue.rawValue, forKey: "mapLayer")
}
}

static var enableMapRecentering: Bool {
get {
UserDefaults.standard.bool(forKey: "meshMapRecentering")
Expand All @@ -79,7 +73,6 @@ extension UserDefaults {
UserDefaults.standard.set(newValue, forKey: "meshMapRecentering")
}
}

static var enableMapNodeHistoryPins: Bool {
get {
UserDefaults.standard.bool(forKey: "meshMapShowNodeHistory")
Expand All @@ -88,7 +81,6 @@ extension UserDefaults {
UserDefaults.standard.set(newValue, forKey: "meshMapShowNodeHistory")
}
}

static var enableMapRouteLines: Bool {
get {
UserDefaults.standard.bool(forKey: "meshMapShowRouteLines")
Expand All @@ -97,7 +89,6 @@ extension UserDefaults {
UserDefaults.standard.set(newValue, forKey: "meshMapShowRouteLines")
}
}

static var enableOfflineMaps: Bool {
get {
UserDefaults.standard.bool(forKey: "enableOfflineMaps")
Expand All @@ -114,17 +105,14 @@ extension UserDefaults {
UserDefaults.standard.set(newValue, forKey: "enableOfflineMapsMBTiles")
}
}

static var mapTileServer: MapTileServer {
get {

MapTileServer(rawValue: UserDefaults.standard.string(forKey: "mapTileServer") ?? MapTileServer.openStreetMap.rawValue) ?? MapTileServer.openStreetMap
}
set {
UserDefaults.standard.set(newValue.rawValue, forKey: "mapTileServer")
}
}

static var enableOverlayServer: Bool {
get {
UserDefaults.standard.bool(forKey: "enableOverlayServer")
Expand All @@ -133,17 +121,14 @@ extension UserDefaults {
UserDefaults.standard.set(newValue, forKey: "enableOverlayServer")
}
}

static var mapOverlayServer: MapOverlayServer {
get {

MapOverlayServer(rawValue: UserDefaults.standard.string(forKey: "mapOverlayServer") ?? MapOverlayServer.baseReReflectivityCurrent.rawValue) ?? MapOverlayServer.baseReReflectivityCurrent
}
set {
UserDefaults.standard.set(newValue.rawValue, forKey: "mapOverlayServer")
}
}

static var mapTilesAboveLabels: Bool {
get {
UserDefaults.standard.bool(forKey: "mapTilesAboveLabels")
Expand Down
Loading

0 comments on commit a990d7f

Please sign in to comment.