From 29c4410627932d24dd9189b3f5ed81cf8ffef6c1 Mon Sep 17 00:00:00 2001 From: Anton Kharchevskyi Date: Tue, 11 May 2021 23:31:21 +0300 Subject: [PATCH] Add format rules --- FlowCrypt/App/Logger.swift | 6 +++--- FlowCrypt/AppDelegate.swift | 2 +- .../SegmentedViewController.swift | 1 + .../View Controllers/WebViewController.swift | 1 + .../Compose/ComposeViewController.swift | 1 + .../EnterPassPhraseViewController.swift | 1 + .../Import Key/ImportKeyViewController.swift | 1 + .../Container/InboxViewControllerContainer.swift | 3 ++- .../InboxViewControllerContainerDecorator.swift | 2 +- .../Controllers/Inbox/InboxViewController.swift | 1 + .../Controllers/Msg/MessageViewController.swift | 3 ++- .../Search/SearchViewController.swift | 1 + .../BackupOptionsViewController.swift | 3 ++- .../BackupOptionsViewDecorator.swift | 4 ++-- .../Backups Scene/BackupViewController.swift | 3 ++- .../BackupSelectKeyDecorator.swift | 6 +++--- .../BackupSelectKeyViewController.swift | 5 +++-- .../Contacts List/ContactDetailDecorator.swift | 2 +- .../ContactDetailViewController.swift | 1 + .../Contacts List/ContactsListDecorator.swift | 2 +- .../ContactsListViewController.swift | 3 ++- .../Settings/KeyLegal/LegalViewController.swift | 1 + .../KeyDetailInfoViewController.swift | 1 + .../Key Details/KeyDetailViewController.swift | 1 + .../Key List/KeySettingsViewController.swift | 1 + .../Key List/KeySettingsViewDecorator.swift | 2 +- .../PublicKeyDetailViewController.swift | 3 ++- .../Settings List/SettingsViewController.swift | 1 + .../Controllers/Setup/SetupViewController.swift | 1 + .../SideMenu/Menu/MyMenuViewController.swift | 2 +- .../SideMenu/Menu/MyMenuViewDecorator.swift | 2 +- .../EmailProviderViewController.swift | 2 +- .../EmailProviderViewDecorator.swift | 2 +- .../SignIn/SignInViewController.swift | 1 + FlowCrypt/Core/Core.swift | 2 +- FlowCrypt/Core/CoreHost.swift | 2 +- FlowCrypt/Core/Models/CoreTypesTest.swift | 3 +-- FlowCrypt/Core/Models/KeyDetails.swift | 2 +- .../Extensions/UIViewControllerExtensions.swift | 2 +- .../Encrypted Storage/EncryptedStorage.swift | 2 +- .../Encrypted Storage/KeyChainService.swift | 2 +- .../DataManager/Local Storage/LocalStorage.swift | 1 - .../DataManager/UserAccountService.swift | 2 +- .../Backup Provider/Gmail+Backup.swift | 10 +++++----- .../Mail Provider/Imap/Imap+session.swift | 6 +++--- .../SessionCredentialsProvider.swift | 4 ++-- .../Message Gateway/GmailService+send.swift | 6 +++--- .../Message Provider/Gmail+Message.swift | 8 ++++---- .../Gmail+MessageOperations.swift | 12 ++++++------ .../Imap+MessageOperations.swift | 6 +++--- .../Gmail+MessagesList.swift | 16 ++++++++-------- .../MessagesList Provider/Model/Message.swift | 2 +- .../Model/MessageLabel.swift | 2 +- .../SearchMessage Provider/Gmail+Search.swift | 6 +++--- .../Migration/DBMigrationService.swift | 2 +- .../Services/Backup Services/BackupService.swift | 6 +++--- .../Contacts Services/ContactsService.swift | 1 - .../RemoteContactsProvider.swift | 2 +- .../GmailService+folders.swift | 8 ++++---- .../Folders Services/TrashFolderProvider.swift | 2 +- .../Functionality/Services/GlobalRouter.swift | 2 +- .../Services/GoogleUserService.swift | 12 ++++++------ .../Extensions/CollectionExtensions.swift | 2 +- FlowCryptCommon/Extensions/Either.swift | 2 +- .../Extensions/StringExtensions.swift | 2 +- FlowCryptCommon/Trace.swift | 2 +- FlowCryptTests/ExtensionTests.swift | 4 ++-- FlowCryptUI/Cell Nodes/CheckBoxTextNode.swift | 4 ++-- FlowCryptUI/Cell Nodes/ContactDetailNode.swift | 3 +-- FlowCryptUI/Cell Nodes/InfoCellNode.swift | 2 +- FlowCryptUI/Cell Nodes/RecipientEmailNode.swift | 4 ++-- FlowCryptUI/Cell Nodes/SwitchCellNode.swift | 3 +-- FlowCryptUI/Nodes/TextFieldNode.swift | 2 -- FlowCryptUI/Views/NavigationBarItemsView.swift | 1 + FlowCryptUIApplication/ViewController.swift | 2 +- FlowCryptUITests/SignInGoogleTest.swift | 3 --- FlowCryptUITests/SignInTest.swift | 4 +--- Scripts/format.sh | 9 +++++++-- fastlane/SnapshotHelper.swift | 8 ++++---- 79 files changed, 138 insertions(+), 122 deletions(-) diff --git a/FlowCrypt/App/Logger.swift b/FlowCrypt/App/Logger.swift index 36d97940a..bee940c46 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.init(describing: type))]") + Logger(config: .default, label: "[\(String(describing: type))]") } static func nested(in type: T.Type, with label: String) -> Logger { var message = "[\(label)]" - message.append("[\(String.init(describing: type))]") + message.append("[\(String(describing: type))]") return Logger(config: .default, label: message) } } diff --git a/FlowCrypt/AppDelegate.swift b/FlowCrypt/AppDelegate.swift index 7eb97c628..8a96beb0a 100644 --- a/FlowCrypt/AppDelegate.swift +++ b/FlowCrypt/AppDelegate.swift @@ -3,8 +3,8 @@ // FlowCrypt // -import UIKit import AppAuth +import UIKit 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 9040837a0..5a9f24ae5 100644 --- a/FlowCrypt/Common UI/View Controllers/SegmentedViewController.swift +++ b/FlowCrypt/Common UI/View Controllers/SegmentedViewController.swift @@ -47,6 +47,7 @@ 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 482593dd3..c33fc7891 100644 --- a/FlowCrypt/Common UI/View Controllers/WebViewController.swift +++ b/FlowCrypt/Common UI/View Controllers/WebViewController.swift @@ -19,6 +19,7 @@ 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 ac79ef83b..1474b7b3f 100644 --- a/FlowCrypt/Controllers/Compose/ComposeViewController.swift +++ b/FlowCrypt/Controllers/Compose/ComposeViewController.swift @@ -89,6 +89,7 @@ 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 c27276db6..a00edbd9d 100644 --- a/FlowCrypt/Controllers/ImportKey/Enter Pass Phrase/EnterPassPhraseViewController.swift +++ b/FlowCrypt/Controllers/ImportKey/Enter Pass Phrase/EnterPassPhraseViewController.swift @@ -47,6 +47,7 @@ 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 96ad60e18..43d90c63c 100644 --- a/FlowCrypt/Controllers/ImportKey/Import Key/ImportKeyViewController.swift +++ b/FlowCrypt/Controllers/ImportKey/Import Key/ImportKeyViewController.swift @@ -41,6 +41,7 @@ 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 6390f0196..223d0b114 100644 --- a/FlowCrypt/Controllers/Inbox/Container/InboxViewControllerContainer.swift +++ b/FlowCrypt/Controllers/Inbox/Container/InboxViewControllerContainer.swift @@ -7,8 +7,8 @@ // import AsyncDisplayKit -import FlowCryptUI import FlowCryptCommon +import FlowCryptUI // MARK: - InboxViewControllerContainer // Used to fetch folders and get correct path for "inbox" folder @@ -45,6 +45,7 @@ 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 fbff051e2..479e4ff4e 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 UIKit import FlowCryptUI +import UIKit struct InboxViewControllerContainerDecorator { func emptyFoldersInput(with size: CGSize) -> TextCellNode.Input { diff --git a/FlowCrypt/Controllers/Inbox/InboxViewController.swift b/FlowCrypt/Controllers/Inbox/InboxViewController.swift index c07bac307..d6d56067c 100644 --- a/FlowCrypt/Controllers/Inbox/InboxViewController.swift +++ b/FlowCrypt/Controllers/Inbox/InboxViewController.swift @@ -77,6 +77,7 @@ 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 202997b7b..479d649be 100644 --- a/FlowCrypt/Controllers/Msg/MessageViewController.swift +++ b/FlowCrypt/Controllers/Msg/MessageViewController.swift @@ -83,6 +83,7 @@ final class MessageViewController: TableNodeViewController { super.init(node: TableNode()) } + @available(*, unavailable) required init?(coder _: NSCoder) { fatalError("init(coder:) has not been implemented") } @@ -281,7 +282,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 02c516367..ed9b745ec 100644 --- a/FlowCrypt/Controllers/Search/SearchViewController.swift +++ b/FlowCrypt/Controllers/Search/SearchViewController.swift @@ -48,6 +48,7 @@ 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 52d23235f..fb9a5a643 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 FlowCryptUI import AsyncDisplayKit +import FlowCryptUI enum BackupOption: Int, CaseIterable, Equatable { case email, download @@ -47,6 +47,7 @@ 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 5e15328f2..262277646 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 UIKit import FlowCryptUI +import UIKit protocol BackupOptionsViewDecoratorType { var sceneTitle: String { get } @@ -62,7 +62,7 @@ struct BackupOptionsViewDecorator: BackupOptionsViewDecoratorType { ? .main : .lightGray - return CheckBoxTextNode.Input.init( + return CheckBoxTextNode.Input( 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 6860bdee2..a32368891 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 FlowCryptUI import AsyncDisplayKit +import FlowCryptUI final class BackupViewController: ASDKViewController { private enum Parts: Int, CaseIterable { @@ -50,6 +50,7 @@ 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 4547d9776..35eb1b7cc 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 UIKit -import FlowCryptUI import FlowCryptCommon +import FlowCryptUI +import UIKit protocol BackupSelectKeyDecoratorType { var sceneTitle: String { get } @@ -37,7 +37,7 @@ struct BackupSelectKeyDecorator: BackupSelectKeyDecoratorType { ? .main : .lightGray - return CheckBoxTextNode.Input.init( + return CheckBoxTextNode.Input( 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 878f85c30..b3c4fe98b 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 Foundation -import FlowCryptUI import AsyncDisplayKit +import FlowCryptUI +import Foundation final class BackupSelectKeyViewController: ASDKViewController { private let backupService: BackupServiceType @@ -34,6 +34,7 @@ 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 7de7871aa..1a02af594 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 Foundation import FlowCryptUI +import Foundation 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 c5eb4c53c..b9a0b6f89 100644 --- a/FlowCrypt/Controllers/Settings/Contacts/Contacts List/ContactDetailViewController.swift +++ b/FlowCrypt/Controllers/Settings/Contacts/Contacts List/ContactDetailViewController.swift @@ -31,6 +31,7 @@ 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 645428be0..3be4721ac 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 UIKit import FlowCryptUI +import UIKit 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 08dbf682b..5eccbf0c6 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,6 +24,7 @@ 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 e395201cd..e4c1c85e9 100644 --- a/FlowCrypt/Controllers/Settings/KeyLegal/LegalViewController.swift +++ b/FlowCrypt/Controllers/Settings/KeyLegal/LegalViewController.swift @@ -21,6 +21,7 @@ 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 137478c63..db5a8fce9 100644 --- a/FlowCrypt/Controllers/Settings/KeySettings/Key Detail Info/KeyDetailInfoViewController.swift +++ b/FlowCrypt/Controllers/Settings/KeySettings/Key Detail Info/KeyDetailInfoViewController.swift @@ -31,6 +31,7 @@ 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 a81afe14e..6a171c61d 100644 --- a/FlowCrypt/Controllers/Settings/KeySettings/Key Details/KeyDetailViewController.swift +++ b/FlowCrypt/Controllers/Settings/KeySettings/Key Details/KeyDetailViewController.swift @@ -29,6 +29,7 @@ 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 06904fda2..6be74e2e3 100644 --- a/FlowCrypt/Controllers/Settings/KeySettings/Key List/KeySettingsViewController.swift +++ b/FlowCrypt/Controllers/Settings/KeySettings/Key List/KeySettingsViewController.swift @@ -23,6 +23,7 @@ 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 a51c58d2f..e5ae328ef 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 Foundation import FlowCryptCommon +import Foundation 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 36b39cab7..4a90ba330 100644 --- a/FlowCrypt/Controllers/Settings/KeySettings/Public Key/PublicKeyDetailViewController.swift +++ b/FlowCrypt/Controllers/Settings/KeySettings/Public Key/PublicKeyDetailViewController.swift @@ -17,6 +17,7 @@ final class PublicKeyDetailViewController: TableNodeViewController { super.init(node: TableNode()) } + @available(*, unavailable) required init?(coder _: NSCoder) { fatalError("init(coder:) has not been implemented") } @@ -38,7 +39,7 @@ extension PublicKeyDetailViewController: ASTableDelegate, ASTableDataSource { func tableNode(_: ASTableNode, nodeBlockForRowAt _: IndexPath) -> ASCellNodeBlock { return { [weak self] in - return SetupTitleNode( + 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 7dea2f913..6b31bbeec 100644 --- a/FlowCrypt/Controllers/Settings/Settings List/SettingsViewController.swift +++ b/FlowCrypt/Controllers/Settings/Settings List/SettingsViewController.swift @@ -39,6 +39,7 @@ 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 30d407ab9..9aa5dda35 100644 --- a/FlowCrypt/Controllers/Setup/SetupViewController.swift +++ b/FlowCrypt/Controllers/Setup/SetupViewController.swift @@ -80,6 +80,7 @@ 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 1f9b6329c..4ffb216cf 100644 --- a/FlowCrypt/Controllers/SideMenu/Menu/MyMenuViewController.swift +++ b/FlowCrypt/Controllers/SideMenu/Menu/MyMenuViewController.swift @@ -71,6 +71,7 @@ final class MyMenuViewController: ASDKViewController { super.init(node: ASDisplayNode()) } + @available(*, unavailable) required init?(coder _: NSCoder) { fatalError("init(coder:) has not been implemented") } @@ -275,7 +276,6 @@ 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 4a2ef12ca..0f291719a 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 FlowCryptUI import FlowCryptCommon +import FlowCryptUI import UIKit protocol MyMenuViewDecoratorType { diff --git a/FlowCrypt/Controllers/SignIn Other/EmailProviderViewController.swift b/FlowCrypt/Controllers/SignIn Other/EmailProviderViewController.swift index db3a2bc16..791273b7b 100644 --- a/FlowCrypt/Controllers/SignIn Other/EmailProviderViewController.swift +++ b/FlowCrypt/Controllers/SignIn Other/EmailProviderViewController.swift @@ -46,6 +46,7 @@ final class EmailProviderViewController: TableNodeViewController { node.dataSource = self } + @available(*, unavailable) required init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented") } @@ -511,7 +512,6 @@ extension EmailProviderViewController { return .success(user) } - } // MARK: - Picker diff --git a/FlowCrypt/Controllers/SignIn Other/EmailProviderViewDecorator.swift b/FlowCrypt/Controllers/SignIn Other/EmailProviderViewDecorator.swift index fbbc39479..613a0a104 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 UIKit import FlowCryptUI +import UIKit protocol EmailProviderViewDecoratorType { var connectButtonTitle: NSAttributedString { get } diff --git a/FlowCrypt/Controllers/SignIn/SignInViewController.swift b/FlowCrypt/Controllers/SignIn/SignInViewController.swift index d6a3e0918..79ae91558 100644 --- a/FlowCrypt/Controllers/SignIn/SignInViewController.swift +++ b/FlowCrypt/Controllers/SignIn/SignInViewController.swift @@ -36,6 +36,7 @@ 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 e8479939e..ec4bf230d 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 78a433be3..f6d435bff 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 b61c0b883..317d845e8 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 XCTest import FlowCryptCommon +import XCTest class CoreTypesTest: XCTestCase { @@ -59,7 +59,6 @@ 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 1a7ab442d..c98d20021 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 Foundation import FlowCryptCommon +import Foundation struct KeyDetails: Decodable { let `public`: String diff --git a/FlowCrypt/Extensions/UIViewControllerExtensions.swift b/FlowCrypt/Extensions/UIViewControllerExtensions.swift index f7ebe9aff..7f314850f 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 b7d206d27..47ddcf5fb 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 let error { + } catch { 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 775d7aef6..9deec38a7 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 e83f7dbf8..228b749e9 100644 --- a/FlowCrypt/Functionality/DataManager/Local Storage/LocalStorage.swift +++ b/FlowCrypt/Functionality/DataManager/Local Storage/LocalStorage.swift @@ -51,6 +51,5 @@ extension LocalStorage: LogOutHandler { .forEach { storage.removeObject(forKey: $0) } - } } diff --git a/FlowCrypt/Functionality/DataManager/UserAccountService.swift b/FlowCrypt/Functionality/DataManager/UserAccountService.swift index da29ca4f5..66d06a87e 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 let error { + } catch { 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 38edcffd6..753b04a16 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 Promises -import GTMSessionFetcher import GoogleAPIClientForREST +import GTMSessionFetcher +import Promises 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 c88eb3085..821d28a8e 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 49538b86c..3ebc32d40 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 96c494705..aaefe76de 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 c2b6f2954..fc68f966f 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 Promises -import GTMSessionFetcher import GoogleAPIClientForREST +import GTMSessionFetcher +import Promises 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 4ef75048c..00b311688 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 Promises -import GTMSessionFetcher import GoogleAPIClientForREST +import GTMSessionFetcher +import Promises 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 8e9e225ad..86448a5ce 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 0dabf78fb..a69b08b59 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 Promises -import GTMSessionFetcher -import GoogleAPIClientForREST import FlowCryptCommon +import GoogleAPIClientForREST +import GTMSessionFetcher +import Promises 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 1a19c4e71..b7bc228c5 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 Foundation import FlowCryptCommon +import Foundation 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 199ee8976..aff11ca6e 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 - return (type, type.value) + (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 b9b6100fb..b318ade2c 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 Promises -import GTMSessionFetcher import GoogleAPIClientForREST +import GTMSessionFetcher +import Promises 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 b869bf1b1..506f5a615 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 let error { + } catch { 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 4e835f82a..9ce28e1fe 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 UIKit import Promises +import UIKit protocol BackupServiceType { /// get all existed backups @@ -89,7 +89,7 @@ extension BackupService: BackupServiceType { } // MARK: - Helpers -fileprivate extension String { +private extension String { var userReadableEmail: String { self.replacingOccurrences( of: "[^a-z0-9]", @@ -99,7 +99,7 @@ fileprivate extension String { } } -fileprivate extension UserId { +private 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 b956fc604..f270faeaa 100644 --- a/FlowCrypt/Functionality/Services/Contacts Services/ContactsService.swift +++ b/FlowCrypt/Functionality/Services/Contacts Services/ContactsService.swift @@ -15,7 +15,6 @@ 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 29c52c786..38d1253a4 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 let error { + } catch { 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 f52efad8f..d91c488ef 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 Promises -import GTMSessionFetcher import GoogleAPIClientForREST +import GTMSessionFetcher +import Promises 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 e067398d3..4dd6b1ad2 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 88519fc2c..55d8ff3d5 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 UIKit import Promises +import UIKit protocol GlobalRouterType { func proceed() diff --git a/FlowCrypt/Functionality/Services/GoogleUserService.swift b/FlowCrypt/Functionality/Services/GoogleUserService.swift index 451723173..9c9c2a737 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 let error { + } catch { completion(.failure(.parsingError(error))) } } else if let error = error { diff --git a/FlowCryptCommon/Extensions/CollectionExtensions.swift b/FlowCryptCommon/Extensions/CollectionExtensions.swift index 669022218..a7da04acd 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 dae2da180..523c78955 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 2ddd6a890..dde16106a 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 f82f828b3..d4ffc436b 100644 --- a/FlowCryptCommon/Trace.swift +++ b/FlowCryptCommon/Trace.swift @@ -6,8 +6,8 @@ // Copyright © 2021 FlowCrypt Limited. All rights reserved. // -import Foundation import CoreFoundation +import Foundation public final class Trace { private let id: String diff --git a/FlowCryptTests/ExtensionTests.swift b/FlowCryptTests/ExtensionTests.swift index 60ebda442..c34d9847b 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.count == 0) - XCTAssert(nonEmptyCollection.count != 0) + XCTAssert(someEmptyCollection.isEmpty) + XCTAssert(!nonEmptyCollection.isEmpty) } func test_safe_subscript() { diff --git a/FlowCryptUI/Cell Nodes/CheckBoxTextNode.swift b/FlowCryptUI/Cell Nodes/CheckBoxTextNode.swift index fde2887a3..d165155cd 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 d996bd9b7..90974325b 100644 --- a/FlowCryptUI/Cell Nodes/ContactDetailNode.swift +++ b/FlowCryptUI/Cell Nodes/ContactDetailNode.swift @@ -16,14 +16,13 @@ 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 99ac732a0..0956e48f7 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 475a549b0..de84b6597 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 119e27d32..7d2ce5646 100644 --- a/FlowCryptUI/Cell Nodes/SwitchCellNode.swift +++ b/FlowCryptUI/Cell Nodes/SwitchCellNode.swift @@ -51,10 +51,9 @@ 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 04b044273..75a3ba883 100644 --- a/FlowCryptUI/Nodes/TextFieldNode.swift +++ b/FlowCryptUI/Nodes/TextFieldNode.swift @@ -240,5 +240,3 @@ extension TextFieldNode { onToolbarDoneAction?() } } - - diff --git a/FlowCryptUI/Views/NavigationBarItemsView.swift b/FlowCryptUI/Views/NavigationBarItemsView.swift index 89aed61fa..a9f31110f 100644 --- a/FlowCryptUI/Views/NavigationBarItemsView.swift +++ b/FlowCryptUI/Views/NavigationBarItemsView.swift @@ -52,6 +52,7 @@ 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 d8c15c172..18c4b9f1b 100644 --- a/FlowCryptUIApplication/ViewController.swift +++ b/FlowCryptUIApplication/ViewController.swift @@ -27,6 +27,7 @@ final class ViewController: TableNodeViewController { super.init(node: TableNode()) } + @available(*, unavailable) required init?(coder _: NSCoder) { fatalError("init(coder:) has not been implemented") } @@ -238,4 +239,3 @@ extension ViewController { textField?.reset() } } - diff --git a/FlowCryptUITests/SignInGoogleTest.swift b/FlowCryptUITests/SignInGoogleTest.swift index 061118372..f05e1fcb8 100644 --- a/FlowCryptUITests/SignInGoogleTest.swift +++ b/FlowCryptUITests/SignInGoogleTest.swift @@ -78,7 +78,6 @@ class SignInGoogleTest: XCTestCase, AppTest { textField.tap() - textField.typeText(user.email) let returnButton = goKeyboardButton XCTAssert(returnButton.exists, "User keyboard button") @@ -98,7 +97,6 @@ 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 @@ -113,7 +111,6 @@ 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 899cebb06..0284e0b6c 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,8 +282,6 @@ extension SignInTest { } } - - /* log in -> approve -> no backups -> generate pubkey -> switch accounts */ diff --git a/Scripts/format.sh b/Scripts/format.sh index 7c5f4e65e..6ce9ce41f 100755 --- a/Scripts/format.sh +++ b/Scripts/format.sh @@ -7,10 +7,15 @@ fi # Do not run format if swiftlint isn't installed if which swiftformat >/dev/null; then - echo "Start formating" + echo "Start formatting" swiftlint autocorrect --path . swiftformat . \ - --rules trailingSpace \ + --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, --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 aaa2a9a92..cd94bc1f9 100644 --- a/fastlane/SnapshotHelper.swift +++ b/fastlane/SnapshotHelper.swift @@ -80,7 +80,7 @@ open class Snapshot: NSObject { setLanguage(app) setLocale(app) setLaunchArguments(app) - } catch let error { + } catch { 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 let error { + } catch { 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)