瀏覽代碼

Lint fixes (#1546)

* update SwiftLint

* lint: remove unused references to self

* lint: avoid weird disable_superflouous_command rule

* fix comment lint issue

* lint: lazy initialize search and mute button
cyBerta 3 年之前
父節點
當前提交
fc770f64a1

+ 3 - 3
DcCore/DcCore/DC/Wrapper.swift

@@ -882,7 +882,7 @@ public class DcChat {
         return DcUtils.copyAndFreeArray(inputArray: dc_get_chat_contacts(dcContext.contextPointer, UInt32(id)))
     }
 
-    public lazy var profileImage: UIImage? = { [weak self] in
+    public lazy var profileImage: UIImage? = {
         guard let cString = dc_chat_get_profile_image(chatPointer) else { return nil }
         let filename = String(cString: cString)
         dc_str_unref(cString)
@@ -1075,7 +1075,7 @@ public class DcMsg {
         return nil
     }
 
-    public lazy var image: UIImage? = { [weak self] in
+    public lazy var image: UIImage? = {
         let filetype = dc_msg_get_viewtype(messagePointer)
         if let path = fileURL, filetype == DC_MSG_IMAGE || filetype == DC_MSG_GIF || filetype == DC_MSG_STICKER {
             if path.isFileURL {
@@ -1310,7 +1310,7 @@ public class DcContact {
         return dc_contact_is_blocked(contactPointer) == 1
     }
 
-    public lazy var profileImage: UIImage? = { [weak self] in
+    public lazy var profileImage: UIImage? = {
         guard let cString = dc_contact_get_profile_image(contactPointer) else { return nil }
         let filename = String(cString: cString)
         dc_str_unref(cString)

+ 2 - 2
Podfile.lock

@@ -26,7 +26,7 @@ PODS:
   - SVGKit (3.1.0):
     - CocoaLumberjack (~> 3.0)
   - SwiftFormat/CLI (0.40.9)
-  - SwiftLint (0.43.1)
+  - SwiftLint (0.47.0)
   - SwiftyBeaver (1.9.4)
 
 DEPENDENCIES:
@@ -76,7 +76,7 @@ SPEC CHECKSUMS:
   SDWebImageWebPCoder: d0dac55073088d24b2ac1b191a71a8f8d0adac21
   SVGKit: 3c8468aab0026048532a3b27a0c81cdd939f0649
   SwiftFormat: 6b67b6e7fe73d664f0cbb4f13721f130462c86a5
-  SwiftLint: 99f82d07b837b942dd563c668de129a03fc3fb52
+  SwiftLint: d41cc46a2ae58ac6d9f26954bc89f1d72e71fdef
   SwiftyBeaver: 576177b2c5c94b3aedd5993914e91271a0524e88
 
 PODFILE CHECKSUM: b1373ee5525a53ced60269aa3cfce2018c295507

+ 2 - 2
Pods/Manifest.lock

@@ -26,7 +26,7 @@ PODS:
   - SVGKit (3.1.0):
     - CocoaLumberjack (~> 3.0)
   - SwiftFormat/CLI (0.40.9)
-  - SwiftLint (0.43.1)
+  - SwiftLint (0.47.0)
   - SwiftyBeaver (1.9.4)
 
 DEPENDENCIES:
@@ -76,7 +76,7 @@ SPEC CHECKSUMS:
   SDWebImageWebPCoder: d0dac55073088d24b2ac1b191a71a8f8d0adac21
   SVGKit: 3c8468aab0026048532a3b27a0c81cdd939f0649
   SwiftFormat: 6b67b6e7fe73d664f0cbb4f13721f130462c86a5
-  SwiftLint: 99f82d07b837b942dd563c668de129a03fc3fb52
+  SwiftLint: d41cc46a2ae58ac6d9f26954bc89f1d72e71fdef
   SwiftyBeaver: 576177b2c5c94b3aedd5993914e91271a0524e88
 
 PODFILE CHECKSUM: b1373ee5525a53ced60269aa3cfce2018c295507

二進制
Pods/SwiftLint/swiftlint


+ 41 - 42
deltachat-ios/Controller/AccountSetupController.swift

@@ -573,48 +573,47 @@ class AccountSetupController: UITableViewController, ProgressAlertHandler {
     private func showOAuthAlertIfNeeded(emailAddress: String, handleCancel: (() -> Void)?) -> Bool {
         return false
 
-        // disable oauth2 for now as not yet supported by deltachat-rust.
-        /*
-         if skipOauth {
-             // user has previously denied oAuth2-setup
-             return false
-         }
-
-         guard let oAuth2UrlPointer = dc_get_oauth2_url(mailboxPointer, emailAddress, "chat.delta:/auth") else {
-             //MRConfig.setAuthFlags(flags: Int(DC_LP_AUTH_NORMAL)) -- do not reset, there may be different values
-             return false
-         }
-
-         let oAuth2Url = String(cString: oAuth2UrlPointer)
-
-         if let url = URL(string: oAuth2Url) {
-             let title = "Continue with simplified setup"
-             // swiftlint:disable all
-             let message = "The entered e-mail address supports a simplified setup (oAuth2).\n\nIn the next step, please allow Delta Chat to act as your Chat with E-Mail app.\n\nThere are no Delta Chat servers, your data stays on your device."
-
-             let oAuthAlertController = UIAlertController(title: title, message: message, preferredStyle: .alert)
-             let confirm = UIAlertAction(title: "Confirm", style: .default, handler: {
-                 [weak self] _ in // TODO: refactor usages of `self` to `self?` when this code is used again
-                 let nc = NotificationCenter.default
-                 self.oauth2Observer = nc.addObserver(self, selector: #selector(self.oauthLoginApproved), name: NSNotification.Name("oauthLoginApproved"), object: nil)
-                 self.launchOAuthBrowserWindow(url: url)
-             })
-             let cancel = UIAlertAction(title: "Cancel", style: .cancel, handler: {
-                 _ in
-                 MRConfig.setAuthFlags(flags: Int(DC_LP_AUTH_NORMAL))
-                 self.skipOauth = true
-                 handleCancel?()
-
-             })
-             oAuthAlertController.addAction(confirm)
-             oAuthAlertController.addAction(cancel)
-
-             present(oAuthAlertController, animated: true, completion: nil)
-             return true
-         } else {
-             return false
-         }
-         */
+        // don't use oauth2 for now as not yet supported by deltachat-rust.
+//
+//         if skipOauth {
+//             // user has previously denied oAuth2-setup
+//             return false
+//         }
+//
+//         guard let oAuth2UrlPointer = dc_get_oauth2_url(mailboxPointer, emailAddress, "chat.delta:/auth") else {
+//             //MRConfig.setAuthFlags(flags: Int(DC_LP_AUTH_NORMAL)) -- do not reset, there may be different values
+//             return false
+//         }
+//
+//         let oAuth2Url = String(cString: oAuth2UrlPointer)
+//
+//         if let url = URL(string: oAuth2Url) {
+//             let title = "Continue with simplified setup"
+//             // swiftlint:disable all
+//             let message = "The entered e-mail address supports a simplified setup (oAuth2).\n\nIn the next step, please allow Delta Chat to act as your Chat with E-Mail app.\n\nThere are no Delta Chat servers, your data stays on your device."
+//
+//             let oAuthAlertController = UIAlertController(title: title, message: message, preferredStyle: .alert)
+//             let confirm = UIAlertAction(title: "Confirm", style: .default, handler: {
+//                 [weak self] _ in // TODO: refactor usages of `self` to `self?` when this code is used again
+//                 let nc = NotificationCenter.default
+//                 self.oauth2Observer = nc.addObserver(self, selector: #selector(self.oauthLoginApproved), name: NSNotification.Name("oauthLoginApproved"), object: nil)
+//                 self.launchOAuthBrowserWindow(url: url)
+//             })
+//             let cancel = UIAlertAction(title: "Cancel", style: .cancel, handler: {
+//                 _ in
+//                 MRConfig.setAuthFlags(flags: Int(DC_LP_AUTH_NORMAL))
+//                 self.skipOauth = true
+//                 handleCancel?()
+//
+//             })
+//             oAuthAlertController.addAction(confirm)
+//             oAuthAlertController.addAction(cancel)
+//
+//             present(oAuthAlertController, animated: true, completion: nil)
+//             return true
+//         } else {
+//             return false
+//         }
     }
 
     @objc func oauthLoginApproved(notification: Notification) {

+ 1 - 1
deltachat-ios/Controller/WelcomeViewController.swift

@@ -135,7 +135,7 @@ class WelcomeViewController: UIViewController, ProgressAlertHandler {
         if dcAccounts.getSelected().isConfigured() {
             UserDefaults.standard.setValue(dcAccounts.getSelected().id, forKey: Constants.Keys.lastSelectedAccountKey)
 
-            //FIXME: what do we want to do with QR-Code created accounts? For now: adding an unencrypted account
+            // FIXME: what do we want to do with QR-Code created accounts? For now: adding an unencrypted account
             // ensure we're configuring on an empty new account
             _ = dcAccounts.add()
         }

+ 2 - 2
deltachat-ios/View/ContactDetailHeader.swift

@@ -39,7 +39,7 @@ class ContactDetailHeader: UIView {
         return label
     }()
 
-    private var searchButton: UIButton = {
+    private lazy var searchButton: UIButton = {
         let button = UIButton()
         button.translatesAutoresizingMaskIntoConstraints = false
         button.addTarget(self, action: #selector(searchBtnTapped), for: .touchUpInside)
@@ -58,7 +58,7 @@ class ContactDetailHeader: UIView {
         return button
     }()
 
-    private var muteButton: UIButton = {
+    private lazy var muteButton: UIButton = {
         let button = UIButton()
         button.translatesAutoresizingMaskIntoConstraints = false
         button.addTarget(self, action: #selector(muteBtnTapped), for: .touchUpInside)