Skip to content

Commit e8a12e0

Browse files
Improve/use shorthand syntax for unwrapping optionals and fix typos (#12369)
1 parent 477bb2a commit e8a12e0

File tree

86 files changed

+266
-266
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

86 files changed

+266
-266
lines changed

Example/tvOSSample/tvOSSample/AuthViewController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class AuthViewController: UIViewController {
5555
// MARK: - Internal Helpers
5656

5757
private func setUserSignedIn(_ user: User?) {
58-
if let user = user {
58+
if let user {
5959
providers.isHidden = true
6060
signedIn.isHidden = false
6161

Example/watchOSSample/ServiceExtension/NotificationService.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class NotificationService: UNNotificationServiceExtension {
2525
self.contentHandler = contentHandler
2626
bestAttemptContent = (request.content.mutableCopy() as? UNMutableNotificationContent)
2727

28-
if let bestAttemptContent = bestAttemptContent {
28+
if let bestAttemptContent {
2929
// Modify the notification content here...
3030
bestAttemptContent.title = "\(bestAttemptContent.title) 👩‍💻"
3131

@@ -39,7 +39,7 @@ class NotificationService: UNNotificationServiceExtension {
3939
// Called just before the extension will be terminated by the system.
4040
// Use this as an opportunity to deliver your "best attempt" at modified content, otherwise the
4141
// original push payload will be used.
42-
if let contentHandler = contentHandler, let bestAttemptContent = bestAttemptContent {
42+
if let contentHandler, let bestAttemptContent {
4343
contentHandler(bestAttemptContent)
4444
}
4545
}

FirebaseAnalyticsSwift/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,11 @@ extension View {
9090
func analyticsScreen(name: String, class screenClass: String? = nil, extraParameters: [String: Any]? = nil) -> some View {
9191
onAppear {
9292
var params: [String: Any] = [AnalyticsParameterScreenName: name]
93-
if let screenClass = screenClass {
93+
if let screenClass {
9494
params[AnalyticsParameterScreenClass] = screenClass
9595
}
96-
if let extraParams = extraParameters {
97-
params.merge(extraParams) { _, new in new }
96+
if let extraParameters {
97+
params.merge(extraParameters) { _, new in new }
9898
}
9999
Analytics.logEvent(AnalyticsEventScreenView, parameters: params)
100100
}

FirebaseAppCheck/Apps/FIRAppCheckTestApp/FIRAppCheckTestApp/AppDelegate.swift

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,11 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
7272
}
7373

7474
DeviceCheckProvider(app: firebaseApp)?.getToken { token, error in
75-
if let token = token {
75+
if let token {
7676
print("DeviceCheck token: \(token.token), expiration date: \(token.expirationDate)")
7777
}
7878

79-
if let error = error {
79+
if let error {
8080
print("DeviceCheck error: \((error as NSError).userInfo)")
8181
}
8282
}
@@ -91,11 +91,11 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
9191
print("Debug token: \(debugProvider.currentDebugToken())")
9292

9393
debugProvider.getToken { token, error in
94-
if let token = token {
94+
if let token {
9595
print("Debug FAC token: \(token.token), expiration date: \(token.expirationDate)")
9696
}
9797

98-
if let error = error {
98+
if let error {
9999
print("Debug error: \(error)")
100100
}
101101
}
@@ -106,11 +106,11 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
106106

107107
func requestLimitedUseToken() {
108108
AppCheck.appCheck().limitedUseToken { result, error in
109-
if let result = result {
109+
if let result {
110110
print("FAC limited-use token: \(result.token), expiration date: \(result.expirationDate)")
111111
}
112112

113-
if let error = error {
113+
if let error {
114114
print("Error: \(String(describing: error))")
115115
}
116116
}
@@ -128,11 +128,11 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
128128
}
129129

130130
appAttestProvider.getToken { token, error in
131-
if let token = token {
131+
if let token {
132132
print("App Attest FAC token: \(token.token), expiration date: \(token.expirationDate)")
133133
}
134134

135-
if let error = error {
135+
if let error {
136136
print("App Attest error: \(error)")
137137
}
138138
}

FirebaseAppCheck/Tests/Unit/Swift/AppCheckAPITests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ final class AppCheckAPITests {
119119
// MARK: - AppCheckErrors
120120

121121
AppCheck.appCheck().token(forcingRefresh: false) { _, error in
122-
if let error = error {
122+
if let error {
123123
switch error {
124124
case AppCheckErrorCode.unknown:
125125
break

FirebaseAuth/Tests/Sample/SwiftApiTests/AccountInfoTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class AccountInfoTests: TestsBase {
4343
let auth = Auth.auth()
4444
let expectation1 = expectation(description: "Created account with email and password.")
4545
auth.createUser(withEmail: kOldUserEmail, password: "password") { user, error in
46-
if let error = error {
46+
if let error {
4747
XCTAssertEqual((error as NSError).code,
4848
AuthErrorCode.emailAlreadyInUse.rawValue,
4949
"Created a user despite it already exiting.")

FirebaseAuth/Tests/Sample/SwiftApiTests/EmailPasswordTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class EmailPasswordTests: TestsBase {
2929
let auth = Auth.auth()
3030
let expectation = self.expectation(description: "Created account with email and password.")
3131
auth.createUser(withEmail: kNewEmailToCreateUser, password: "password") { result, error in
32-
if let error = error {
32+
if let error {
3333
print("createUserWithEmail has error: \(error)")
3434
}
3535
expectation.fulfill()

FirebaseAuth/Tests/Sample/SwiftApiTests/FacebookTests.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import XCTest
3030
// let credential = FacebookAuthProvider.credential(withAccessToken: facebookAccessToken)
3131
// let expectation = self.expectation(description: "Signing in with Facebook finished.")
3232
// auth.signIn(with: credential) { result, error in
33-
// if let error = error {
33+
// if let error {
3434
// XCTFail("Signing in with Facebook had error: \(error)")
3535
// } else {
3636
// XCTAssertEqual(auth.currentUser?.displayName, Credentials.kFacebookUserName)
@@ -69,7 +69,7 @@ import XCTest
6969
// let credential = FacebookAuthProvider.credential(withAccessToken: facebookAccessToken)
7070
// let expectation = self.expectation(description: "Facebook linking finished.")
7171
// auth.currentUser?.link(with: credential, completion: { result, error in
72-
// if let error = error {
72+
// if let error {
7373
// XCTFail("Link to Firebase error: \(error)")
7474
// } else {
7575
// guard let providers = (auth.currentUser?.providerData) else {
@@ -124,7 +124,7 @@ import XCTest
124124
// fetcher.setRequestValue("text/plain", forHTTPHeaderField: "Content-Type")
125125
// let expectation = self.expectation(description: "Creating Facebook account finished.")
126126
// fetcher.beginFetch { data, error in
127-
// if let error = error {
127+
// if let error {
128128
// let error = error as NSError
129129
// if let message = String(data: error.userInfo["data"] as! Data, encoding: .utf8) {
130130
// // May get transient errors here for too many api calls when tests run frequently.
@@ -181,7 +181,7 @@ import XCTest
181181
// fetcher.setRequestValue("text/plain", forHTTPHeaderField: "Content-Type")
182182
// let expectation = self.expectation(description: "Deleting Facebook account finished.")
183183
// fetcher.beginFetch { data, error in
184-
// if let error = error {
184+
// if let error {
185185
// XCTFail("Deleting Facebook account failed with error: \(error)")
186186
// }
187187
// expectation.fulfill()

FirebaseAuth/Tests/Sample/SwiftApiTests/GoogleTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class GoogleTests: TestsBase {
2929
accessToken: googleAccessToken)
3030
let expectation = self.expectation(description: "Signing in with Google finished.")
3131
auth.signIn(with: credential) { result, error in
32-
if let error = error {
32+
if let error {
3333
print("Signing in with Google had error: \(error)")
3434
}
3535
expectation.fulfill()
@@ -65,7 +65,7 @@ class GoogleTests: TestsBase {
6565
fetcher.setRequestValue("application/x-www-form-urlencoded", forHTTPHeaderField: "Content-Type")
6666
let expectation = self.expectation(description: "Exchanging Google account tokens finished.")
6767
fetcher.beginFetch { data, error in
68-
if let error = error {
68+
if let error {
6969
XCTFail("Exchanging Google account tokens finished with error: \(error)")
7070
} else {
7171
do {

FirebaseAuth/Tests/Sample/SwiftApiTests/TestsBase.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class TestsBase: XCTestCase {
3838

3939
let expectation = self.expectation(description: "Anonymous sign-in finished.")
4040
auth.signInAnonymously { result, error in
41-
if let error = error {
41+
if let error {
4242
print("Anonymous sign in error: \(error)")
4343
}
4444
expectation.fulfill()
@@ -59,7 +59,7 @@ class TestsBase: XCTestCase {
5959
let auth = Auth.auth()
6060
let expectation = self.expectation(description: "Delete current user finished.")
6161
auth.currentUser?.delete { error in
62-
if let error = error {
62+
if let error {
6363
print("Anonymous sign in error: \(error)")
6464
}
6565
expectation.fulfill()

0 commit comments

Comments
 (0)