Skip to content

Commit 9a7754c

Browse files
authored
Enable lint for Auth (#5097)
1 parent 8b8135b commit 9a7754c

File tree

224 files changed

+8692
-7670
lines changed

Some content is hidden

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

224 files changed

+8692
-7670
lines changed

Example/Auth/ApiTests/AccountInfoTests.m

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,20 +43,20 @@ - (void)testUpdatingUsersEmail {
4343
[auth createUserWithEmail:kOldUserEmail
4444
password:@"password"
4545
completion:^(FIRAuthDataResult *user, NSError *error) {
46-
if (error.code != FIRAuthErrorCodeEmailAlreadyInUse) {
47-
apiError = error;
48-
}
49-
[expectation fulfill];
50-
}];
46+
if (error.code != FIRAuthErrorCodeEmailAlreadyInUse) {
47+
apiError = error;
48+
}
49+
[expectation fulfill];
50+
}];
5151
[self waitForExpectationsWithTimeout:kExpectationsTimeout handler:nil];
5252

5353
expectation = [self expectationWithDescription:@"Sign in with email and password."];
5454
[auth signInWithEmail:kOldUserEmail
5555
password:@"password"
56-
completion:^(FIRAuthDataResult * _Nullable authResult, NSError * _Nullable error) {
57-
apiError = error;
58-
[expectation fulfill];
59-
}];
56+
completion:^(FIRAuthDataResult *_Nullable authResult, NSError *_Nullable error) {
57+
apiError = error;
58+
[expectation fulfill];
59+
}];
6060
[self waitForExpectationsWithTimeout:kExpectationsTimeout handler:nil];
6161

6262
XCTAssertEqualObjects(auth.currentUser.email, kOldUserEmail);

Example/Auth/ApiTests/FIRAuthApiTestsBase.m

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,7 @@ - (void)signInAnonymously {
3434
XCTFail(@"Could not obtain auth object.");
3535
}
3636

37-
XCTestExpectation *expectation =
38-
[self expectationWithDescription:@"Anonymous sign-in finished."];
37+
XCTestExpectation *expectation = [self expectationWithDescription:@"Anonymous sign-in finished."];
3938
[auth signInAnonymouslyWithCompletion:^(FIRAuthDataResult *result, NSError *error) {
4039
if (error) {
4140
NSLog(@"Anonymous sign in error: %@", error);

Example/Auth/ApiTests/PhoneMultiFactorTests.swift

Lines changed: 41 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -27,53 +27,54 @@ let kOneSecondFactorUserEmail = "[email protected]"
2727
let kOneSecondFactorUserPassword = "aaaaaa"
2828

2929
class PhoneMultiFactorTests: FIRAuthApiTestsBase {
30-
3130
func testEnrollUnenroll() {
32-
let enrollExpectation = self.expectation(description: "Enroll phone multi factor finished.")
33-
let unenrollExpectation = self.expectation(description: "Unenroll phone multi factor finished.")
34-
Auth.auth().signIn(withEmail: kNoSecondFactorUserEmail, password: kNoSecondFactorUserPassword) { (result, error) in
31+
let enrollExpectation = expectation(description: "Enroll phone multi factor finished.")
32+
let unenrollExpectation = expectation(description: "Unenroll phone multi factor finished.")
33+
Auth.auth().signIn(withEmail: kNoSecondFactorUserEmail, password: kNoSecondFactorUserPassword) { result, error in
3534
XCTAssertNil(error, "User normal sign in failed. Error: \(error!.localizedDescription)")
3635

3736
// Enroll
3837
guard let user = result?.user else {
3938
XCTFail("No valid user after attempted sign-in.")
4039
}
41-
user.multiFactor.getSessionWithCompletion({ (session, error) in
40+
user.multiFactor.getSessionWithCompletion { session, error in
4241
XCTAssertNil(error, "Get multi factor session failed. Error: \(error!.localizedDescription)")
4342
PhoneAuthProvider.provider().verifyPhoneNumber(
4443
kPhoneSecondFactorPhoneNumber,
4544
uiDelegate: nil,
46-
multiFactorSession: session) { (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-
let assertion = PhoneMultiFactorGenerator.assertion(with: credential);
52-
user?.multiFactor.enroll(with: assertion, displayName: kPhoneSecondFactorDisplayName) { (error) in
53-
XCTAssertNil(error, "Phone multi factor enroll failed. Error: \(error!.localizedDescription)")
54-
XCTAssertEqual(Auth.auth().currentUser?.multiFactor.enrolledFactors.first?.displayName, kPhoneSecondFactorDisplayName)
55-
enrollExpectation.fulfill()
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()
5657

57-
// Unenroll
58-
user = Auth.auth().currentUser
59-
user?.multiFactor.unenroll(with: (user?.multiFactor.enrolledFactors.first)!, completion: { (error) in
60-
XCTAssertNil(error, "Phone multi factor unenroll failed. Error: \(error!.localizedDescription)")
61-
XCTAssertEqual(Auth.auth().currentUser?.multiFactor.enrolledFactors.count, 0)
62-
unenrollExpectation.fulfill()
63-
})
64-
}
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()
64+
})
65+
}
6566
}
66-
})
67+
}
6768
}
6869

69-
self.waitForExpectations(timeout: 30) { error in
70+
waitForExpectations(timeout: 30) { error in
7071
XCTAssertNil(error, "Failed to wait for enroll and unenroll phone multi factor finished. Error: \(error!.localizedDescription)")
7172
}
7273
}
7374

7475
func testSignInWithSecondFactor() {
75-
let signInExpectation = self.expectation(description: "Sign in with phone multi factor finished.")
76-
Auth.auth().signIn(withEmail: kOneSecondFactorUserEmail, password: kOneSecondFactorUserPassword) { (result, error) in
76+
let signInExpectation = expectation(description: "Sign in with phone multi factor finished.")
77+
Auth.auth().signIn(withEmail: kOneSecondFactorUserEmail, password: kOneSecondFactorUserPassword) { result, error in
7778
// SignIn
7879
guard let error = error, error.code == AuthErrorCode.secondFactorRequired.rawValue else {
7980
XCTFail("User sign in returns wrong error. Error: \(error!.localizedDescription)")
@@ -83,20 +84,22 @@ class PhoneMultiFactorTests: FIRAuthApiTestsBase {
8384
PhoneAuthProvider.provider().verifyPhoneNumber(
8485
with: hint,
8586
uiDelegate: nil,
86-
multiFactorSession: resolver.session) { (verificationId, error) in
87-
XCTAssertNil(error, "Failed to verify phone number. Error: \(error!.localizedDescription)")
88-
let credential = PhoneAuthProvider.provider().credential(
89-
withVerificationID: verificationId!,
90-
verificationCode: kPhoneSecondFactorVerificationCode)
91-
let assertion = PhoneMultiFactorGenerator.assertion(with: credential);
92-
resolver.resolveSignIn(with: assertion) { (authResult, error) in
93-
XCTAssertNil(error, "Failed to sign in with phone multi factor. Error: \(error!.localizedDescription)")
94-
signInExpectation.fulfill()
95-
}
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()
98+
}
9699
}
97100
}
98101

99-
self.waitForExpectations(timeout: 300) { error in
102+
waitForExpectations(timeout: 300) { error in
100103
XCTAssertNil(error, "Failed to wait for enroll and unenroll phone multi factor finished. Error: \(error!.localizedDescription)")
101104
}
102105
}

Example/Auth/App/iOS/FIRAppDelegate.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@
1818

1919
@interface FIRAppDelegate : UIResponder <UIApplicationDelegate>
2020

21-
@property (strong, nonatomic) UIWindow *window;
21+
@property(strong, nonatomic) UIWindow *window;
2222

2323
@end

Example/Auth/App/iOS/FIRAppDelegate.m

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -16,37 +16,40 @@
1616

1717
@implementation FIRAppDelegate
1818

19-
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
20-
{
21-
// Override point for customization after application launch.
22-
return YES;
19+
- (BOOL)application:(UIApplication *)application
20+
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
21+
// Override point for customization after application launch.
22+
return YES;
2323
}
2424

25-
- (void)applicationWillResignActive:(UIApplication *)application
26-
{
27-
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
28-
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
25+
- (void)applicationWillResignActive:(UIApplication *)application {
26+
// Sent when the application is about to move from active to inactive state. This can occur for
27+
// certain types of temporary interruptions (such as an incoming phone call or SMS message) or
28+
// when the user quits the application and it begins the transition to the background state. Use
29+
// this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates.
30+
// Games should use this method to pause the game.
2931
}
3032

31-
- (void)applicationDidEnterBackground:(UIApplication *)application
32-
{
33-
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
34-
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
33+
- (void)applicationDidEnterBackground:(UIApplication *)application {
34+
// Use this method to release shared resources, save user data, invalidate timers, and store
35+
// enough application state information to restore your application to its current state in case
36+
// it is terminated later. If your application supports background execution, this method is
37+
// called instead of applicationWillTerminate: when the user quits.
3538
}
3639

37-
- (void)applicationWillEnterForeground:(UIApplication *)application
38-
{
39-
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
40+
- (void)applicationWillEnterForeground:(UIApplication *)application {
41+
// Called as part of the transition from the background to the inactive state; here you can undo
42+
// many of the changes made on entering the background.
4043
}
4144

42-
- (void)applicationDidBecomeActive:(UIApplication *)application
43-
{
44-
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
45+
- (void)applicationDidBecomeActive:(UIApplication *)application {
46+
// Restart any tasks that were paused (or not yet started) while the application was inactive. If
47+
// the application was previously in the background, optionally refresh the user interface.
4548
}
4649

47-
- (void)applicationWillTerminate:(UIApplication *)application
48-
{
49-
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
50+
- (void)applicationWillTerminate:(UIApplication *)application {
51+
// Called when the application is about to terminate. Save data if appropriate. See also
52+
// applicationDidEnterBackground:.
5053
}
5154

5255
@end

Example/Auth/App/iOS/FIRViewController.m

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,14 @@ @interface FIRViewController ()
2020

2121
@implementation FIRViewController
2222

23-
- (void)viewDidLoad
24-
{
25-
[super viewDidLoad];
26-
// Do any additional setup after loading the view, typically from a nib.
23+
- (void)viewDidLoad {
24+
[super viewDidLoad];
25+
// Do any additional setup after loading the view, typically from a nib.
2726
}
2827

29-
- (void)didReceiveMemoryWarning
30-
{
31-
[super didReceiveMemoryWarning];
32-
// Dispose of any resources that can be recreated.
28+
- (void)didReceiveMemoryWarning {
29+
[super didReceiveMemoryWarning];
30+
// Dispose of any resources that can be recreated.
3331
}
3432

3533
@end

Example/Auth/App/iOS/main.m

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,8 @@
1515
@import UIKit;
1616
#import "FIRAppDelegate.h"
1717

18-
int main(int argc, char * argv[])
19-
{
20-
@autoreleasepool {
21-
return UIApplicationMain(argc, argv, nil, NSStringFromClass([FIRAppDelegate class]));
22-
}
18+
int main(int argc, char* argv[]) {
19+
@autoreleasepool {
20+
return UIApplicationMain(argc, argv, nil, NSStringFromClass([FIRAppDelegate class]));
21+
}
2322
}

Example/Auth/App/macOS/FIRAppDelegate.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,4 @@
1818

1919
@interface FIRAppDelegate : NSObject <NSApplicationDelegate>
2020

21-
2221
@end
23-

Example/Auth/App/macOS/FIRAppDelegate.m

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,11 @@ @interface FIRAppDelegate ()
2323
@implementation FIRAppDelegate
2424

2525
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
26-
// Insert code here to initialize your application
26+
// Insert code here to initialize your application
2727
}
2828

29-
3029
- (void)applicationWillTerminate:(NSNotification *)aNotification {
31-
// Insert code here to tear down your application
30+
// Insert code here to tear down your application
3231
}
3332

34-
3533
@end

Example/Auth/App/macOS/FIRViewController.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,4 @@
1818

1919
@interface FIRViewController : NSViewController
2020

21-
2221
@end
23-

0 commit comments

Comments
 (0)