Skip to content

Commit b90ddf1

Browse files
authored
Limit Swift line lengths to 100 (#5315)
1 parent ee5f8a3 commit b90ddf1

File tree

36 files changed

+561
-261
lines changed

36 files changed

+561
-261
lines changed

CoreOnly/Tests/FirebasePodTest/FirebasePodTest/AppDelegate.swift

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ class FirestoreExists: Firestore {}
2626
class FunctionsExists: Functions {}
2727
class InAppMessagingExists: InAppMessaging {}
2828
class InAppMessagingDisplayExists: InAppMessagingDisplay { // protocol instead of interface
29-
func displayMessage(_ messageForDisplay: InAppMessagingDisplayMessage, displayDelegate: InAppMessagingDisplayDelegate) {}
29+
func displayMessage(_ messageForDisplay: InAppMessagingDisplayMessage,
30+
displayDelegate: InAppMessagingDisplayDelegate) {}
3031
}
3132

3233
class MessagingExists: Messaging {}
@@ -36,20 +37,26 @@ class StorageExists: Storage {}
3637

3738
@UIApplicationMain
3839
class AppDelegate: UIResponder, UIApplicationDelegate {
39-
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
40+
func application(_ application: UIApplication,
41+
didFinishLaunchingWithOptions launchOptions: [UIApplication
42+
.LaunchOptionsKey: Any]?) -> Bool {
4043
// Override point for customization after application launch.
4144
return true
4245
}
4346

4447
// MARK: UISceneSession Lifecycle
4548

46-
func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration {
49+
func application(_ application: UIApplication,
50+
configurationForConnecting connectingSceneSession: UISceneSession,
51+
options: UIScene.ConnectionOptions) -> UISceneConfiguration {
4752
// Called when a new scene session is being created.
4853
// Use this method to select a configuration to create the new scene with.
49-
return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role)
54+
return UISceneConfiguration(name: "Default Configuration",
55+
sessionRole: connectingSceneSession.role)
5056
}
5157

52-
func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set<UISceneSession>) {
58+
func application(_ application: UIApplication,
59+
didDiscardSceneSessions sceneSessions: Set<UISceneSession>) {
5360
// Called when the user discards a scene session.
5461
// If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions.
5562
// Use this method to release any resources that were specific to the discarded scenes, as they will not return.

CoreOnly/Tests/FirebasePodTest/FirebasePodTest/SceneDelegate.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ import UIKit
1717
class SceneDelegate: UIResponder, UIWindowSceneDelegate {
1818
var window: UIWindow?
1919

20-
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
20+
func scene(_ scene: UIScene,
21+
willConnectTo session: UISceneSession,
22+
options connectionOptions: UIScene.ConnectionOptions) {
2123
// Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`.
2224
// If using a storyboard, the `window` property will automatically be initialized and attached to the scene.
2325
// This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead).

Example/Auth/ApiTests/PhoneMultiFactorTests.swift

Lines changed: 70 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -30,77 +30,93 @@ class PhoneMultiFactorTests: FIRAuthApiTestsBase {
3030
func testEnrollUnenroll() {
3131
let enrollExpectation = expectation(description: "Enroll phone multi factor finished.")
3232
let unenrollExpectation = expectation(description: "Unenroll phone multi factor finished.")
33-
Auth.auth().signIn(withEmail: kNoSecondFactorUserEmail, password: kNoSecondFactorUserPassword) { result, error in
34-
XCTAssertNil(error, "User normal sign in failed. Error: \(error!.localizedDescription)")
33+
Auth.auth()
34+
.signIn(withEmail: kNoSecondFactorUserEmail,
35+
password: kNoSecondFactorUserPassword) { result, error in
36+
XCTAssertNil(error, "User normal sign in failed. Error: \(error!.localizedDescription)")
3537

36-
// Enroll
37-
guard let user = result?.user else {
38-
XCTFail("No valid user after attempted sign-in.")
39-
}
40-
user.multiFactor.getSessionWithCompletion { session, error in
41-
XCTAssertNil(error, "Get multi factor session failed. Error: \(error!.localizedDescription)")
42-
PhoneAuthProvider.provider().verifyPhoneNumber(
43-
kPhoneSecondFactorPhoneNumber,
44-
uiDelegate: nil,
45-
multiFactorSession: session
46-
) { verificationId, error in
47-
XCTAssertNil(error, "Verify phone number failed. Error: \(error!.localizedDescription)")
48-
let credential = PhoneAuthProvider.provider().credential(
49-
withVerificationID: verificationId!,
50-
verificationCode: kPhoneSecondFactorVerificationCode
51-
)
52-
let assertion = PhoneMultiFactorGenerator.assertion(with: credential)
53-
user?.multiFactor.enroll(with: assertion, displayName: kPhoneSecondFactorDisplayName) { error in
54-
XCTAssertNil(error, "Phone multi factor enroll failed. Error: \(error!.localizedDescription)")
55-
XCTAssertEqual(Auth.auth().currentUser?.multiFactor.enrolledFactors.first?.displayName, kPhoneSecondFactorDisplayName)
56-
enrollExpectation.fulfill()
38+
// Enroll
39+
guard let user = result?.user else {
40+
XCTFail("No valid user after attempted sign-in.")
41+
}
42+
user.multiFactor.getSessionWithCompletion { session, error in
43+
XCTAssertNil(error,
44+
"Get multi factor session failed. Error: \(error!.localizedDescription)")
45+
PhoneAuthProvider.provider().verifyPhoneNumber(
46+
kPhoneSecondFactorPhoneNumber,
47+
uiDelegate: nil,
48+
multiFactorSession: session
49+
) { verificationId, error in
50+
XCTAssertNil(error, "Verify phone number failed. Error: \(error!.localizedDescription)")
51+
let credential = PhoneAuthProvider.provider().credential(
52+
withVerificationID: verificationId!,
53+
verificationCode: kPhoneSecondFactorVerificationCode
54+
)
55+
let assertion = PhoneMultiFactorGenerator.assertion(with: credential)
56+
user?.multiFactor
57+
.enroll(with: assertion, displayName: kPhoneSecondFactorDisplayName) { error in
58+
XCTAssertNil(error,
59+
"Phone multi factor enroll failed. Error: \(error!.localizedDescription)")
60+
XCTAssertEqual(Auth.auth().currentUser?.multiFactor.enrolledFactors.first?
61+
.displayName,
62+
kPhoneSecondFactorDisplayName)
63+
enrollExpectation.fulfill()
5764

58-
// Unenroll
59-
user = Auth.auth().currentUser
60-
user?.multiFactor.unenroll(with: (user?.multiFactor.enrolledFactors.first)!, completion: { error in
61-
XCTAssertNil(error, "Phone multi factor unenroll failed. Error: \(error!.localizedDescription)")
62-
XCTAssertEqual(Auth.auth().currentUser?.multiFactor.enrolledFactors.count, 0)
63-
unenrollExpectation.fulfill()
65+
// Unenroll
66+
user = Auth.auth().currentUser
67+
user?.multiFactor
68+
.unenroll(with: (user?.multiFactor.enrolledFactors.first)!, completion: { error in
69+
XCTAssertNil(error,
70+
"Phone multi factor unenroll failed. Error: \(error!.localizedDescription)")
71+
XCTAssertEqual(Auth.auth().currentUser?.multiFactor.enrolledFactors.count, 0)
72+
unenrollExpectation.fulfill()
6473
})
74+
}
6575
}
6676
}
6777
}
68-
}
6978

7079
waitForExpectations(timeout: 30) { error in
71-
XCTAssertNil(error, "Failed to wait for enroll and unenroll phone multi factor finished. Error: \(error!.localizedDescription)")
80+
XCTAssertNil(error,
81+
"Failed to wait for enroll and unenroll phone multi factor finished. Error: \(error!.localizedDescription)")
7282
}
7383
}
7484

7585
func testSignInWithSecondFactor() {
7686
let signInExpectation = expectation(description: "Sign in with phone multi factor finished.")
77-
Auth.auth().signIn(withEmail: kOneSecondFactorUserEmail, password: kOneSecondFactorUserPassword) { result, error in
78-
// SignIn
79-
guard let error = error, error.code == AuthErrorCode.secondFactorRequired.rawValue else {
80-
XCTFail("User sign in returns wrong error. Error: \(error!.localizedDescription)")
81-
}
82-
let resolver = error.userInfo["FIRAuthErrorUserInfoMultiFactorResolverKey"] as! MultiFactorResolver
83-
let hint = resolver.hints.first as! PhoneMultiFactorInfo
84-
PhoneAuthProvider.provider().verifyPhoneNumber(
85-
with: hint,
86-
uiDelegate: nil,
87-
multiFactorSession: resolver.session
88-
) { verificationId, error in
89-
XCTAssertNil(error, "Failed to verify phone number. Error: \(error!.localizedDescription)")
90-
let credential = PhoneAuthProvider.provider().credential(
91-
withVerificationID: verificationId!,
92-
verificationCode: kPhoneSecondFactorVerificationCode
93-
)
94-
let assertion = PhoneMultiFactorGenerator.assertion(with: credential)
95-
resolver.resolveSignIn(with: assertion) { authResult, error in
96-
XCTAssertNil(error, "Failed to sign in with phone multi factor. Error: \(error!.localizedDescription)")
97-
signInExpectation.fulfill()
87+
Auth.auth()
88+
.signIn(withEmail: kOneSecondFactorUserEmail,
89+
password: kOneSecondFactorUserPassword) { result, error in
90+
// SignIn
91+
guard let error = error, error.code == AuthErrorCode.secondFactorRequired.rawValue else {
92+
XCTFail("User sign in returns wrong error. Error: \(error!.localizedDescription)")
93+
}
94+
let resolver = error
95+
.userInfo["FIRAuthErrorUserInfoMultiFactorResolverKey"] as! MultiFactorResolver
96+
let hint = resolver.hints.first as! PhoneMultiFactorInfo
97+
PhoneAuthProvider.provider().verifyPhoneNumber(
98+
with: hint,
99+
uiDelegate: nil,
100+
multiFactorSession: resolver.session
101+
) { verificationId, error in
102+
XCTAssertNil(error,
103+
"Failed to verify phone number. Error: \(error!.localizedDescription)")
104+
let credential = PhoneAuthProvider.provider().credential(
105+
withVerificationID: verificationId!,
106+
verificationCode: kPhoneSecondFactorVerificationCode
107+
)
108+
let assertion = PhoneMultiFactorGenerator.assertion(with: credential)
109+
resolver.resolveSignIn(with: assertion) { authResult, error in
110+
XCTAssertNil(error,
111+
"Failed to sign in with phone multi factor. Error: \(error!.localizedDescription)")
112+
signInExpectation.fulfill()
113+
}
98114
}
99115
}
100-
}
101116

102117
waitForExpectations(timeout: 300) { error in
103-
XCTAssertNil(error, "Failed to wait for enroll and unenroll phone multi factor finished. Error: \(error!.localizedDescription)")
118+
XCTAssertNil(error,
119+
"Failed to wait for enroll and unenroll phone multi factor finished. Error: \(error!.localizedDescription)")
104120
}
105121
}
106122
}

Example/Messaging/Sample/iOS/AppDelegate.swift

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
3333

3434
static var hasPresentedInvalidServiceInfoPlistAlert = false
3535

36-
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
36+
func application(_ application: UIApplication,
37+
didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?)
38+
-> Bool {
3739
guard !AppDelegate.isWithinUnitTest else {
3840
// During unit tests, we don't want to initialize Firebase, since by default we want to able
3941
// to run unit tests without requiring a non-dummy GoogleService-Info.plist file
@@ -85,7 +87,10 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
8587
NotificationCenter.default.post(name: UserNotificationsChangedNotification, object: nil)
8688
}
8789

88-
func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable: Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
90+
func application(_ application: UIApplication,
91+
didReceiveRemoteNotification userInfo: [AnyHashable: Any],
92+
fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult)
93+
-> Void) {
8994
print("application:didReceiveRemoteNotification:fetchCompletionHandler: called, with notification:")
9095
print("\(userInfo.jsonString ?? "{}")")
9196
completionHandler(.newData)
@@ -131,7 +136,9 @@ extension AppDelegate: MessagingDelegate {
131136

132137
extension AppDelegate {
133138
func listenForDirectChannelStateChanges() {
134-
NotificationCenter.default.addObserver(self, selector: #selector(onMessagingDirectChannelStateChanged(_:)), name: .MessagingConnectionStateChanged, object: nil)
139+
NotificationCenter.default
140+
.addObserver(self, selector: #selector(onMessagingDirectChannelStateChanged(_:)),
141+
name: .MessagingConnectionStateChanged, object: nil)
135142
}
136143

137144
func onMessagingDirectChannelStateChanged(_ notification: Notification) {

Example/Messaging/Sample/iOS/MessagingViewController.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,8 @@ class MessagingViewController: UIViewController {
153153
}()
154154

155155
lazy var apnsStatusTableCell: UITableViewCell = {
156-
let cell = UITableViewCell(style: UITableViewCellStyle.value1, reuseIdentifier: Row.apnsStatus.rawValue)
156+
let cell = UITableViewCell(style: UITableViewCellStyle.value1,
157+
reuseIdentifier: Row.apnsStatus.rawValue)
157158
cell.textLabel?.text = "Allowed:"
158159
cell.detailTextLabel?.numberOfLines = 0
159160
cell.detailTextLabel?.lineBreakMode = .byWordWrapping

Example/Messaging/Sample/iOS/NotificationsController.swift

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ class NotificationsController: NSObject {
5252
UNUserNotificationCenter.current()
5353
.requestAuthorization(options: [.alert, .badge, .sound],
5454
completionHandler: { granted, error in
55-
NotificationCenter.default.post(name: UserNotificationsChangedNotification, object: nil)
55+
NotificationCenter.default
56+
.post(name: UserNotificationsChangedNotification, object: nil)
5657
})
5758
} else if #available(iOS 8.0, *) {
5859
let userNotificationSettings = UIUserNotificationSettings(types: [.alert, .badge, .sound],
@@ -131,7 +132,9 @@ extension NotificationsController: UNUserNotificationCenterDelegate {
131132
completionHandler([.alert, .badge, .sound])
132133
}
133134

134-
func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {
135+
func userNotificationCenter(_ center: UNUserNotificationCenter,
136+
didReceive response: UNNotificationResponse,
137+
withCompletionHandler completionHandler: @escaping () -> Void) {
135138
print("Received notification response")
136139
let jsonString = response.notification.request.content.userInfo.jsonString ?? "{}"
137140
print("\(jsonString)")

Example/tvOSSample/tvOSSample/AppDelegate.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ import FirebaseCore
1919
class AppDelegate: UIResponder, UIApplicationDelegate {
2020
var window: UIWindow?
2121

22-
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
22+
func application(_ application: UIApplication,
23+
didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?)
24+
-> Bool {
2325
// Override point for customization after application launch.
2426
FirebaseApp.configure()
2527
return true

Example/tvOSSample/tvOSSample/StorageViewController.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ class StorageViewController: UIViewController {
3131
case failed(String)
3232

3333
/// Equatable support for UIState.
34-
static func == (lhs: StorageViewController.UIState, rhs: StorageViewController.UIState) -> Bool {
34+
static func == (lhs: StorageViewController.UIState,
35+
rhs: StorageViewController.UIState) -> Bool {
3536
switch (lhs, rhs) {
3637
case (.cleared, .cleared): return true
3738
case (.downloading, .downloading): return true

Example/watchOSSample/SampleWatchAppWatchKitExtension/ComplicationController.swift

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,42 +17,59 @@ import ClockKit
1717
class ComplicationController: NSObject, CLKComplicationDataSource {
1818
// MARK: - Timeline Configuration
1919

20-
func getSupportedTimeTravelDirections(for complication: CLKComplication, withHandler handler: @escaping (CLKComplicationTimeTravelDirections) -> Void) {
20+
func getSupportedTimeTravelDirections(for complication: CLKComplication,
21+
withHandler handler: @escaping (CLKComplicationTimeTravelDirections)
22+
-> Void) {
2123
handler([.forward, .backward])
2224
}
2325

24-
func getTimelineStartDate(for complication: CLKComplication, withHandler handler: @escaping (Date?) -> Void) {
26+
func getTimelineStartDate(for complication: CLKComplication,
27+
withHandler handler: @escaping (Date?) -> Void) {
2528
handler(nil)
2629
}
2730

28-
func getTimelineEndDate(for complication: CLKComplication, withHandler handler: @escaping (Date?) -> Void) {
31+
func getTimelineEndDate(for complication: CLKComplication,
32+
withHandler handler: @escaping (Date?) -> Void) {
2933
handler(nil)
3034
}
3135

32-
func getPrivacyBehavior(for complication: CLKComplication, withHandler handler: @escaping (CLKComplicationPrivacyBehavior) -> Void) {
36+
func getPrivacyBehavior(for complication: CLKComplication,
37+
withHandler handler: @escaping (CLKComplicationPrivacyBehavior) -> Void) {
3338
handler(.showOnLockScreen)
3439
}
3540

3641
// MARK: - Timeline Population
3742

38-
func getCurrentTimelineEntry(for complication: CLKComplication, withHandler handler: @escaping (CLKComplicationTimelineEntry?) -> Void) {
43+
func getCurrentTimelineEntry(for complication: CLKComplication,
44+
withHandler handler: @escaping (CLKComplicationTimelineEntry?)
45+
-> Void) {
3946
// Call the handler with the current timeline entry
4047
handler(nil)
4148
}
4249

43-
func getTimelineEntries(for complication: CLKComplication, before date: Date, limit: Int, withHandler handler: @escaping ([CLKComplicationTimelineEntry]?) -> Void) {
50+
func getTimelineEntries(for complication: CLKComplication,
51+
before date: Date,
52+
limit: Int,
53+
withHandler handler: @escaping ([CLKComplicationTimelineEntry]?)
54+
-> Void) {
4455
// Call the handler with the timeline entries prior to the given date
4556
handler(nil)
4657
}
4758

48-
func getTimelineEntries(for complication: CLKComplication, after date: Date, limit: Int, withHandler handler: @escaping ([CLKComplicationTimelineEntry]?) -> Void) {
59+
func getTimelineEntries(for complication: CLKComplication,
60+
after date: Date,
61+
limit: Int,
62+
withHandler handler: @escaping ([CLKComplicationTimelineEntry]?)
63+
-> Void) {
4964
// Call the handler with the timeline entries after to the given date
5065
handler(nil)
5166
}
5267

5368
// MARK: - Placeholder Templates
5469

55-
func getLocalizableSampleTemplate(for complication: CLKComplication, withHandler handler: @escaping (CLKComplicationTemplate?) -> Void) {
70+
func getLocalizableSampleTemplate(for complication: CLKComplication,
71+
withHandler handler: @escaping (CLKComplicationTemplate?)
72+
-> Void) {
5673
// This method will be called once per supported complication, and the results will be cached
5774
handler(nil)
5875
}

0 commit comments

Comments
 (0)