Skip to content

Commit

Permalink
Final Swiftlint fixes (yay)
Browse files Browse the repository at this point in the history
  • Loading branch information
robbiet480 committed Nov 20, 2017
1 parent d379222 commit 5ab76d5
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 20 deletions.
4 changes: 2 additions & 2 deletions HomeAssistant/AppDelegate.swift
Expand Up @@ -247,12 +247,12 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
coordinates: location.coordinate,
accuracy: location.horizontalAccuracy,
zone: nil)
}) { (_, _, error) -> Void in
}, error: { (_, _, error) -> Void in
// something went wrong. request will be cancelled automatically
NSLog("Error during significant location update registration: @%",
error.localizedDescription)
Crashlytics.sharedInstance().recordError(error)
}
})
}
}

Expand Down
8 changes: 3 additions & 5 deletions HomeAssistant/HAAPI.swift
Expand Up @@ -204,14 +204,12 @@ public class HomeAssistantAPI {
batteryState = "Full"
}

let hostname = UIDevice().name

let locationUpdate: [String: Any] = [
"battery": Int(UIDevice.current.batteryLevel*100),
"battery_status": batteryState,
"gps": [coordinates.latitude, coordinates.longitude],
"gps_accuracy": accuracy,
"hostname": hostname,
"hostname": UIDevice.current.name,
"dev_id": deviceID
]

Expand Down Expand Up @@ -354,11 +352,11 @@ public class HomeAssistantAPI {
accuracy: location.horizontalAccuracy,
zone: nil)
fulfill(true)
}) { (_, _, error) in
}, error: { (_, _, error) in
print("Error when trying to get a oneshot location for \(updateTrigger) trigger!", error)
Crashlytics.sharedInstance().recordError(error)
reject(error)
}
})
}
}

Expand Down
15 changes: 2 additions & 13 deletions HomeAssistant/Utilities/Utils.swift
Expand Up @@ -198,8 +198,8 @@ func openURLInBrowser(urlToOpen: URL) {

func removeSpecialCharsFromString(text: String) -> String {
let okayChars: Set<Character> =
Set("abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLKMNOPQRSTUVWXYZ1234567890".characters)
return String(text.characters.filter {okayChars.contains($0) })
Set("abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLKMNOPQRSTUVWXYZ1234567890")
return String(text.filter {okayChars.contains($0) })
}

func convertToDictionary(text: String) -> [String: Any]? {
Expand Down Expand Up @@ -274,14 +274,3 @@ extension UIImage {
return newImage
}
}

extension String {

subscript (i: Int) -> Character {
return self[self.characters.index(self.startIndex, offsetBy: i)]
}

subscript (i: Int) -> String {
return String(self[i] as Character)
}
}

0 comments on commit 5ab76d5

Please sign in to comment.