Add SwiftFormat to the project. (#129)

* Run swiftformat for whitespace.
* Run swiftformat with some rules.
This commit is contained in:
Doug
2022-07-06 14:49:05 +01:00
committed by GitHub
parent 26d8affaa8
commit 02eb4b35e2
188 changed files with 759 additions and 717 deletions
@@ -21,4 +21,4 @@ protocol ApplicationProtocol {
var applicationState: UIApplication.State { get }
}
extension UIApplication: ApplicationProtocol {}
extension UIApplication: ApplicationProtocol { }
@@ -19,22 +19,22 @@ protocol BackgroundTaskServiceProtocol {
extension BackgroundTaskServiceProtocol {
func startBackgroundTask(withName name: String) -> BackgroundTaskProtocol? {
return startBackgroundTask(withName: name,
expirationHandler: nil)
startBackgroundTask(withName: name,
expirationHandler: nil)
}
func startBackgroundTask(withName name: String,
isReusable: Bool) -> BackgroundTaskProtocol? {
return startBackgroundTask(withName: name,
isReusable: isReusable,
expirationHandler: nil)
startBackgroundTask(withName: name,
isReusable: isReusable,
expirationHandler: nil)
}
func startBackgroundTask(withName name: String,
expirationHandler: (() -> Void)?) -> BackgroundTaskProtocol? {
return startBackgroundTask(withName: name,
isReusable: false,
expirationHandler: expirationHandler)
startBackgroundTask(withName: name,
isReusable: false,
expirationHandler: expirationHandler)
}
}
@@ -15,16 +15,17 @@ class UIKitBackgroundTask: BackgroundTaskProtocol {
var isRunning: Bool {
identifier != .invalid
}
let isReusable: Bool
let expirationHandler: BackgroundTaskExpirationHandler?
var elapsedTime: TimeInterval {
return Date().timeIntervalSince(startDate) * 1000
Date().timeIntervalSince(startDate) * 1000
}
private let application: ApplicationProtocol
private var identifier: UIBackgroundTaskIdentifier = .invalid
private var useCounter: Int = 0
private let startDate: Date = Date()
private var useCounter = 0
private let startDate = Date()
/// Initializes and starts a new background task
/// - Parameters:
@@ -35,7 +35,7 @@ class UIKitBackgroundTaskService: BackgroundTaskServiceProtocol {
expirationHandler?()
return nil
}
var created: Bool = false
var created = false
var result: BackgroundTaskProtocol?
if isReusable {
@@ -47,10 +47,10 @@ class UIKitBackgroundTaskService: BackgroundTaskServiceProtocol {
isReusable: isReusable,
application: application,
expirationHandler: { [weak self] task in
guard let self = self else { return }
self.reusableTasks[task.name] = nil
expirationHandler?()
}) {
guard let self = self else { return }
self.reusableTasks[task.name] = nil
expirationHandler?()
}) {
created = true
reusableTasks[name] = newTask
result = newTask
@@ -61,8 +61,8 @@ class UIKitBackgroundTaskService: BackgroundTaskServiceProtocol {
isReusable: isReusable,
application: application,
expirationHandler: { _ in
expirationHandler?()
}) {
expirationHandler?()
}) {
result = newTask
created = true
}
@@ -85,8 +85,8 @@ class UIKitBackgroundTaskService: BackgroundTaskServiceProtocol {
}
private func avoidStartingNewTasks(for application: ApplicationProtocol) -> Bool {
if application.applicationState == .background
&& application.backgroundTimeRemaining < .backgroundTimeRemainingThresholdToStartTasks {
if application.applicationState == .background,
application.backgroundTimeRemaining < .backgroundTimeRemainingThresholdToStartTasks {
return true
}
return false