From a47661665ec8694086cad73702ea6959704e10f5 Mon Sep 17 00:00:00 2001 From: Abhishek Banthia <8280282+n0shake@users.noreply.github.com> Date: Mon, 5 Jul 2021 17:22:17 -0400 Subject: [PATCH] Formatting. --- .../Overall App/Foundation + Additions.swift | 6 ++--- Clocker/Overall App/NetworkManager.swift | 3 ++- Clocker/Overall App/Reach.swift | 4 ++-- .../Overall App/VersionUpdateHandler.swift | 2 +- .../Data Layer/TimezoneDataOperations.swift | 22 ++++++++++--------- Clocker/Panel/FloatingWindowController.swift | 2 +- 6 files changed, 21 insertions(+), 18 deletions(-) diff --git a/Clocker/Overall App/Foundation + Additions.swift b/Clocker/Overall App/Foundation + Additions.swift index 6b7336d7..3e6caf8a 100644 --- a/Clocker/Overall App/Foundation + Additions.swift +++ b/Clocker/Overall App/Foundation + Additions.swift @@ -34,9 +34,9 @@ extension NSImage.Name { static let menubarIcon = NSImage.Name("LightModeIcon") } -extension Data { +public extension Data { // Extracting this out for tests - public func decode() -> SearchResult? { + func decode() -> SearchResult? { let jsonDecoder = JSONDecoder() do { let decodedObject = try jsonDecoder.decode(SearchResult.self, from: self) @@ -46,7 +46,7 @@ extension Data { } } - public func decodeTimezone() -> Timezone? { + func decodeTimezone() -> Timezone? { let jsonDecoder = JSONDecoder() do { let decodedObject = try jsonDecoder.decode(Timezone.self, from: self) diff --git a/Clocker/Overall App/NetworkManager.swift b/Clocker/Overall App/NetworkManager.swift index ba6b3f05..fcfe8667 100644 --- a/Clocker/Overall App/NetworkManager.swift +++ b/Clocker/Overall App/NetworkManager.swift @@ -41,7 +41,8 @@ extension NetworkManager { let session = URLSession(configuration: configuration) guard let encodedPath = path.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed), - let url = URL(string: encodedPath) else { + let url = URL(string: encodedPath) + else { completionHandler(nil, unableToGenerateURL) return nil } diff --git a/Clocker/Overall App/Reach.swift b/Clocker/Overall App/Reach.swift index 191870ee..b7a1b413 100644 --- a/Clocker/Overall App/Reach.swift +++ b/Clocker/Overall App/Reach.swift @@ -54,8 +54,8 @@ open class Reach { } } -extension ReachabilityStatus { - fileprivate init(reachabilityFlags flags: SCNetworkReachabilityFlags) { +private extension ReachabilityStatus { + init(reachabilityFlags flags: SCNetworkReachabilityFlags) { let connectionRequired = flags.contains(.connectionRequired) let isReachable = flags.contains(.reachable) diff --git a/Clocker/Overall App/VersionUpdateHandler.swift b/Clocker/Overall App/VersionUpdateHandler.swift index 7e423160..88a46005 100644 --- a/Clocker/Overall App/VersionUpdateHandler.swift +++ b/Clocker/Overall App/VersionUpdateHandler.swift @@ -25,7 +25,7 @@ class VersionUpdateHandler: NSObject { private var appStoreCountry: String! private var applicationVersion: String! private var applicationBundleID: String = Bundle.main.bundleIdentifier ?? "N/A" - private var updatePriority: VersionUpdateHandlerPriority = VersionUpdateHandlerPriority.defaultPri + private var updatePriority = VersionUpdateHandlerPriority.defaultPri private var useAllAvailableLanguages: Bool = true private var onlyPromptIfMainWindowIsAvailable: Bool = true private var checkAtLaunch: Bool = true diff --git a/Clocker/Panel/Data Layer/TimezoneDataOperations.swift b/Clocker/Panel/Data Layer/TimezoneDataOperations.swift index f0d4f1fe..9be80f8e 100644 --- a/Clocker/Panel/Data Layer/TimezoneDataOperations.swift +++ b/Clocker/Panel/Data Layer/TimezoneDataOperations.swift @@ -7,7 +7,7 @@ import CoreModelKit class TimezoneDataOperations: NSObject { private var dataObject: TimezoneData! - private lazy var nsCalendar: Calendar = Calendar.autoupdatingCurrent + private lazy var nsCalendar = Calendar.autoupdatingCurrent private static var gregorianCalendar = NSCalendar(calendarIdentifier: NSCalendar.Identifier.gregorian) private static var swiftyCalendar = Calendar(identifier: .gregorian) private static let currentLocale = Locale.current.identifier @@ -22,12 +22,13 @@ extension TimezoneDataOperations { guard let newDate = TimezoneDataOperations.gregorianCalendar?.date(byAdding: .minute, value: sliderValue, to: Date(), - options: .matchFirst) else { + options: .matchFirst) + else { assertionFailure("Data was unexpectedly nil") return CLEmptyString } - - if (dataObject.timezoneFormat(DataStore.shared().timezoneFormat()) == DateFormat.epochTime) { + + if dataObject.timezoneFormat(DataStore.shared().timezoneFormat()) == DateFormat.epochTime { let timezone = TimeZone(identifier: dataObject.timezone()) let offset = timezone?.secondsFromGMT(for: newDate) ?? 0 let value = Int(Date().timeIntervalSince1970 + Double(offset)) @@ -38,7 +39,6 @@ extension TimezoneDataOperations { format: dataObject.timezoneFormat(DataStore.shared().timezoneFormat()), timezoneIdentifier: dataObject.timezone(), locale: Locale.autoupdatingCurrent) - return dateFormatter.string(from: newDate) } @@ -52,7 +52,8 @@ extension TimezoneDataOperations { guard let newDate = TimezoneDataOperations.gregorianCalendar?.date(byAdding: .minute, value: sliderValue, to: Date(), - options: .matchFirst) else { + options: .matchFirst) + else { assertionFailure("Data was unexpectedly nil") return nil } @@ -204,8 +205,8 @@ extension TimezoneDataOperations { let sourceTimezone = TimeZone.current let destinationTimezone = TimeZone(identifier: dataObject.timezone()) - let sourceGMTOffset: Double = Double(sourceTimezone.secondsFromGMT(for: source)) - let destinationGMTOffset: Double = Double(destinationTimezone?.secondsFromGMT(for: source) ?? 0) + let sourceGMTOffset = Double(sourceTimezone.secondsFromGMT(for: source)) + let destinationGMTOffset = Double(destinationTimezone?.secondsFromGMT(for: source) ?? 0) let interval = destinationGMTOffset - sourceGMTOffset return Date(timeInterval: interval, since: source) @@ -367,12 +368,13 @@ extension TimezoneDataOperations { to: Date()) guard let lat = dataObject.latitude, - let long = dataObject.longitude else { + let long = dataObject.longitude + else { assertionFailure("Data was unexpectedly nil.") return } - let coordinates: CLLocationCoordinate2D = CLLocationCoordinate2D(latitude: lat, longitude: long) + let coordinates = CLLocationCoordinate2D(latitude: lat, longitude: long) guard let dateForCalculation = currentDate, let solar = Solar(for: dateForCalculation, coordinate: coordinates) else { return diff --git a/Clocker/Panel/FloatingWindowController.swift b/Clocker/Panel/FloatingWindowController.swift index f69a7e19..4f357751 100644 --- a/Clocker/Panel/FloatingWindowController.swift +++ b/Clocker/Panel/FloatingWindowController.swift @@ -5,7 +5,7 @@ import Cocoa class FloatingWindowController: ParentPanelController { private var repeater: Repeater? - static var sharedWindow: FloatingWindowController = FloatingWindowController(windowNibName: NSNib.Name.floatingWindowIdentifier) + static var sharedWindow = FloatingWindowController(windowNibName: NSNib.Name.floatingWindowIdentifier) override func windowDidLoad() { super.windowDidLoad()