Commit 93bc2994 authored by Roddi Deecke's avatar Roddi Deecke Committed by Thomas Mellenthin

fix "Syntactic Sugar" violations

parent 9905a3cf
......@@ -16,7 +16,6 @@ disabled_rules:
- function_parameter_count
- line_length
- force_cast
- syntactic_sugar
- implicit_getter
- todo
- file_length
......
......@@ -9,7 +9,7 @@
import CoreBluetooth
protocol BluetoothManagerDelegate: class {
func didFindNewPeripherals(_ peripherals: Array<FoundPeripheral>?)
func didFindNewPeripherals(_ peripherals: [FoundPeripheral]?)
func didConnectToPeripheal(_ peripheral: FoundPeripheral?)
func didDisconnectFromPeripheral()
func didGetNewLightSensorData(_ data: UInt16)
......@@ -20,7 +20,7 @@ protocol BluetoothManagerDelegate: class {
// Provide default empty implementation to avoid empty boilerplate in the delegate
extension BluetoothManagerDelegate {
func didFindNewPeripherals(_ peripherals: Array<FoundPeripheral>?) {}
func didFindNewPeripherals(_ peripherals: [FoundPeripheral]?) {}
func didConnectToPeripheal(_ peripheral: FoundPeripheral?) {}
func didDisconnectFromPeripheral() {}
func didGetNewLightSensorData(_ data: UInt16) {}
......@@ -97,7 +97,7 @@ class BluetoothManager: NSObject, CBCentralManagerDelegate, CBPeripheralDelegate
let card10TXWriteCharacteristicUUID = CBUUID(string: "42230101-2342-2342-2342-234223422342")
let card10RXReadCharacteristicUUID = CBUUID(string: "42230102-2342-2342-2342-234223422342")
private(set) public var foundPeripheral: Array<FoundPeripheral>
private(set) public var foundPeripheral: [FoundPeripheral]
public var connectedPeripheral: CBPeripheral?
/// Holds BluetoothManagerDelegates weakly
......
......@@ -11,7 +11,7 @@ import CoreBluetooth
public class Card10TabBarController: UITabBarController, UITabBarControllerDelegate, BluetoothManagerDelegate {
var allViewControllers: Array<UIViewController>? = []
var allViewControllers: [UIViewController]? = []
public override func viewDidLoad() {
super.viewDidLoad()
......
......@@ -27,7 +27,7 @@ extension HatcheryClientDelegate {
class HatcheryClient: NSObject, URLSessionDelegate {
let hatcheryBaseURL: URL = URL(string: "https://badge.team/")!
private(set) public var loadedEggs: Array<Array<HatcheryEgg>> = []
private(set) public var loadedEggs: [[HatcheryEgg]] = []
weak var delegate: HatcheryClientDelegate?
......@@ -59,8 +59,8 @@ class HatcheryClient: NSObject, URLSessionDelegate {
let json = try JSONSerialization.jsonObject(with: data!, options: [])
if let jsonArray = json as? [Any] {
self.loadedEggs.removeAll()
var loadedEggsUncategorized: Array<HatcheryEgg> = []
for case let dictionary as Dictionary<String, Any> in jsonArray {
var loadedEggsUncategorized: [HatcheryEgg] = []
for case let dictionary as [String: Any] in jsonArray {
loadedEggsUncategorized.append(HatcheryEgg.init(dictionary: dictionary))
}
......@@ -69,7 +69,7 @@ class HatcheryClient: NSObject, URLSessionDelegate {
uniqueCategories = uniqueCategories.sorted { $0.lowercased() < $1.lowercased() }
for category in uniqueCategories {
var eggsForCategory: Array<HatcheryEgg> = []
var eggsForCategory: [HatcheryEgg] = []
for egg in loadedEggsUncategorized {
if egg.category == category {
eggsForCategory.append(egg)
......@@ -109,9 +109,9 @@ class HatcheryClient: NSObject, URLSessionDelegate {
do {
let json = try JSONSerialization.jsonObject(with: data!, options: [])
if let eggDict = json as? Dictionary<String, Any> {
if let releases = eggDict["releases"] as? Dictionary<String, Any> {
if let latestRelease = releases[revision] as? Array<Dictionary<String, String>> {
if let eggDict = json as? [String: Any] {
if let releases = eggDict["releases"] as? [String: Any] {
if let latestRelease = releases[revision] as? [[String: String]] {
let releaseURL = latestRelease[0]["url"]
self.downloadRelease(fromURL: URL(string: releaseURL!)!)
}
......
......@@ -20,9 +20,9 @@ class HatcheryEgg: NSObject {
private(set) public var sizeOfContent: Double?
private(set) public var category: String?
let dictionary: Dictionary<String, Any>
let dictionary: [String: Any]
init(dictionary: Dictionary<String, Any>) {
init(dictionary: [String: Any]) {
self.dictionary = dictionary
self.name = dictionary["name"] as? String
......
......@@ -111,7 +111,7 @@ extension ScannerTableViewController {
extension ScannerTableViewController: BluetoothManagerDelegate {
func didFindNewPeripherals(_ peripherals: Array<FoundPeripheral>?) {
func didFindNewPeripherals(_ peripherals: [FoundPeripheral]?) {
self.tableView.reloadSections(IndexSet(integer: 0), with: .automatic)
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment