Skip to content

Commit 290f00b

Browse files
authored
Auto-style swift sources (firebase#847)
* Fix bash style issues * Exclude additional build output directories * Format swift files with scripts/style.sh * Reformat swift sources * Allow swiftformat 0.32.0 on travis
1 parent c85372b commit 290f00b

File tree

9 files changed

+309
-276
lines changed

9 files changed

+309
-276
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ before_install:
1313
- bundle exec pod install --project-directory=Example --repo-update
1414
- bundle exec pod install --project-directory=Firestore/Example --no-repo-update
1515
- brew install clang-format
16+
- brew install swiftformat
1617
- brew install cmake
1718
- brew install go # Somehow the build for Abseil requires this.
1819
- echo "$TRAVIS_COMMIT_RANGE"

Example/tvOSSample/tvOSSample/AppDelegate.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import FirebaseCore
1717

1818
@UIApplicationMain
1919
class AppDelegate: UIResponder, UIApplicationDelegate {
20-
2120
var window: UIWindow?
2221

2322
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
@@ -26,4 +25,3 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
2625
return true
2726
}
2827
}
29-

Example/tvOSSample/tvOSSample/AuthLoginViewController.swift

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -16,25 +16,14 @@ import UIKit
1616
import FirebaseAuth
1717

1818
class AuthLoginViewController: UIViewController {
19+
override func viewDidLoad() {
20+
super.viewDidLoad()
1921

20-
override func viewDidLoad() {
21-
super.viewDidLoad()
22+
// Do any additional setup after loading the view.
23+
}
2224

23-
// Do any additional setup after loading the view.
24-
}
25-
26-
override func didReceiveMemoryWarning() {
27-
super.didReceiveMemoryWarning()
28-
// Dispose of any resources that can be recreated.
29-
}
30-
31-
/*
32-
// MARK: - Navigation
33-
34-
// In a storyboard-based application, you will often want to do a little preparation before navigation
35-
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
36-
// Get the new view controller using segue.destinationViewController.
37-
// Pass the selected object to the new view controller.
38-
}
39-
*/
25+
override func didReceiveMemoryWarning() {
26+
super.didReceiveMemoryWarning()
27+
// Dispose of any resources that can be recreated.
28+
}
4029
}

Example/tvOSSample/tvOSSample/AuthViewController.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@ class AuthViewController: UIViewController {
2020
// MARK: - User Interface
2121

2222
/// A stackview containing all of the buttons to providers (Email, OAuth, etc).
23-
@IBOutlet weak var providers: UIStackView!
23+
@IBOutlet var providers: UIStackView!
2424

2525
/// A stackview containing a signed in label and sign out button.
26-
@IBOutlet weak var signedIn: UIStackView!
26+
@IBOutlet var signedIn: UIStackView!
2727

2828
/// A label to display the status for the signed in user.
29-
@IBOutlet weak var signInStatus: UILabel!
29+
@IBOutlet var signInStatus: UILabel!
3030

3131
// MARK: - User Actions
3232

Example/tvOSSample/tvOSSample/DatabaseViewController.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class DatabaseViewController: UIViewController {
3030
// MARK: - Interface
3131

3232
/// Label to display the current value.
33-
@IBOutlet weak var currentValue: UILabel!
33+
@IBOutlet var currentValue: UILabel!
3434

3535
// MARK: - User Actions
3636

@@ -65,7 +65,7 @@ class DatabaseViewController: UIViewController {
6565
// Observe the current value, and update the UI every time it changes.
6666
let ref = Database.database().reference(withPath: Constants.databasePath)
6767

68-
ref.observe(.value) { [weak self] (snapshot) in
68+
ref.observe(.value) { [weak self] snapshot in
6969
guard let value = snapshot.value as? Int else {
7070
print("Error grabbing value from Snapshot!")
7171
return

Example/tvOSSample/tvOSSample/EmailLoginViewController.swift

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ protocol EmailLoginDelegate {
1919
func emailLogin(_ controller: EmailLoginViewController, signedInAs user: User)
2020
func emailLogin(_ controller: EmailLoginViewController, failedWithError error: Error)
2121
}
22+
2223
class EmailLoginViewController: UIViewController {
2324

2425
// MARK: - Public Properties
@@ -27,15 +28,15 @@ class EmailLoginViewController: UIViewController {
2728

2829
// MARK: - User Interface
2930

30-
@IBOutlet private weak var emailAddress: UITextField!
31-
@IBOutlet private weak var password: UITextField!
31+
@IBOutlet private var emailAddress: UITextField!
32+
@IBOutlet private var password: UITextField!
3233

3334
// MARK: - User Actions
3435

3536
@IBAction func logInButtonHit(_ sender: UIButton) {
3637
guard let (email, password) = validatedInputs() else { return }
3738

38-
Auth.auth().signIn(withEmail: email, password: password) { [unowned self] (user, error) in
39+
Auth.auth().signIn(withEmail: email, password: password) { [unowned self] user, error in
3940
guard let user = user else {
4041
print("Error signing in: \(error!)")
4142
self.delegate?.emailLogin(self, failedWithError: error!)
@@ -50,7 +51,7 @@ class EmailLoginViewController: UIViewController {
5051
@IBAction func signUpButtonHit(_ sender: UIButton) {
5152
guard let (email, password) = validatedInputs() else { return }
5253

53-
Auth.auth().createUser(withEmail: email, password: password) { [unowned self] (user, error) in
54+
Auth.auth().createUser(withEmail: email, password: password) { [unowned self] user, error in
5455
guard let user = user else {
5556
print("Error signing up: \(error!)")
5657
self.delegate?.emailLogin(self, failedWithError: error!)

Example/tvOSSample/tvOSSample/StorageViewController.swift

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ 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, rhs: StorageViewController.UIState) -> Bool {
3535
switch (lhs, rhs) {
3636
case (.cleared, .cleared): return true
3737
case (.downloading, .downloading): return true
@@ -52,16 +52,16 @@ class StorageViewController: UIViewController {
5252
// MARK: Interface
5353

5454
/// Image view to display the downloaded image.
55-
@IBOutlet weak var imageView: UIImageView!
55+
@IBOutlet var imageView: UIImageView!
5656

5757
/// The download button.
58-
@IBOutlet weak var downloadButton: UIButton!
58+
@IBOutlet var downloadButton: UIButton!
5959

6060
/// The clear button.
61-
@IBOutlet weak var clearButton: UIButton!
61+
@IBOutlet var clearButton: UIButton!
6262

6363
/// A visual representation of the state.
64-
@IBOutlet weak var stateLabel: UILabel!
64+
@IBOutlet var stateLabel: UILabel!
6565

6666
// MARK: - User Actions
6767

@@ -72,7 +72,7 @@ class StorageViewController: UIViewController {
7272
let storage = Storage.storage()
7373
let ref = storage.reference(withPath: Constants.downloadPath)
7474
// TODO: Show progress bar here using proper API.
75-
let task = ref.getData(maxSize: Constants.maxSize) { [unowned self] (data, error) in
75+
let task = ref.getData(maxSize: Constants.maxSize) { [unowned self] data, error in
7676
guard let data = data else {
7777
self.state = .failed("Error downloading: \(error!.localizedDescription)")
7878
return
@@ -114,7 +114,7 @@ class StorageViewController: UIViewController {
114114
stateLabel.text = "State: Downloading..."
115115

116116
// Download complete, ensure the download button is still off and enable the clear button.
117-
case (_, .downloaded(let image)):
117+
case let (_, .downloaded(image)):
118118
imageView.image = image
119119
stateLabel.text = "State: Image downloaded!"
120120

@@ -124,7 +124,7 @@ class StorageViewController: UIViewController {
124124
stateLabel.text = "State: Pending download"
125125

126126
// An error occurred.
127-
case (_, .failed(let error)):
127+
case let (_, .failed(error)):
128128
stateLabel.text = "State: \(error)"
129129

130130
// For now, as the default, throw a fatal error because it's an unexpected state. This will

0 commit comments

Comments
 (0)