ソースを参照

target more linter warnings

B. Petersen 6 年 前
コミット
07f03d0ae2

+ 2 - 2
.swiftlint.yml

@@ -40,8 +40,8 @@ function_parameter_count:
   error: 8
 
 type_body_length:
-  warning: 300
-  error: 500
+  warning: 600
+  error: 800
 
 file_length:
   warning: 1000

+ 2 - 1
deltachat-ios/AppDelegate.swift

@@ -210,7 +210,8 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
             }
         }
 
-        NotificationCenter.default.addObserver(self, selector: #selector(reachabilityChanged(note:)), name: .reachabilityChanged, object: reachability)
+        NotificationCenter.default.addObserver(self, selector: #selector(reachabilityChanged(note:)),
+                                               name: .reachabilityChanged, object: reachability)
         do {
             try reachability.startNotifier()
         } catch {

+ 2 - 2
deltachat-ios/Controller/AccountSetupController.swift

@@ -58,7 +58,7 @@ class AccountSetupController: UITableViewController {
 
     private lazy var restoreCell: ActionCell = {
         let cell = ActionCell(frame: .zero)
-        cell.actionTitle = String.localized("import_backup_title");
+        cell.actionTitle = String.localized("import_backup_title")
         cell.accessibilityIdentifier = "restoreCell"
         return cell
     }()
@@ -381,7 +381,7 @@ class AccountSetupController: UITableViewController {
 
     // returns true if needed
     private func showOAuthAlertIfNeeded(emailAddress: String, handleCancel: (() -> Void)?) -> Bool {
-        return false;
+        return false
 
         // disable oauth2 for now as not yet supported by deltachat-rust.
         /*

+ 14 - 7
deltachat-ios/Controller/ChatViewController.swift

@@ -244,8 +244,6 @@ class ChatViewController: MessagesViewController {
         }
     }
 
-
-
     private func configureMessageMenu() {
         var menuItems: [UIMenuItem]
 
@@ -335,7 +333,8 @@ class ChatViewController: MessagesViewController {
         messageInputBar.sendButton.title = nil
         messageInputBar.sendButton.tintColor = UIColor(white: 1, alpha: 1)
         messageInputBar.sendButton.layer.cornerRadius = 15
-        messageInputBar.middleContentViewPadding = UIEdgeInsets(top: 0, left: 5, bottom: 0, right: 10)	// this adds a padding between textinputfield and send button
+        messageInputBar.middleContentViewPadding = UIEdgeInsets(top: 0, left: 5, bottom: 0, right: 10)
+        // this adds a padding between textinputfield and send button
         messageInputBar.sendButton.contentEdgeInsets = UIEdgeInsets(top: 5, left: 5, bottom: 5, right: 5)
         messageInputBar.sendButton.setSize(CGSize(width: 30, height: 30), animated: false)
 
@@ -914,7 +913,9 @@ extension MessageCollectionViewCell {
             // Get indexPath
             if let indexPath = collectionView.indexPath(for: self) {
                 // Trigger action
-                collectionView.delegate?.collectionView?(collectionView, performAction: #selector(MessageCollectionViewCell.messageInfo(_:)), forItemAt: indexPath, withSender: sender)
+                collectionView.delegate?.collectionView?(collectionView,
+                    performAction: #selector(MessageCollectionViewCell.messageInfo(_:)),
+                    forItemAt: indexPath, withSender: sender)
             }
         }
     }
@@ -925,7 +926,9 @@ extension MessageCollectionViewCell {
             // Get indexPath
             if let indexPath = collectionView.indexPath(for: self) {
                 // Trigger action
-                collectionView.delegate?.collectionView?(collectionView, performAction: #selector(MessageCollectionViewCell.messageBlock(_:)), forItemAt: indexPath, withSender: sender)
+                collectionView.delegate?.collectionView?(collectionView,
+                    performAction: #selector(MessageCollectionViewCell.messageBlock(_:)),
+                    forItemAt: indexPath, withSender: sender)
             }
         }
     }
@@ -936,7 +939,9 @@ extension MessageCollectionViewCell {
             // Get indexPath
             if let indexPath = collectionView.indexPath(for: self) {
                 // Trigger action
-                collectionView.delegate?.collectionView?(collectionView, performAction: #selector(MessageCollectionViewCell.messageDismiss(_:)), forItemAt: indexPath, withSender: sender)
+                collectionView.delegate?.collectionView?(collectionView,
+                    performAction: #selector(MessageCollectionViewCell.messageDismiss(_:)),
+                    forItemAt: indexPath, withSender: sender)
             }
         }
     }
@@ -947,7 +952,9 @@ extension MessageCollectionViewCell {
             // Get indexPath
             if let indexPath = collectionView.indexPath(for: self) {
                 // Trigger action
-                collectionView.delegate?.collectionView?(collectionView, performAction: #selector(MessageCollectionViewCell.messageStartChat(_:)), forItemAt: indexPath, withSender: sender)
+                collectionView.delegate?.collectionView?(collectionView,
+                    performAction: #selector(MessageCollectionViewCell.messageStartChat(_:)),
+                    forItemAt: indexPath, withSender: sender)
             }
         }
     }

+ 6 - 2
deltachat-ios/Controller/ContactDetailViewController.swift

@@ -56,7 +56,9 @@ class ContactDetailViewController: UITableViewController {
 
     override func viewDidLoad() {
         super.viewDidLoad()
-        navigationItem.rightBarButtonItem = UIBarButtonItem(title: String.localized("global_menu_edit_desktop"), style: .plain, target: self, action: #selector(editButtonPressed))
+        navigationItem.rightBarButtonItem = UIBarButtonItem(
+            title: String.localized("global_menu_edit_desktop"),
+            style: .plain, target: self, action: #selector(editButtonPressed))
         self.title = String.localized("contact_detail_title_desktop")
     }
 
@@ -137,7 +139,9 @@ class ContactDetailViewController: UITableViewController {
     }
 
     private func showNotificationSetup() {
-        let notificationSetupAlert = UIAlertController(title: "Notifications Setup is not implemented yet", message: "But you get an idea where this is going", preferredStyle: .actionSheet)
+        let notificationSetupAlert = UIAlertController(title: "Notifications Setup is not implemented yet",
+                                                       message: "But you get an idea where this is going",
+                                                       preferredStyle: .actionSheet)
         let cancelAction = UIAlertAction(title: String.localized("cancel"), style: .cancel, handler: nil)
         notificationSetupAlert.addAction(cancelAction)
         present(notificationSetupAlert, animated: true, completion: nil)

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

@@ -12,7 +12,7 @@ final class DCNavigationController: UINavigationController {
         } else {
             navigationBar.setBackgroundImage(UIImage(), for: .default)
         }
-        navigationBar.backgroundColor = .white;
+        navigationBar.backgroundColor = .white
         setShadow(nil)
     }
 

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

@@ -42,7 +42,7 @@ class EditSettingsController: UITableViewController {
     override func viewWillDisappear(_ animated: Bool) {
         if displayNameBackup != displayNameCell.getText() || statusCellBackup != displayNameCell.getText() {
             DCConfig.selfstatus = statusCell.getText()
-            DCConfig.displayname = displayNameCell.getText()	
+            DCConfig.displayname = displayNameCell.getText()
             dc_configure(mailboxPointer)
         }
     }

+ 3 - 1
deltachat-ios/Controller/GroupChatDetailViewController.swift

@@ -40,7 +40,9 @@ class GroupChatDetailViewController: UIViewController {
     }
 
     private func showNotificationSetup() {
-        let notificationSetupAlert = UIAlertController(title: "Notifications Setup is not implemented yet", message: "But you get an idea where this is going", preferredStyle: .actionSheet)
+        let notificationSetupAlert = UIAlertController(title: "Notifications Setup is not implemented yet",
+                                                       message: "But you get an idea where this is going",
+                                                       preferredStyle: .actionSheet)
         let cancelAction = UIAlertAction(title: String.localized("cancel"), style: .cancel, handler: nil)
         notificationSetupAlert.addAction(cancelAction)
         present(notificationSetupAlert, animated: true, completion: nil)

+ 4 - 1
deltachat-ios/Controller/GroupMembersViewController.swift

@@ -7,7 +7,10 @@ class NewGroupViewController: GroupMembersViewController {
         super.viewDidLoad()
         title = String.localized("menu_new_group")
         navigationController?.navigationBar.prefersLargeTitles = false
-        let groupCreationNextButton = UIBarButtonItem(title: String.localized("next"), style: .done, target: self, action: #selector(nextButtonPressed))
+        let groupCreationNextButton = UIBarButtonItem(title: String.localized("next"),
+                                                      style: .done,
+                                                      target: self,
+                                                      action: #selector(nextButtonPressed))
         navigationItem.rightBarButtonItem = groupCreationNextButton
         contactIds = Utils.getContactIds()
     }

+ 3 - 1
deltachat-ios/Controller/NewChatViewController.swift

@@ -104,7 +104,9 @@ class NewChatViewController: UITableViewController {
     }
 
     override func viewWillDisappear(_: Bool) {
-        title = String.localized("pref_chats") /* hack: when navigating to chatView (removing this viewController), there was a delayed backButton update (showing 'New Chat' for a moment) */
+        title = String.localized("pref_chats")
+        /* hack: when navigating to chatView (removing this viewController),
+        there was a delayed backButton update (showing 'New Chat' for a moment) */
     }
 
     override func viewDidDisappear(_ animated: Bool) {

+ 1 - 2
deltachat-ios/Controller/NewProfileViewController.swift

@@ -196,7 +196,7 @@ class NewProfileViewController: UIViewController, QrCodeReaderDelegate {
         }
 
         let qrParsed: DcLot = self.dcContext.checkQR(qrCode: code)
-        let nameAndAddress = DCContact(id: qrParsed.id).nameNAddr;
+        let nameAndAddress = DCContact(id: qrParsed.id).nameNAddr
         let alert = UIAlertController(title: String.localizedStringWithFormat(String.localized("qrscan_ask_fingerprint_ask_oob"), nameAndAddress),
                                       message: nil,
                                       preferredStyle: .alert)
@@ -305,4 +305,3 @@ class NewProfileViewController: UIViewController, QrCodeReaderDelegate {
         navigationController?.pushViewController(chatVC, animated: true)
     }
 }
-

+ 3 - 1
deltachat-ios/Controller/SettingsController.swift

@@ -210,7 +210,9 @@ internal final class SettingsViewController: QuickTableViewController {
 
         let dbfile = appDelegate.dbfile()
         let dburl = URL(fileURLWithPath: dbfile, isDirectory: false)
-        let alert = UIAlertController(title: String.localized("delete_account"), message: String.localized("delete_account_message"), preferredStyle: .actionSheet)
+        let alert = UIAlertController(title: String.localized("delete_account"),
+                                      message: String.localized("delete_account_message"),
+                                      preferredStyle: .actionSheet)
 
         alert.addAction(UIAlertAction(title: String.localized("delete"), style: .destructive, handler: { _ in
             appDelegate.stop()

+ 1 - 2
deltachat-ios/DC/Wrapper.swift

@@ -578,8 +578,7 @@ class DCConfig {
     private class func setOptStr(_ key: String, _ value: String?) {
         if let v = value {
             dc_set_config(mailboxPointer, key, v)
-        }
-        else {
+        } else {
             dc_set_config(mailboxPointer, key, nil)
         }
     }

+ 3 - 2
deltachat-ios/Helper/Constants.swift

@@ -2,7 +2,9 @@ import UIKit
 
 struct Constants {
     // see: https://core.telegram.org/blackberry/chat
-    static let chatColors: [UIColor] = ["#ee4928", "#41a903", "#e09602", "#0f94ed", "#8f3bf7", "#fc4380", "#00a1c4", "#eb7002"].map { s in UIColor(hexString: s) }
+    static let chatColors: [UIColor] = [
+        "#ee4928", "#41a903", "#e09602", "#0f94ed",
+        "#8f3bf7", "#fc4380", "#00a1c4", "#eb7002"].map { s in UIColor(hexString: s) }
     struct Color {
         static let bubble = UIColor(netHex: 0xEFFFDE)
     }
@@ -18,4 +20,3 @@ struct Constants {
 
     static let notificationIdentifier = "deltachat-ios-local-notifications"
 }
-

+ 1 - 1
deltachat-ios/Helper/UIImage+Extension.swift

@@ -31,7 +31,7 @@ extension UIImage {
         let heightRatio = targetSize.height / size.height
 
         var newSize: CGSize
-        if(widthRatio > heightRatio) {
+        if widthRatio > heightRatio {
             newSize = CGSize(width: size.width * heightRatio, height: size.height * heightRatio)
         } else {
             newSize = CGSize(width: size.width * widthRatio, height: size.height *      widthRatio)

+ 4 - 3
deltachat-ios/Helper/Utils.swift

@@ -102,7 +102,8 @@ struct Utils {
     }
 
     static func saveImage(image: UIImage) -> String? {
-        guard let directory = try? FileManager.default.url(for: .documentDirectory, in: .userDomainMask, appropriateFor: nil, create: false) as NSURL else {
+        guard let directory = try? FileManager.default.url(for: .documentDirectory, in: .userDomainMask,
+            appropriateFor: nil, create: false) as NSURL else {
             return nil
         }
 
@@ -165,10 +166,10 @@ class DateUtils {
             return String.localized("now")	// under one minute
         } else if seconds < 3600 {
             let mins = seconds / 60
-            return String.localized(stringID: "n_minutes", count: mins);
+            return String.localized(stringID: "n_minutes", count: mins)
         } else if seconds < 86400 {
             let hours = seconds / 3600
-            return String.localized(stringID: "n_hours", count: hours);
+            return String.localized(stringID: "n_hours", count: hours)
         } else {
             let date = Date(timeIntervalSince1970: Double(timeStamp))
             let dateFormatter = DateFormatter()

+ 2 - 1
deltachat-ios/View/TextFieldCell.swift

@@ -43,7 +43,8 @@ class TextFieldCell: UITableViewCell {
         textField.trailingAnchor.constraint(equalTo: trailing).isActive = true
         textField.centerYAnchor.constraint(equalTo: contentView.centerYAnchor).isActive = true
         if let label = self.textLabel {
-            textField.leadingAnchor.constraint(equalTo: label.trailingAnchor, constant: 20).isActive = true // this will prevent the textfield from growing over the textLabel while typing
+            textField.leadingAnchor.constraint(equalTo: label.trailingAnchor, constant: 20).isActive = true
+            // this will prevent the textfield from growing over the textLabel while typing
         } else {
             textField.leadingAnchor.constraint(equalTo: contentView.leadingAnchor, constant: 20).isActive = true
         }