diff --git a/FlowCrypt/App/Logger.swift b/FlowCrypt/App/Logger.swift index bee940c46..36d97940a 100644 --- a/FlowCrypt/App/Logger.swift +++ b/FlowCrypt/App/Logger.swift @@ -76,7 +76,7 @@ struct Logger { } } - static var dateFormatter = DateFormatter().then { + static var dateFormatter = DateFormatter().then { $0.dateFormat = "HH:mm:ss" $0.locale = .current $0.timeZone = .current @@ -143,12 +143,12 @@ extension Logger { } static func nested(_ type: T.Type) -> Logger { - Logger(config: .default, label: "[\(String(describing: type))]") + Logger(config: .default, label: "[\(String.init(describing: type))]") } static func nested(in type: T.Type, with label: String) -> Logger { var message = "[\(label)]" - message.append("[\(String(describing: type))]") + message.append("[\(String.init(describing: type))]") return Logger(config: .default, label: message) } } diff --git a/FlowCrypt/AppDelegate.swift b/FlowCrypt/AppDelegate.swift index 8a96beb0a..7eb97c628 100644 --- a/FlowCrypt/AppDelegate.swift +++ b/FlowCrypt/AppDelegate.swift @@ -3,8 +3,8 @@ // FlowCrypt // -import AppAuth import UIKit +import AppAuth class AppDelegate: UIResponder, UIApplicationDelegate { var googleAuthSession: OIDExternalUserAgentSession? diff --git a/FlowCrypt/Common UI/View Controllers/SegmentedViewController.swift b/FlowCrypt/Common UI/View Controllers/SegmentedViewController.swift index 5a9f24ae5..9040837a0 100644 --- a/FlowCrypt/Common UI/View Controllers/SegmentedViewController.swift +++ b/FlowCrypt/Common UI/View Controllers/SegmentedViewController.swift @@ -47,7 +47,6 @@ final class SegmentedViewController: ASDKViewController { super.init(node: ASDisplayNode()) } - @available(*, unavailable) required init?(coder _: NSCoder) { fatalError("init(coder:) has not been implemented") } diff --git a/FlowCrypt/Common UI/View Controllers/WebViewController.swift b/FlowCrypt/Common UI/View Controllers/WebViewController.swift index c33fc7891..482593dd3 100644 --- a/FlowCrypt/Common UI/View Controllers/WebViewController.swift +++ b/FlowCrypt/Common UI/View Controllers/WebViewController.swift @@ -19,7 +19,6 @@ final class WebViewController: UIViewController { super.init(nibName: nil, bundle: nil) } - @available(*, unavailable) required init?(coder _: NSCoder) { fatalError("init(coder:) has not been implemented") } diff --git a/FlowCrypt/Controllers/Compose/ComposeViewController.swift b/FlowCrypt/Controllers/Compose/ComposeViewController.swift index 1474b7b3f..ac79ef83b 100644 --- a/FlowCrypt/Controllers/Compose/ComposeViewController.swift +++ b/FlowCrypt/Controllers/Compose/ComposeViewController.swift @@ -89,7 +89,6 @@ final class ComposeViewController: TableNodeViewController { super.init(node: TableNode()) } - @available(*, unavailable) required init?(coder _: NSCoder) { fatalError("init(coder:) has not been implemented") } diff --git a/FlowCrypt/Controllers/ImportKey/Enter Pass Phrase/EnterPassPhraseViewController.swift b/FlowCrypt/Controllers/ImportKey/Enter Pass Phrase/EnterPassPhraseViewController.swift index a00edbd9d..c27276db6 100644 --- a/FlowCrypt/Controllers/ImportKey/Enter Pass Phrase/EnterPassPhraseViewController.swift +++ b/FlowCrypt/Controllers/ImportKey/Enter Pass Phrase/EnterPassPhraseViewController.swift @@ -47,7 +47,6 @@ final class EnterPassPhraseViewController: TableNodeViewController { super.init(node: TableNode()) } - @available(*, unavailable) required init?(coder _: NSCoder) { fatalError("init(coder:) has not been implemented") } diff --git a/FlowCrypt/Controllers/ImportKey/Import Key/ImportKeyViewController.swift b/FlowCrypt/Controllers/ImportKey/Import Key/ImportKeyViewController.swift index 43d90c63c..96ad60e18 100644 --- a/FlowCrypt/Controllers/ImportKey/Import Key/ImportKeyViewController.swift +++ b/FlowCrypt/Controllers/ImportKey/Import Key/ImportKeyViewController.swift @@ -41,7 +41,6 @@ final class ImportKeyViewController: TableNodeViewController { super.init(node: TableNode()) } - @available(*, unavailable) required init?(coder _: NSCoder) { fatalError("init(coder:) has not been implemented") } diff --git a/FlowCrypt/Controllers/Inbox/Container/InboxViewControllerContainer.swift b/FlowCrypt/Controllers/Inbox/Container/InboxViewControllerContainer.swift index 223d0b114..6390f0196 100644 --- a/FlowCrypt/Controllers/Inbox/Container/InboxViewControllerContainer.swift +++ b/FlowCrypt/Controllers/Inbox/Container/InboxViewControllerContainer.swift @@ -7,8 +7,8 @@ // import AsyncDisplayKit -import FlowCryptCommon import FlowCryptUI +import FlowCryptCommon // MARK: - InboxViewControllerContainer // Used to fetch folders and get correct path for "inbox" folder @@ -45,7 +45,6 @@ final class InboxViewControllerContainer: TableNodeViewController { node.dataSource = self } - @available(*, unavailable) required init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented") } diff --git a/FlowCrypt/Controllers/Inbox/Container/InboxViewControllerContainerDecorator.swift b/FlowCrypt/Controllers/Inbox/Container/InboxViewControllerContainerDecorator.swift index 479e4ff4e..fbff051e2 100644 --- a/FlowCrypt/Controllers/Inbox/Container/InboxViewControllerContainerDecorator.swift +++ b/FlowCrypt/Controllers/Inbox/Container/InboxViewControllerContainerDecorator.swift @@ -6,8 +6,8 @@ // Copyright © 2020 FlowCrypt Limited. All rights reserved. // -import FlowCryptUI import UIKit +import FlowCryptUI struct InboxViewControllerContainerDecorator { func emptyFoldersInput(with size: CGSize) -> TextCellNode.Input { diff --git a/FlowCrypt/Controllers/Inbox/InboxViewController.swift b/FlowCrypt/Controllers/Inbox/InboxViewController.swift index d6d56067c..c07bac307 100644 --- a/FlowCrypt/Controllers/Inbox/InboxViewController.swift +++ b/FlowCrypt/Controllers/Inbox/InboxViewController.swift @@ -77,7 +77,6 @@ final class InboxViewController: ASDKViewController { tableNode.leadingScreensForBatching = 1 } - @available(*, unavailable) required init?(coder _: NSCoder) { fatalError("init(coder:) has not been implemented") } diff --git a/FlowCrypt/Controllers/Msg/MessageViewController.swift b/FlowCrypt/Controllers/Msg/MessageViewController.swift index 479d649be..202997b7b 100644 --- a/FlowCrypt/Controllers/Msg/MessageViewController.swift +++ b/FlowCrypt/Controllers/Msg/MessageViewController.swift @@ -83,7 +83,6 @@ final class MessageViewController: TableNodeViewController { super.init(node: TableNode()) } - @available(*, unavailable) required init?(coder _: NSCoder) { fatalError("init(coder:) has not been implemented") } @@ -282,7 +281,7 @@ extension MessageViewController { return true } .then(on: .main) { [weak self] didPerformOp in - guard didPerformOp else { self?.hideSpinner(); return } + guard didPerformOp else { self?.hideSpinner(); return } self?.handleOpSuccess(operation: .permanentlyDelete) }.catch(on: .main) { [weak self] _ in self?.handleOpErr(operation: .permanentlyDelete) diff --git a/FlowCrypt/Controllers/Search/SearchViewController.swift b/FlowCrypt/Controllers/Search/SearchViewController.swift index ed9b745ec..02c516367 100644 --- a/FlowCrypt/Controllers/Search/SearchViewController.swift +++ b/FlowCrypt/Controllers/Search/SearchViewController.swift @@ -48,7 +48,6 @@ final class SearchViewController: TableNodeViewController { super.init(node: TableNode()) } - @available(*, unavailable) required init?(coder _: NSCoder) { fatalError("init(coder:) has not been implemented") } diff --git a/FlowCrypt/Controllers/Settings/Backup/Backups Option Scene/BackupOptionsViewController.swift b/FlowCrypt/Controllers/Settings/Backup/Backups Option Scene/BackupOptionsViewController.swift index fb9a5a643..52d23235f 100644 --- a/FlowCrypt/Controllers/Settings/Backup/Backups Option Scene/BackupOptionsViewController.swift +++ b/FlowCrypt/Controllers/Settings/Backup/Backups Option Scene/BackupOptionsViewController.swift @@ -6,8 +6,8 @@ // Copyright © 2020 FlowCrypt Limited. All rights reserved. // -import AsyncDisplayKit import FlowCryptUI +import AsyncDisplayKit enum BackupOption: Int, CaseIterable, Equatable { case email, download @@ -47,7 +47,6 @@ final class BackupOptionsViewController: ASDKViewController { super.init(node: TableNode()) } - @available(*, unavailable) required init?(coder _: NSCoder) { fatalError("init(coder:) has not been implemented") } diff --git a/FlowCrypt/Controllers/Settings/Backup/Backups Option Scene/BackupOptionsViewDecorator.swift b/FlowCrypt/Controllers/Settings/Backup/Backups Option Scene/BackupOptionsViewDecorator.swift index 262277646..5e15328f2 100644 --- a/FlowCrypt/Controllers/Settings/Backup/Backups Option Scene/BackupOptionsViewDecorator.swift +++ b/FlowCrypt/Controllers/Settings/Backup/Backups Option Scene/BackupOptionsViewDecorator.swift @@ -6,8 +6,8 @@ // Copyright © 2020 FlowCrypt Limited. All rights reserved. // -import FlowCryptUI import UIKit +import FlowCryptUI protocol BackupOptionsViewDecoratorType { var sceneTitle: String { get } @@ -62,7 +62,7 @@ struct BackupOptionsViewDecorator: BackupOptionsViewDecoratorType { ? .main : .lightGray - return CheckBoxTextNode.Input( + return CheckBoxTextNode.Input.init( title: attributedTitle, insets: .side(16), preferredSize: CGSize(width: 30, height: 30), diff --git a/FlowCrypt/Controllers/Settings/Backup/Backups Scene/BackupViewController.swift b/FlowCrypt/Controllers/Settings/Backup/Backups Scene/BackupViewController.swift index a32368891..6860bdee2 100644 --- a/FlowCrypt/Controllers/Settings/Backup/Backups Scene/BackupViewController.swift +++ b/FlowCrypt/Controllers/Settings/Backup/Backups Scene/BackupViewController.swift @@ -6,8 +6,8 @@ // Copyright © 2020 FlowCrypt Limited. All rights reserved. // -import AsyncDisplayKit import FlowCryptUI +import AsyncDisplayKit final class BackupViewController: ASDKViewController { private enum Parts: Int, CaseIterable { @@ -50,7 +50,6 @@ final class BackupViewController: ASDKViewController { super.init(node: TableNode()) } - @available(*, unavailable) required init?(coder _: NSCoder) { fatalError("init(coder:) has not been implemented") } diff --git a/FlowCrypt/Controllers/Settings/Backup/Backups Seleckt Key Scene/BackupSelectKeyDecorator.swift b/FlowCrypt/Controllers/Settings/Backup/Backups Seleckt Key Scene/BackupSelectKeyDecorator.swift index 35eb1b7cc..4547d9776 100644 --- a/FlowCrypt/Controllers/Settings/Backup/Backups Seleckt Key Scene/BackupSelectKeyDecorator.swift +++ b/FlowCrypt/Controllers/Settings/Backup/Backups Seleckt Key Scene/BackupSelectKeyDecorator.swift @@ -6,9 +6,9 @@ // Copyright © 2020 FlowCrypt Limited. All rights reserved. // -import FlowCryptCommon -import FlowCryptUI import UIKit +import FlowCryptUI +import FlowCryptCommon protocol BackupSelectKeyDecoratorType { var sceneTitle: String { get } @@ -37,7 +37,7 @@ struct BackupSelectKeyDecorator: BackupSelectKeyDecoratorType { ? .main : .lightGray - return CheckBoxTextNode.Input( + return CheckBoxTextNode.Input.init( title: title, subtitle: subtitle, insets: UIEdgeInsets(top: 8, left: 16, bottom: 8, right: 16), diff --git a/FlowCrypt/Controllers/Settings/Backup/Backups Seleckt Key Scene/BackupSelectKeyViewController.swift b/FlowCrypt/Controllers/Settings/Backup/Backups Seleckt Key Scene/BackupSelectKeyViewController.swift index b3c4fe98b..878f85c30 100644 --- a/FlowCrypt/Controllers/Settings/Backup/Backups Seleckt Key Scene/BackupSelectKeyViewController.swift +++ b/FlowCrypt/Controllers/Settings/Backup/Backups Seleckt Key Scene/BackupSelectKeyViewController.swift @@ -6,9 +6,9 @@ // Copyright © 2020 FlowCrypt Limited. All rights reserved. // -import AsyncDisplayKit -import FlowCryptUI import Foundation +import FlowCryptUI +import AsyncDisplayKit final class BackupSelectKeyViewController: ASDKViewController { private let backupService: BackupServiceType @@ -34,7 +34,6 @@ final class BackupSelectKeyViewController: ASDKViewController { super.init(node: TableNode()) } - @available(*, unavailable) required init?(coder _: NSCoder) { fatalError("init(coder:) has not been implemented") } diff --git a/FlowCrypt/Controllers/Settings/Contacts/Contacts List/ContactDetailDecorator.swift b/FlowCrypt/Controllers/Settings/Contacts/Contacts List/ContactDetailDecorator.swift index 1a02af594..7de7871aa 100644 --- a/FlowCrypt/Controllers/Settings/Contacts/Contacts List/ContactDetailDecorator.swift +++ b/FlowCrypt/Controllers/Settings/Contacts/Contacts List/ContactDetailDecorator.swift @@ -6,8 +6,8 @@ // Copyright © 2020 FlowCrypt Limited. All rights reserved. // -import FlowCryptUI import Foundation +import FlowCryptUI protocol ContactDetailDecoratorType { var title: String { get } diff --git a/FlowCrypt/Controllers/Settings/Contacts/Contacts List/ContactDetailViewController.swift b/FlowCrypt/Controllers/Settings/Contacts/Contacts List/ContactDetailViewController.swift index b9a0b6f89..c5eb4c53c 100644 --- a/FlowCrypt/Controllers/Settings/Contacts/Contacts List/ContactDetailViewController.swift +++ b/FlowCrypt/Controllers/Settings/Contacts/Contacts List/ContactDetailViewController.swift @@ -31,7 +31,6 @@ final class ContactDetailViewController: TableNodeViewController { super.init(node: TableNode()) } - @available(*, unavailable) required init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented") } diff --git a/FlowCrypt/Controllers/Settings/Contacts/Contacts List/ContactsListDecorator.swift b/FlowCrypt/Controllers/Settings/Contacts/Contacts List/ContactsListDecorator.swift index 3be4721ac..645428be0 100644 --- a/FlowCrypt/Controllers/Settings/Contacts/Contacts List/ContactsListDecorator.swift +++ b/FlowCrypt/Controllers/Settings/Contacts/Contacts List/ContactsListDecorator.swift @@ -6,8 +6,8 @@ // Copyright © 2020 FlowCrypt Limited. All rights reserved. // -import FlowCryptUI import UIKit +import FlowCryptUI protocol ContactsListDecoratorType { var title: String { get } diff --git a/FlowCrypt/Controllers/Settings/Contacts/Contacts List/ContactsListViewController.swift b/FlowCrypt/Controllers/Settings/Contacts/Contacts List/ContactsListViewController.swift index 5eccbf0c6..08dbf682b 100644 --- a/FlowCrypt/Controllers/Settings/Contacts/Contacts List/ContactsListViewController.swift +++ b/FlowCrypt/Controllers/Settings/Contacts/Contacts List/ContactsListViewController.swift @@ -6,9 +6,9 @@ // Copyright © 2020 FlowCrypt Limited. All rights reserved. // +import FlowCryptUI import AsyncDisplayKit import FlowCryptCommon -import FlowCryptUI final class ContactsListViewController: TableNodeViewController { private let decorator: ContactsListDecoratorType @@ -24,7 +24,6 @@ final class ContactsListViewController: TableNodeViewController { super.init(node: TableNode()) } - @available(*, unavailable) required init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented") } diff --git a/FlowCrypt/Controllers/Settings/KeyLegal/LegalViewController.swift b/FlowCrypt/Controllers/Settings/KeyLegal/LegalViewController.swift index e4c1c85e9..e395201cd 100644 --- a/FlowCrypt/Controllers/Settings/KeyLegal/LegalViewController.swift +++ b/FlowCrypt/Controllers/Settings/KeyLegal/LegalViewController.swift @@ -21,7 +21,6 @@ final class LegalViewController: UIViewController { super.init(nibName: nil, bundle: nil) } - @available(*, unavailable) required init?(coder _: NSCoder) { fatalError("init(coder:) has not been implemented") } diff --git a/FlowCrypt/Controllers/Settings/KeySettings/Key Detail Info/KeyDetailInfoViewController.swift b/FlowCrypt/Controllers/Settings/KeySettings/Key Detail Info/KeyDetailInfoViewController.swift index db5a8fce9..137478c63 100644 --- a/FlowCrypt/Controllers/Settings/KeySettings/Key Detail Info/KeyDetailInfoViewController.swift +++ b/FlowCrypt/Controllers/Settings/KeySettings/Key Detail Info/KeyDetailInfoViewController.swift @@ -31,7 +31,6 @@ final class KeyDetailInfoViewController: TableNodeViewController { super.init(node: TableNode()) } - @available(*, unavailable) required init?(coder _: NSCoder) { fatalError("init(coder:) has not been implemented") } diff --git a/FlowCrypt/Controllers/Settings/KeySettings/Key Details/KeyDetailViewController.swift b/FlowCrypt/Controllers/Settings/KeySettings/Key Details/KeyDetailViewController.swift index 6a171c61d..a81afe14e 100644 --- a/FlowCrypt/Controllers/Settings/KeySettings/Key Details/KeyDetailViewController.swift +++ b/FlowCrypt/Controllers/Settings/KeySettings/Key Details/KeyDetailViewController.swift @@ -29,7 +29,6 @@ final class KeyDetailViewController: TableNodeViewController { super.init(node: TableNode()) } - @available(*, unavailable) required init?(coder _: NSCoder) { fatalError("init(coder:) has not been implemented") } diff --git a/FlowCrypt/Controllers/Settings/KeySettings/Key List/KeySettingsViewController.swift b/FlowCrypt/Controllers/Settings/KeySettings/Key List/KeySettingsViewController.swift index 6be74e2e3..06904fda2 100644 --- a/FlowCrypt/Controllers/Settings/KeySettings/Key List/KeySettingsViewController.swift +++ b/FlowCrypt/Controllers/Settings/KeySettings/Key List/KeySettingsViewController.swift @@ -23,7 +23,6 @@ final class KeySettingsViewController: TableNodeViewController { super.init(node: TableNode()) } - @available(*, unavailable) required init?(coder _: NSCoder) { fatalError("init(coder:) has not been implemented") } diff --git a/FlowCrypt/Controllers/Settings/KeySettings/Key List/KeySettingsViewDecorator.swift b/FlowCrypt/Controllers/Settings/KeySettings/Key List/KeySettingsViewDecorator.swift index e5ae328ef..a51c58d2f 100644 --- a/FlowCrypt/Controllers/Settings/KeySettings/Key List/KeySettingsViewDecorator.swift +++ b/FlowCrypt/Controllers/Settings/KeySettings/Key List/KeySettingsViewDecorator.swift @@ -6,8 +6,8 @@ // Copyright © 2019 FlowCrypt Limited. All rights reserved. // -import FlowCryptCommon import Foundation +import FlowCryptCommon protocol KeySettingsViewDecoratorType { func attributedUsers(key: KeyDetails) -> NSAttributedString diff --git a/FlowCrypt/Controllers/Settings/KeySettings/Public Key/PublicKeyDetailViewController.swift b/FlowCrypt/Controllers/Settings/KeySettings/Public Key/PublicKeyDetailViewController.swift index 4a90ba330..36b39cab7 100644 --- a/FlowCrypt/Controllers/Settings/KeySettings/Public Key/PublicKeyDetailViewController.swift +++ b/FlowCrypt/Controllers/Settings/KeySettings/Public Key/PublicKeyDetailViewController.swift @@ -17,7 +17,6 @@ final class PublicKeyDetailViewController: TableNodeViewController { super.init(node: TableNode()) } - @available(*, unavailable) required init?(coder _: NSCoder) { fatalError("init(coder:) has not been implemented") } @@ -39,7 +38,7 @@ extension PublicKeyDetailViewController: ASTableDelegate, ASTableDataSource { func tableNode(_: ASTableNode, nodeBlockForRowAt _: IndexPath) -> ASCellNodeBlock { return { [weak self] in - SetupTitleNode( + return SetupTitleNode( SetupTitleNode.Input( title: (self?.text ?? "").attributed(.regular(16)), insets: .side(16), diff --git a/FlowCrypt/Controllers/Settings/Settings List/SettingsViewController.swift b/FlowCrypt/Controllers/Settings/Settings List/SettingsViewController.swift index 6b31bbeec..7dea2f913 100644 --- a/FlowCrypt/Controllers/Settings/Settings List/SettingsViewController.swift +++ b/FlowCrypt/Controllers/Settings/Settings List/SettingsViewController.swift @@ -39,7 +39,6 @@ final class SettingsViewController: TableNodeViewController { super.init(node: TableNode()) } - @available(*, unavailable) required init?(coder _: NSCoder) { fatalError("init(coder:) has not been implemented") } diff --git a/FlowCrypt/Controllers/Setup/SetupViewController.swift b/FlowCrypt/Controllers/Setup/SetupViewController.swift index 9aa5dda35..30d407ab9 100644 --- a/FlowCrypt/Controllers/Setup/SetupViewController.swift +++ b/FlowCrypt/Controllers/Setup/SetupViewController.swift @@ -80,7 +80,6 @@ final class SetupViewController: TableNodeViewController { super.init(node: TableNode()) } - @available(*, unavailable) required init?(coder _: NSCoder) { fatalError("init(coder:) has not been implemented") } diff --git a/FlowCrypt/Controllers/SideMenu/Menu/MyMenuViewController.swift b/FlowCrypt/Controllers/SideMenu/Menu/MyMenuViewController.swift index 4ffb216cf..1f9b6329c 100644 --- a/FlowCrypt/Controllers/SideMenu/Menu/MyMenuViewController.swift +++ b/FlowCrypt/Controllers/SideMenu/Menu/MyMenuViewController.swift @@ -71,7 +71,6 @@ final class MyMenuViewController: ASDKViewController { super.init(node: ASDisplayNode()) } - @available(*, unavailable) required init?(coder _: NSCoder) { fatalError("init(coder:) has not been implemented") } @@ -276,6 +275,7 @@ extension MyMenuViewController { divider.backgroundColor = decorator.dividerColor } } + } // MARK: - Actions diff --git a/FlowCrypt/Controllers/SideMenu/Menu/MyMenuViewDecorator.swift b/FlowCrypt/Controllers/SideMenu/Menu/MyMenuViewDecorator.swift index 0f291719a..4a2ef12ca 100644 --- a/FlowCrypt/Controllers/SideMenu/Menu/MyMenuViewDecorator.swift +++ b/FlowCrypt/Controllers/SideMenu/Menu/MyMenuViewDecorator.swift @@ -6,8 +6,8 @@ // Copyright © 2020 FlowCrypt Limited. All rights reserved. // -import FlowCryptCommon import FlowCryptUI +import FlowCryptCommon import UIKit protocol MyMenuViewDecoratorType { diff --git a/FlowCrypt/Controllers/SignIn Other/EmailProviderViewController.swift b/FlowCrypt/Controllers/SignIn Other/EmailProviderViewController.swift index 791273b7b..db3a2bc16 100644 --- a/FlowCrypt/Controllers/SignIn Other/EmailProviderViewController.swift +++ b/FlowCrypt/Controllers/SignIn Other/EmailProviderViewController.swift @@ -46,7 +46,6 @@ final class EmailProviderViewController: TableNodeViewController { node.dataSource = self } - @available(*, unavailable) required init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented") } @@ -512,6 +511,7 @@ extension EmailProviderViewController { return .success(user) } + } // MARK: - Picker diff --git a/FlowCrypt/Controllers/SignIn Other/EmailProviderViewDecorator.swift b/FlowCrypt/Controllers/SignIn Other/EmailProviderViewDecorator.swift index 613a0a104..fbbc39479 100644 --- a/FlowCrypt/Controllers/SignIn Other/EmailProviderViewDecorator.swift +++ b/FlowCrypt/Controllers/SignIn Other/EmailProviderViewDecorator.swift @@ -6,8 +6,8 @@ // Copyright © 2020 FlowCrypt Limited. All rights reserved. // -import FlowCryptUI import UIKit +import FlowCryptUI protocol EmailProviderViewDecoratorType { var connectButtonTitle: NSAttributedString { get } diff --git a/FlowCrypt/Controllers/SignIn/SignInViewController.swift b/FlowCrypt/Controllers/SignIn/SignInViewController.swift index 79ae91558..d6a3e0918 100644 --- a/FlowCrypt/Controllers/SignIn/SignInViewController.swift +++ b/FlowCrypt/Controllers/SignIn/SignInViewController.swift @@ -36,7 +36,6 @@ final class SignInViewController: TableNodeViewController { node.dataSource = self } - @available(*, unavailable) required init?(coder _: NSCoder) { fatalError("init(coder:) has not been implemented") } diff --git a/FlowCrypt/Core/Core.swift b/FlowCrypt/Core/Core.swift index ec4bf230d..e8479939e 100644 --- a/FlowCrypt/Core/Core.swift +++ b/FlowCrypt/Core/Core.swift @@ -111,7 +111,7 @@ final class Core { let jsFileSrc = try? String(contentsOfFile: jsFile) self.context = JSContext(virtualMachine: self.vm)! self.context?.setObject(CoreHost(), forKeyedSubscript: "coreHost" as (NSCopying & NSObjectProtocol)) - self.context!.exceptionHandler = { [weak self] _, exception in + self.context!.exceptionHandler = { [weak self] (_, exception) in guard let exception = exception else { return } self?.logger.logWarning("\(exception)") } diff --git a/FlowCrypt/Core/CoreHost.swift b/FlowCrypt/Core/CoreHost.swift index f6d435bff..78a433be3 100644 --- a/FlowCrypt/Core/CoreHost.swift +++ b/FlowCrypt/Core/CoreHost.swift @@ -2,13 +2,13 @@ // © 2017-2019 FlowCrypt Limited. All rights reserved. // -import BigInt import CommonCrypto // for hashing import Foundation import IDZSwiftCommonCrypto // for aes import JavaScriptCore // for export to js import Security // for rng import SwiftyRSA // for rsa +import BigInt @objc protocol CoreHostExports: JSExport { // crypto diff --git a/FlowCrypt/Core/Models/CoreTypesTest.swift b/FlowCrypt/Core/Models/CoreTypesTest.swift index 317d845e8..b61c0b883 100644 --- a/FlowCrypt/Core/Models/CoreTypesTest.swift +++ b/FlowCrypt/Core/Models/CoreTypesTest.swift @@ -6,8 +6,8 @@ // Copyright © 2020 FlowCrypt Limited. All rights reserved. // -import FlowCryptCommon import XCTest +import FlowCryptCommon class CoreTypesTest: XCTestCase { @@ -59,6 +59,7 @@ class CoreTypesTest: XCTestCase { 1, "If the [KeyDetails] contains two keys with the same fingerprint, only one should be added" ) + } func test_key_ids_with_same_fingerprint() { diff --git a/FlowCrypt/Core/Models/KeyDetails.swift b/FlowCrypt/Core/Models/KeyDetails.swift index c98d20021..1a7ab442d 100644 --- a/FlowCrypt/Core/Models/KeyDetails.swift +++ b/FlowCrypt/Core/Models/KeyDetails.swift @@ -6,8 +6,8 @@ // Copyright © 2020 FlowCrypt Limited. All rights reserved. // -import FlowCryptCommon import Foundation +import FlowCryptCommon struct KeyDetails: Decodable { let `public`: String diff --git a/FlowCrypt/Extensions/UIViewControllerExtensions.swift b/FlowCrypt/Extensions/UIViewControllerExtensions.swift index 7f314850f..f7ebe9aff 100644 --- a/FlowCrypt/Extensions/UIViewControllerExtensions.swift +++ b/FlowCrypt/Extensions/UIViewControllerExtensions.swift @@ -108,7 +108,7 @@ extension UIViewController { func showSpinner(_ message: String = "loading_title".localized, isUserInteractionEnabled: Bool = false) { DispatchQueue.main.async { - guard self.view.subviews.first(where: { $0 is MBProgressHUD }) == nil else { + guard self.view.subviews.first(where: {$0 is MBProgressHUD}) == nil else { // hud is already shown return } diff --git a/FlowCrypt/Functionality/DataManager/Encrypted Storage/EncryptedStorage.swift b/FlowCrypt/Functionality/DataManager/Encrypted Storage/EncryptedStorage.swift index 47ddcf5fb..b7d206d27 100644 --- a/FlowCrypt/Functionality/DataManager/Encrypted Storage/EncryptedStorage.swift +++ b/FlowCrypt/Functionality/DataManager/Encrypted Storage/EncryptedStorage.swift @@ -218,7 +218,7 @@ extension EncryptedStorage { try storage.write { storage.deleteAll() } - } catch { + } catch let error { assertionFailure("Error while deleting the objects from the storage \(error)") } } diff --git a/FlowCrypt/Functionality/DataManager/Encrypted Storage/KeyChainService.swift b/FlowCrypt/Functionality/DataManager/Encrypted Storage/KeyChainService.swift index 9deec38a7..775d7aef6 100644 --- a/FlowCrypt/Functionality/DataManager/Encrypted Storage/KeyChainService.swift +++ b/FlowCrypt/Functionality/DataManager/Encrypted Storage/KeyChainService.swift @@ -6,9 +6,9 @@ // Copyright © 2019 FlowCrypt Limited. All rights reserved. // -import FlowCryptCommon import Foundation import Security +import FlowCryptCommon // keychain is used to generate and retrieve encryption key which is used to encrypt local DB // it does not contain any actual data or keys other than the db encryption key diff --git a/FlowCrypt/Functionality/DataManager/Local Storage/LocalStorage.swift b/FlowCrypt/Functionality/DataManager/Local Storage/LocalStorage.swift index 228b749e9..e83f7dbf8 100644 --- a/FlowCrypt/Functionality/DataManager/Local Storage/LocalStorage.swift +++ b/FlowCrypt/Functionality/DataManager/Local Storage/LocalStorage.swift @@ -51,5 +51,6 @@ extension LocalStorage: LogOutHandler { .forEach { storage.removeObject(forKey: $0) } + } } diff --git a/FlowCrypt/Functionality/DataManager/UserAccountService.swift b/FlowCrypt/Functionality/DataManager/UserAccountService.swift index 66d06a87e..da29ca4f5 100644 --- a/FlowCrypt/Functionality/DataManager/UserAccountService.swift +++ b/FlowCrypt/Functionality/DataManager/UserAccountService.swift @@ -129,7 +129,7 @@ extension UserAccountService: UserAccountServiceType { do { try self.storages.forEach { try $0.logOutUser(email: email) } - } catch { + } catch let error { logger.logError("storage error \(error)") } } diff --git a/FlowCrypt/Functionality/Mail Provider/Backup Provider/Gmail+Backup.swift b/FlowCrypt/Functionality/Mail Provider/Backup Provider/Gmail+Backup.swift index 753b04a16..38edcffd6 100644 --- a/FlowCrypt/Functionality/Mail Provider/Backup Provider/Gmail+Backup.swift +++ b/FlowCrypt/Functionality/Mail Provider/Backup Provider/Gmail+Backup.swift @@ -6,14 +6,14 @@ // Copyright © 2020 FlowCrypt Limited. All rights reserved. // -import GoogleAPIClientForREST -import GTMSessionFetcher import Promises +import GTMSessionFetcher +import GoogleAPIClientForREST extension GmailService: BackupProvider { func searchBackups(for email: String) -> Promise { Logger.logVerbose("[GmailService] will begin searching for backups") - return Promise { resolve, _ in + return Promise { (resolve, _) in let backupSearchExpressions = GeneralConstants.EmailConstant .recoverAccountSearchSubject .map { searchExpression(using: MessageSearchContext(expression: $0)) } @@ -47,8 +47,8 @@ extension GmailService: BackupProvider { messageId: context.messageId, identifier: context.attachmentId ) - return Promise { resolve, reject in - self.gmailService.executeQuery(query) { _, data, error in + return Promise { (resolve, reject) in + self.gmailService.executeQuery(query) { (_, data, error) in if let error = error { reject(GmailServiceError.providerError(error)) return diff --git a/FlowCrypt/Functionality/Mail Provider/Imap/Imap+session.swift b/FlowCrypt/Functionality/Mail Provider/Imap/Imap+session.swift index 821d28a8e..c88eb3085 100644 --- a/FlowCrypt/Functionality/Mail Provider/Imap/Imap+session.swift +++ b/FlowCrypt/Functionality/Mail Provider/Imap/Imap+session.swift @@ -6,9 +6,9 @@ // Copyright © 2019 FlowCrypt Limited. All rights reserved. // -import FlowCryptCommon import Foundation import Promises +import FlowCryptCommon extension Imap { @@ -41,14 +41,14 @@ extension Imap { } private func logIMAPConnection(for session: MCOIMAPSession) { - session.connectionLogger = { [weak self] connectionID, type, data in + session.connectionLogger = { [weak self] (connectionID, type, data) in guard let data = data, let string = String(data: data, encoding: .utf8) else { return } self?.logger.logInfo("connection IMAP :\(type):\(string)") } } private func logSMTPConnection(for smtpSession: MCOSMTPSession) { - smtpSession.connectionLogger = { [weak self] connectionID, type, data in + smtpSession.connectionLogger = { [weak self] (connectionID, type, data) in guard let data = data, let string = String(data: data, encoding: .utf8) else { return } self?.logger.logInfo("connection SMTP:\(type):\(string)") } diff --git a/FlowCrypt/Functionality/Mail Provider/Mail Sessions Providers/SessionCredentialsProvider.swift b/FlowCrypt/Functionality/Mail Provider/Mail Sessions Providers/SessionCredentialsProvider.swift index 3ebc32d40..49538b86c 100644 --- a/FlowCrypt/Functionality/Mail Provider/Mail Sessions Providers/SessionCredentialsProvider.swift +++ b/FlowCrypt/Functionality/Mail Provider/Mail Sessions Providers/SessionCredentialsProvider.swift @@ -58,7 +58,7 @@ struct SessionCredentialsService: SessionCredentialsProvider { guard let email = email, let services = manager?.provider(forEmail: email)?.imapServices() as? [MCONetService], - let credentials = services.first(where: { $0.connectionType == MCOConnectionType(connection) }) + let credentials = services.first(where: { $0.connectionType == MCOConnectionType(connection)}) else { return error(for: connection) } @@ -79,7 +79,7 @@ struct SessionCredentialsService: SessionCredentialsProvider { guard let email = email, let services = manager?.provider(forEmail: email)?.smtpServices() as? [MCONetService], - let credentials = services.first(where: { $0.connectionType == MCOConnectionType(connection) }) + let credentials = services.first(where: { $0.connectionType == MCOConnectionType(connection)}) else { return error(for: connection) } diff --git a/FlowCrypt/Functionality/Mail Provider/Message Gateway/GmailService+send.swift b/FlowCrypt/Functionality/Mail Provider/Message Gateway/GmailService+send.swift index aaefe76de..96c494705 100644 --- a/FlowCrypt/Functionality/Mail Provider/Message Gateway/GmailService+send.swift +++ b/FlowCrypt/Functionality/Mail Provider/Message Gateway/GmailService+send.swift @@ -7,13 +7,13 @@ // import Foundation +import Promises import GoogleAPIClientForREST import GTMSessionFetcher -import Promises extension GmailService: MessageGateway { func sendMail(mime: Data) -> Promise { - Promise { resolve, reject in + Promise { (resolve, reject) in guard let raw = GTLREncodeBase64(mime) else { return reject(GmailServiceError.messageEncode) } @@ -27,7 +27,7 @@ extension GmailService: MessageGateway { uploadParameters: nil ) - self.gmailService.executeQuery(querySend) { _, _, error in + self.gmailService.executeQuery(querySend) { (_, _, error) in if let error = error { reject(GmailServiceError.providerError(error)) return diff --git a/FlowCrypt/Functionality/Mail Provider/Message Provider/Gmail+Message.swift b/FlowCrypt/Functionality/Mail Provider/Message Provider/Gmail+Message.swift index fc68f966f..c2b6f2954 100644 --- a/FlowCrypt/Functionality/Mail Provider/Message Provider/Gmail+Message.swift +++ b/FlowCrypt/Functionality/Mail Provider/Message Provider/Gmail+Message.swift @@ -6,13 +6,13 @@ // Copyright © 2020 FlowCrypt Limited. All rights reserved. // -import GoogleAPIClientForREST -import GTMSessionFetcher import Promises +import GTMSessionFetcher +import GoogleAPIClientForREST extension GmailService: MessageProvider { func fetchMsg(message: Message, folder: String) -> Promise { - return Promise { resolve, reject in + return Promise { (resolve, reject) in guard let identifier = message.identifier.stringId else { return reject(GmailServiceError.missedMessageInfo("id")) } @@ -20,7 +20,7 @@ extension GmailService: MessageProvider { let query = GTLRGmailQuery_UsersMessagesGet.query(withUserId: .me, identifier: identifier) query.format = kGTLRGmailFormatRaw - self.gmailService.executeQuery(query) { _, data, error in + self.gmailService.executeQuery(query) { (_, data, error) in if let error = error { reject(GmailServiceError.providerError(error)) return diff --git a/FlowCrypt/Functionality/Mail Provider/MessageOperations Provider/Gmail+MessageOperations.swift b/FlowCrypt/Functionality/Mail Provider/MessageOperations Provider/Gmail+MessageOperations.swift index 00b311688..4ef75048c 100644 --- a/FlowCrypt/Functionality/Mail Provider/MessageOperations Provider/Gmail+MessageOperations.swift +++ b/FlowCrypt/Functionality/Mail Provider/MessageOperations Provider/Gmail+MessageOperations.swift @@ -7,9 +7,9 @@ // import Foundation -import GoogleAPIClientForREST -import GTMSessionFetcher import Promises +import GTMSessionFetcher +import GoogleAPIClientForREST extension GmailService: MessageOperationsProvider { func markAsRead(message: Message, folder: String) -> Promise { @@ -21,7 +21,7 @@ extension GmailService: MessageOperationsProvider { } func delete(message: Message, form folderPath: String?) -> Promise { - Promise { resolve, reject in + Promise { (resolve, reject) in guard let identifier = message.identifier.stringId else { return reject(GmailServiceError.missedMessageInfo("id")) } @@ -31,7 +31,7 @@ extension GmailService: MessageOperationsProvider { identifier: identifier ) - self.gmailService.executeQuery(query) { _, _, error in + self.gmailService.executeQuery(query) { (_, _, error) in if let error = error { reject(GmailServiceError.providerError(error)) } @@ -50,7 +50,7 @@ extension GmailService: MessageOperationsProvider { } private func update(message: Message, labelsToAdd: [MessageLabelType] = [], labelsToRemove: [MessageLabelType] = []) -> Promise { - Promise { resolve, reject in + Promise { (resolve, reject) in guard let identifier = message.identifier.stringId else { return reject(GmailServiceError.missedMessageInfo("id")) } @@ -63,7 +63,7 @@ extension GmailService: MessageOperationsProvider { identifier: identifier ) - self.gmailService.executeQuery(query) { _, _, error in + self.gmailService.executeQuery(query) { (_, _, error) in if let error = error { reject(GmailServiceError.providerError(error)) } diff --git a/FlowCrypt/Functionality/Mail Provider/MessageOperations Provider/Imap+MessageOperations.swift b/FlowCrypt/Functionality/Mail Provider/MessageOperations Provider/Imap+MessageOperations.swift index 86448a5ce..8e9e225ad 100644 --- a/FlowCrypt/Functionality/Mail Provider/MessageOperations Provider/Imap+MessageOperations.swift +++ b/FlowCrypt/Functionality/Mail Provider/MessageOperations Provider/Imap+MessageOperations.swift @@ -41,7 +41,7 @@ extension Imap: MessageOperationsProvider { // MARK: - trash func moveMessageToTrash(message: Message, trashPath: String?, from folder: String) -> Promise { - return Promise { [weak self] resolve, reject in + return Promise { [weak self] (resolve, reject) in guard let self = self else { return reject(AppErr.nilSelf) } guard let identifier = message.identifier.intId else { @@ -69,7 +69,7 @@ extension Imap: MessageOperationsProvider { // MARK: - delete func delete(message: Message, form folderPath: String?) -> Promise { - return Promise { [weak self] _, reject in + return Promise { [weak self] (_, reject) in guard let self = self else { return reject(AppErr.nilSelf) } guard let identifier = message.identifier.intId else { @@ -113,7 +113,7 @@ extension Imap: MessageOperationsProvider { // MARK: - archive func archiveMessage(message: Message, folderPath: String) -> Promise { - return Promise { [weak self] _, reject in + return Promise { [weak self] (_, reject) in guard let self = self else { return reject(AppErr.nilSelf) } guard let identifier = message.identifier.intId else { diff --git a/FlowCrypt/Functionality/Mail Provider/MessagesList Provider/Gmail+MessagesList.swift b/FlowCrypt/Functionality/Mail Provider/MessagesList Provider/Gmail+MessagesList.swift index a69b08b59..0dabf78fb 100644 --- a/FlowCrypt/Functionality/Mail Provider/MessagesList Provider/Gmail+MessagesList.swift +++ b/FlowCrypt/Functionality/Mail Provider/MessagesList Provider/Gmail+MessagesList.swift @@ -6,14 +6,14 @@ // Copyright © 2020 FlowCrypt Limited. All rights reserved. // -import FlowCryptCommon -import GoogleAPIClientForREST -import GTMSessionFetcher import Promises +import GTMSessionFetcher +import GoogleAPIClientForREST +import FlowCryptCommon extension GmailService: MessagesListProvider { func fetchMessages(using context: FetchMessageContext) -> Promise { - Promise { resolve, reject in + Promise { (resolve, reject) in let list = try awaitPromise(fetchMessagesList(using: context)) let messageRequests: [Promise] = list.messages?.compactMap(\.identifier).map(fetchFullMessage(with:)) ?? [] @@ -50,8 +50,8 @@ extension GmailService { query.q = searchQuery } - return Promise { resolve, reject in - self.gmailService.executeQuery(query) { _, data, error in + return Promise { (resolve, reject) in + self.gmailService.executeQuery(query) { (_, data, error) in if let error = error { reject(GmailServiceError.providerError(error)) return @@ -69,8 +69,8 @@ extension GmailService { private func fetchFullMessage(with identifier: String) -> Promise { let query = GTLRGmailQuery_UsersMessagesGet.query(withUserId: .me, identifier: identifier) query.format = kGTLRGmailFormatFull - return Promise { resolve, reject in - self.gmailService.executeQuery(query) { _, data, error in + return Promise { (resolve, reject) in + self.gmailService.executeQuery(query) { (_, data, error) in if let error = error { reject(GmailServiceError.providerError(error)) return diff --git a/FlowCrypt/Functionality/Mail Provider/MessagesList Provider/Model/Message.swift b/FlowCrypt/Functionality/Mail Provider/MessagesList Provider/Model/Message.swift index b7bc228c5..1a19c4e71 100644 --- a/FlowCrypt/Functionality/Mail Provider/MessagesList Provider/Model/Message.swift +++ b/FlowCrypt/Functionality/Mail Provider/MessagesList Provider/Model/Message.swift @@ -6,8 +6,8 @@ // Copyright © 2020 FlowCrypt Limited. All rights reserved. // -import FlowCryptCommon import Foundation +import FlowCryptCommon import GoogleAPIClientForREST struct Message: Hashable { diff --git a/FlowCrypt/Functionality/Mail Provider/MessagesList Provider/Model/MessageLabel.swift b/FlowCrypt/Functionality/Mail Provider/MessagesList Provider/Model/MessageLabel.swift index aff11ca6e..199ee8976 100644 --- a/FlowCrypt/Functionality/Mail Provider/MessagesList Provider/Model/MessageLabel.swift +++ b/FlowCrypt/Functionality/Mail Provider/MessagesList Provider/Model/MessageLabel.swift @@ -100,7 +100,7 @@ extension MessageLabelType { init(gmailLabel: String) { let types: [MessageLabelType] = [.seen, .unread, .starred, .sent, .trash, .draft, .important] let all = types.map { type in - (type, type.value) + return (type, type.value) } guard let label = all.first(where: { $0.1 == gmailLabel })?.0 else { self = .label(gmailLabel) diff --git a/FlowCrypt/Functionality/Mail Provider/SearchMessage Provider/Gmail+Search.swift b/FlowCrypt/Functionality/Mail Provider/SearchMessage Provider/Gmail+Search.swift index b318ade2c..b9b6100fb 100644 --- a/FlowCrypt/Functionality/Mail Provider/SearchMessage Provider/Gmail+Search.swift +++ b/FlowCrypt/Functionality/Mail Provider/SearchMessage Provider/Gmail+Search.swift @@ -6,13 +6,13 @@ // Copyright © 2020 FlowCrypt Limited. All rights reserved. // -import GoogleAPIClientForREST -import GTMSessionFetcher import Promises +import GTMSessionFetcher +import GoogleAPIClientForREST extension GmailService: MessageSearchProvider { func searchExpression(using context: MessageSearchContext) -> Promise<[Message]> { - Promise { resolve, _ in + Promise { (resolve, _) in let context = try awaitPromise(self.fetchMessages(using: FetchMessageContext(searchContext: context))) resolve(context.messages) } diff --git a/FlowCrypt/Functionality/Migration/DBMigrationService.swift b/FlowCrypt/Functionality/Migration/DBMigrationService.swift index 506f5a615..b869bf1b1 100644 --- a/FlowCrypt/Functionality/Migration/DBMigrationService.swift +++ b/FlowCrypt/Functionality/Migration/DBMigrationService.swift @@ -53,7 +53,7 @@ extension DBMigrationService { try storage.write { storage.delete(folders) } - } catch { + } catch let error { logger.logWarning("Can't perform Gmail Api migration \(error)") assertionFailure("Can't perform Gmail Api migration \(error)") } diff --git a/FlowCrypt/Functionality/Services/Backup Services/BackupService.swift b/FlowCrypt/Functionality/Services/Backup Services/BackupService.swift index 9ce28e1fe..4e835f82a 100644 --- a/FlowCrypt/Functionality/Services/Backup Services/BackupService.swift +++ b/FlowCrypt/Functionality/Services/Backup Services/BackupService.swift @@ -6,8 +6,8 @@ // Copyright © 2020 FlowCrypt Limited. All rights reserved. // -import Promises import UIKit +import Promises protocol BackupServiceType { /// get all existed backups @@ -89,7 +89,7 @@ extension BackupService: BackupServiceType { } // MARK: - Helpers -private extension String { +fileprivate extension String { var userReadableEmail: String { self.replacingOccurrences( of: "[^a-z0-9]", @@ -99,7 +99,7 @@ private extension String { } } -private extension UserId { +fileprivate extension UserId { var toMime: String { "\(name) <\(email)>" } diff --git a/FlowCrypt/Functionality/Services/Contacts Services/ContactsService.swift b/FlowCrypt/Functionality/Services/Contacts Services/ContactsService.swift index f270faeaa..b956fc604 100644 --- a/FlowCrypt/Functionality/Services/Contacts Services/ContactsService.swift +++ b/FlowCrypt/Functionality/Services/Contacts Services/ContactsService.swift @@ -15,6 +15,7 @@ enum ContactsError: Error { } protocol ContactsServiceType: PublicKeyProvider, ContactsProviderType { + } protocol PublicKeyProvider { diff --git a/FlowCrypt/Functionality/Services/Contacts Services/RemoteContactsProvider.swift b/FlowCrypt/Functionality/Services/Contacts Services/RemoteContactsProvider.swift index 38d1253a4..29c52c786 100644 --- a/FlowCrypt/Functionality/Services/Contacts Services/RemoteContactsProvider.swift +++ b/FlowCrypt/Functionality/Services/Contacts Services/RemoteContactsProvider.swift @@ -65,7 +65,7 @@ extension RemoteContactsProvider: ContactsProviderType { algo: keyDetail.algo ) return Promise(contact) - } catch { + } catch let error { let message = "Armored or binary are not parsed.\n\(error.localizedDescription)" return Promise(ContactsError.unexpected(message)) } diff --git a/FlowCrypt/Functionality/Services/Folders Services/RemoteFoldersProviderType/GmailService+folders.swift b/FlowCrypt/Functionality/Services/Folders Services/RemoteFoldersProviderType/GmailService+folders.swift index d91c488ef..f52efad8f 100644 --- a/FlowCrypt/Functionality/Services/Folders Services/RemoteFoldersProviderType/GmailService+folders.swift +++ b/FlowCrypt/Functionality/Services/Folders Services/RemoteFoldersProviderType/GmailService+folders.swift @@ -7,16 +7,16 @@ // import Foundation -import GoogleAPIClientForREST -import GTMSessionFetcher import Promises +import GTMSessionFetcher +import GoogleAPIClientForREST extension GmailService: RemoteFoldersProviderType { func fetchFolders() -> Promise<[FolderObject]> { - Promise { resolve, reject in + Promise { (resolve, reject) in let query = GTLRGmailQuery_UsersLabelsList.query(withUserId: .me) - self.gmailService.executeQuery(query) { _, data, error in + self.gmailService.executeQuery(query) { (_, data, error) in if let error = error { reject(GmailServiceError.providerError(error)) return diff --git a/FlowCrypt/Functionality/Services/Folders Services/TrashFolderProvider.swift b/FlowCrypt/Functionality/Services/Folders Services/TrashFolderProvider.swift index 4dd6b1ad2..e067398d3 100644 --- a/FlowCrypt/Functionality/Services/Folders Services/TrashFolderProvider.swift +++ b/FlowCrypt/Functionality/Services/Folders Services/TrashFolderProvider.swift @@ -26,7 +26,7 @@ extension TrashFolderProvider: TrashFolderProviderType { if let path = localStorage.trashFolderPath { return Promise(path) } else { - return Promise { resolve, _ in + return Promise { (resolve, _) in // will get all folders _ = try awaitPromise(folderProvider.fetchFolders()) resolve(localStorage.trashFolderPath) diff --git a/FlowCrypt/Functionality/Services/GlobalRouter.swift b/FlowCrypt/Functionality/Services/GlobalRouter.swift index 55d8ff3d5..88519fc2c 100644 --- a/FlowCrypt/Functionality/Services/GlobalRouter.swift +++ b/FlowCrypt/Functionality/Services/GlobalRouter.swift @@ -6,8 +6,8 @@ // Copyright © 2019 FlowCrypt Limited. All rights reserved. // -import Promises import UIKit +import Promises protocol GlobalRouterType { func proceed() diff --git a/FlowCrypt/Functionality/Services/GoogleUserService.swift b/FlowCrypt/Functionality/Services/GoogleUserService.swift index 9c9c2a737..451723173 100644 --- a/FlowCrypt/Functionality/Services/GoogleUserService.swift +++ b/FlowCrypt/Functionality/Services/GoogleUserService.swift @@ -6,11 +6,11 @@ // Copyright © 2019 FlowCrypt Limited. All rights reserved. // -import AppAuth import Foundation -import GTMAppAuth import Promises import RealmSwift +import AppAuth +import GTMAppAuth protocol UserServiceType { func signOut(user email: String) @@ -59,7 +59,7 @@ extension GoogleUserService: UserServiceType { func renewSession() -> Promise { // GTMAppAuth should renew session via OIDAuthStateChangeDelegate - Promise { [weak self] resolve, _ in + Promise { [weak self] (resolve, _) in self?.logger.logInfo("Renew session for google user") resolve(()) } @@ -74,7 +74,7 @@ extension GoogleUserService: UserServiceType { let googleAuthSession = OIDAuthState.authState( byPresenting: request, presenting: viewController - ) { authState, error in + ) { (authState, error) in if let authState = authState { let authorization = GTMAppAuthFetcherAuthorization(authState: authState) guard let email = authorization.userEmail else { @@ -165,12 +165,12 @@ extension GoogleUserService { fetcherService.authorizer = authorization fetcherService.fetcher(with: userInfoEndpoint) - .beginFetch { data, error in + .beginFetch { (data, error) in if let data = data { do { let user = try JSONDecoder().decode(GoogleUser.self, from: data) completion(.success(user)) - } catch { + } catch let error { completion(.failure(.parsingError(error))) } } else if let error = error { diff --git a/FlowCryptCommon/Extensions/CollectionExtensions.swift b/FlowCryptCommon/Extensions/CollectionExtensions.swift index a7da04acd..669022218 100644 --- a/FlowCryptCommon/Extensions/CollectionExtensions.swift +++ b/FlowCryptCommon/Extensions/CollectionExtensions.swift @@ -47,7 +47,7 @@ public extension Array where Element == String { } func containsCaseInsensitive(_ stringToCompare: String) -> Bool { - contains(where: { $0.caseInsensitiveCompare(stringToCompare) == .orderedSame } ) + contains(where: { $0.caseInsensitiveCompare(stringToCompare) == .orderedSame} ) } } diff --git a/FlowCryptCommon/Extensions/Either.swift b/FlowCryptCommon/Extensions/Either.swift index 523c78955..dae2da180 100644 --- a/FlowCryptCommon/Extensions/Either.swift +++ b/FlowCryptCommon/Extensions/Either.swift @@ -8,7 +8,7 @@ import Foundation -public enum Either { +public enum Either{ case left(A) case right(B) } diff --git a/FlowCryptCommon/Extensions/StringExtensions.swift b/FlowCryptCommon/Extensions/StringExtensions.swift index dde16106a..2ddd6a890 100644 --- a/FlowCryptCommon/Extensions/StringExtensions.swift +++ b/FlowCryptCommon/Extensions/StringExtensions.swift @@ -26,7 +26,7 @@ public extension String { ) -> String { String( self.enumerated() - .map { $0 > 0 && $0 % stride == 0 ? [separator, $1] : [$1] } + .map { $0 > 0 && $0 % stride == 0 ? [separator, $1] : [$1]} .joined() ) } diff --git a/FlowCryptCommon/Trace.swift b/FlowCryptCommon/Trace.swift index d4ffc436b..f82f828b3 100644 --- a/FlowCryptCommon/Trace.swift +++ b/FlowCryptCommon/Trace.swift @@ -6,8 +6,8 @@ // Copyright © 2021 FlowCrypt Limited. All rights reserved. // -import CoreFoundation import Foundation +import CoreFoundation public final class Trace { private let id: String diff --git a/FlowCryptTests/ExtensionTests.swift b/FlowCryptTests/ExtensionTests.swift index c34d9847b..60ebda442 100644 --- a/FlowCryptTests/ExtensionTests.swift +++ b/FlowCryptTests/ExtensionTests.swift @@ -37,8 +37,8 @@ extension ExtensionTests { let someEmptyCollection: [String] = [] let nonEmptyCollection = [1, 2, 3] - XCTAssert(someEmptyCollection.isEmpty) - XCTAssert(!nonEmptyCollection.isEmpty) + XCTAssert(someEmptyCollection.count == 0) + XCTAssert(nonEmptyCollection.count != 0) } func test_safe_subscript() { diff --git a/FlowCryptUI/Cell Nodes/CheckBoxTextNode.swift b/FlowCryptUI/Cell Nodes/CheckBoxTextNode.swift index d165155cd..fde2887a3 100644 --- a/FlowCryptUI/Cell Nodes/CheckBoxTextNode.swift +++ b/FlowCryptUI/Cell Nodes/CheckBoxTextNode.swift @@ -80,7 +80,7 @@ public final class CheckBoxTextNode: CellNode { children: [checkBox, textStack] ) - return ASInsetLayoutSpec( + return ASInsetLayoutSpec( insets: input.insets, child: stack ) @@ -93,7 +93,7 @@ public final class CheckBoxTextNode: CellNode { children: [checkBox, textNode] ) - return ASInsetLayoutSpec( + return ASInsetLayoutSpec( insets: input.insets, child: stack ) diff --git a/FlowCryptUI/Cell Nodes/ContactDetailNode.swift b/FlowCryptUI/Cell Nodes/ContactDetailNode.swift index 90974325b..d996bd9b7 100644 --- a/FlowCryptUI/Cell Nodes/ContactDetailNode.swift +++ b/FlowCryptUI/Cell Nodes/ContactDetailNode.swift @@ -16,13 +16,14 @@ public final class ContactDetailNode: CellNode { let algoInfo: NSAttributedString? let created: NSAttributedString? + public init( user: NSAttributedString, ids: NSAttributedString, fingerprints: NSAttributedString, algoInfo: NSAttributedString?, created: NSAttributedString? - ) { + ){ self.user = user self.ids = ids self.fingerprints = fingerprints diff --git a/FlowCryptUI/Cell Nodes/InfoCellNode.swift b/FlowCryptUI/Cell Nodes/InfoCellNode.swift index 0956e48f7..99ac732a0 100644 --- a/FlowCryptUI/Cell Nodes/InfoCellNode.swift +++ b/FlowCryptUI/Cell Nodes/InfoCellNode.swift @@ -40,7 +40,7 @@ public final class InfoCellNode: CellNode { self.imageNode.image = input?.image self.automaticallyManagesSubnodes = true - if let backgroundColor = input?.backgroundColor { + if let backgroundColor = input?.backgroundColor{ self.backgroundColor = backgroundColor } } diff --git a/FlowCryptUI/Cell Nodes/RecipientEmailNode.swift b/FlowCryptUI/Cell Nodes/RecipientEmailNode.swift index de84b6597..475a549b0 100644 --- a/FlowCryptUI/Cell Nodes/RecipientEmailNode.swift +++ b/FlowCryptUI/Cell Nodes/RecipientEmailNode.swift @@ -76,7 +76,7 @@ final class RecipientEmailNode: CellNode { imageNode.alpha = 1 let animation = CABasicAnimation(keyPath: "transform.rotation") animation.fromValue = 0 - animation.toValue = Double.pi * 2.0 + animation.toValue = Double.pi * 2.0 animation.duration = 2 animation.repeatCount = .infinity animation.isRemovedOnCompletion = false @@ -89,7 +89,7 @@ final class RecipientEmailNode: CellNode { imageNode.alpha = 1 let animation = CABasicAnimation(keyPath: "transform.scale") animation.fromValue = 0.9 - animation.toValue = 1.0 + animation.toValue = 1.0 animation.duration = 0.5 animation.repeatCount = 1 animation.isRemovedOnCompletion = false diff --git a/FlowCryptUI/Cell Nodes/SwitchCellNode.swift b/FlowCryptUI/Cell Nodes/SwitchCellNode.swift index 7d2ce5646..119e27d32 100644 --- a/FlowCryptUI/Cell Nodes/SwitchCellNode.swift +++ b/FlowCryptUI/Cell Nodes/SwitchCellNode.swift @@ -51,9 +51,10 @@ public final class SwitchCellNode: CellNode { self.textNode.attributedText = input?.attributedText self.automaticallyManagesSubnodes = true - if let backgroundColor = input?.backgroundColor { + if let backgroundColor = input?.backgroundColor{ self.backgroundColor = backgroundColor } + } @objc private func handleAction(_ sender: UISwitch) { diff --git a/FlowCryptUI/Nodes/TextFieldNode.swift b/FlowCryptUI/Nodes/TextFieldNode.swift index 75a3ba883..04b044273 100644 --- a/FlowCryptUI/Nodes/TextFieldNode.swift +++ b/FlowCryptUI/Nodes/TextFieldNode.swift @@ -240,3 +240,5 @@ extension TextFieldNode { onToolbarDoneAction?() } } + + diff --git a/FlowCryptUI/Views/NavigationBarItemsView.swift b/FlowCryptUI/Views/NavigationBarItemsView.swift index a9f31110f..89aed61fa 100644 --- a/FlowCryptUI/Views/NavigationBarItemsView.swift +++ b/FlowCryptUI/Views/NavigationBarItemsView.swift @@ -52,7 +52,6 @@ public final class NavigationBarItemsView: UIBarButtonItem { } } - @available(*, unavailable) required init?(coder _: NSCoder) { fatalError("init(coder:) has not been implemented") } diff --git a/FlowCryptUIApplication/ViewController.swift b/FlowCryptUIApplication/ViewController.swift index 18c4b9f1b..d8c15c172 100644 --- a/FlowCryptUIApplication/ViewController.swift +++ b/FlowCryptUIApplication/ViewController.swift @@ -27,7 +27,6 @@ final class ViewController: TableNodeViewController { super.init(node: TableNode()) } - @available(*, unavailable) required init?(coder _: NSCoder) { fatalError("init(coder:) has not been implemented") } @@ -239,3 +238,4 @@ extension ViewController { textField?.reset() } } + diff --git a/FlowCryptUITests/SignInGoogleTest.swift b/FlowCryptUITests/SignInGoogleTest.swift index f05e1fcb8..061118372 100644 --- a/FlowCryptUITests/SignInGoogleTest.swift +++ b/FlowCryptUITests/SignInGoogleTest.swift @@ -78,6 +78,7 @@ class SignInGoogleTest: XCTestCase, AppTest { textField.tap() + textField.typeText(user.email) let returnButton = goKeyboardButton XCTAssert(returnButton.exists, "User keyboard button") @@ -97,6 +98,7 @@ class SignInGoogleTest: XCTestCase, AppTest { XCTAssert(app.tables.firstMatch.exists, "Table does not exist") + // MARK: - Wrong pass phrase // enter wrong pass phrase and tap enter let button = goKeyboardButton @@ -111,6 +113,7 @@ class SignInGoogleTest: XCTestCase, AppTest { wait(0.2) app.tables.secureTextFields.firstMatch.tap() + // MARK: - Correct pass phrase // enter correct pass phrase and tap enter if button.exists { diff --git a/FlowCryptUITests/SignInTest.swift b/FlowCryptUITests/SignInTest.swift index 0284e0b6c..899cebb06 100644 --- a/FlowCryptUITests/SignInTest.swift +++ b/FlowCryptUITests/SignInTest.swift @@ -208,7 +208,7 @@ extension SignInTest { app.tables .staticTexts .allElementsBoundByIndex - .first(where: { $0.label.contains("Sent" ) })? + .first(where: { $0.label.contains("Sent" )})? .tap() wait(3) @@ -282,6 +282,8 @@ extension SignInTest { } } + + /* log in -> approve -> no backups -> generate pubkey -> switch accounts */ diff --git a/Scripts/format.sh b/Scripts/format.sh index 6ce9ce41f..7c5f4e65e 100755 --- a/Scripts/format.sh +++ b/Scripts/format.sh @@ -7,15 +7,10 @@ fi # Do not run format if swiftlint isn't installed if which swiftformat >/dev/null; then - echo "Start formatting" + echo "Start formating" swiftlint autocorrect --path . swiftformat . \ - --rules trailingSpace, blankLinesAtEndOfScope, consecutiveBlankLines, consecutiveSpaces, \ - duplicateImports, initCoderUnavailable, isEmpty, leadingDelimiters, preferKeyPath, redundantBreak, \ - redundantExtensionACL, redundantFileprivate, redundantGet, redundantLet, redundantLetError, \ - redundantNilInit, redundantParens, redundantPattern, redundantReturn, redundantVoidReturnType, semicolons, \ - sortedImports, spaceAroundBraces, spaceAroundBrackets, spaceAroundGenerics, spaceInsideBraces, spaceInsideGenerics, \ - strongifiedSelf, trailingClosures, void, wrapArguments --wraparguments, + --rules trailingSpace \ --swiftversion 5 else echo "warning: SwiftFormat not installed, download from https://github.com/nicklockwood/SwiftFormat" diff --git a/fastlane/SnapshotHelper.swift b/fastlane/SnapshotHelper.swift index cd94bc1f9..aaa2a9a92 100644 --- a/fastlane/SnapshotHelper.swift +++ b/fastlane/SnapshotHelper.swift @@ -80,7 +80,7 @@ open class Snapshot: NSObject { setLanguage(app) setLocale(app) setLaunchArguments(app) - } catch { + } catch let error { NSLog(error.localizedDescription) } } @@ -184,7 +184,7 @@ open class Snapshot: NSObject { let path = screenshotsDir.appendingPathComponent("\(simulator)-\(name).png") try screenshot.pngRepresentation.write(to: path) - } catch { + } catch let error { NSLog("Problem writing screenshot: \(name) to \(screenshotsDir)/\(simulator)-\(name).png") NSLog(error.localizedDescription) } @@ -266,7 +266,7 @@ private extension XCUIElementAttributes { private extension XCUIElementQuery { var networkLoadingIndicators: XCUIElementQuery { - let isNetworkLoadingIndicator = NSPredicate { evaluatedObject, _ in + let isNetworkLoadingIndicator = NSPredicate { (evaluatedObject, _) in guard let element = evaluatedObject as? XCUIElementAttributes else { return false } return element.isNetworkLoadingIndicator @@ -282,7 +282,7 @@ private extension XCUIElementQuery { let deviceWidth = app.windows.firstMatch.frame.width - let isStatusBar = NSPredicate { evaluatedObject, _ in + let isStatusBar = NSPredicate { (evaluatedObject, _) in guard let element = evaluatedObject as? XCUIElementAttributes else { return false } return element.isStatusBar(deviceWidth)