Browse Source

swiftlint

Marino Faggiana 1 year ago
parent
commit
28e6d8e70c
28 changed files with 35 additions and 125 deletions
  1. 1 3
      iOSClient/Activity/NCActivity.swift
  2. 1 4
      iOSClient/Activity/NCActivityTableViewCell.swift
  3. 1 4
      iOSClient/Login/NCLogin.swift
  4. 1 3
      iOSClient/Login/NCLoginWeb.swift
  5. 1 4
      iOSClient/Main/Collection Common/NCCollectionViewCommon.swift
  6. 1 4
      iOSClient/Main/Create cloud/NCCreateFormUploadDocuments.swift
  7. 1 4
      iOSClient/Main/Create cloud/NCCreateFormUploadVoiceNote.swift
  8. 1 5
      iOSClient/Main/NCMainTabBar.swift
  9. 2 8
      iOSClient/Main/NCPickerViewController.swift
  10. 1 3
      iOSClient/Media/NCMedia.swift
  11. 1 5
      iOSClient/Menu/AppDelegate+Menu.swift
  12. 1 6
      iOSClient/More/NCMore.swift
  13. 1 4
      iOSClient/Networking/NCNetworking.swift
  14. 1 4
      iOSClient/Networking/NCNetworkingProcessUpload.swift
  15. 1 3
      iOSClient/Networking/NCService.swift
  16. 1 4
      iOSClient/Notification/NCNotification.swift
  17. 1 3
      iOSClient/RichWorkspace/NCRichWorkspaceCommon.swift
  18. 1 4
      iOSClient/RichWorkspace/NCViewerRichWorkspace.swift
  19. 1 5
      iOSClient/Settings/NCEndToEndInitialize.swift
  20. 1 4
      iOSClient/Settings/NCManageAutoUploadFileName.swift
  21. 2 10
      iOSClient/Settings/NCManageE2EE.swift
  22. 1 4
      iOSClient/Share/NCShareNetworking.swift
  23. 6 6
      iOSClient/Utility/CCUtility.m
  24. 1 4
      iOSClient/Viewer/NCViewer.swift
  25. 1 4
      iOSClient/Viewer/NCViewerMedia/NCPlayer/NCPlayer.swift
  26. 1 5
      iOSClient/Viewer/NCViewerMedia/NCViewerMedia.swift
  27. 1 4
      iOSClient/Viewer/NCViewerNextcloudText/NCViewerNextcloudText.swift
  28. 1 4
      iOSClient/Viewer/NCViewerRichdocument/NCViewerRichdocument.swift

+ 1 - 3
iOSClient/Activity/NCActivity.swift

@@ -39,9 +39,7 @@ class NCActivity: UIViewController, NCSharePagingContent {
     var metadata: tableMetadata?
     var showComments: Bool = false
 
-    // swiftlint:disable force_cast
-    private let appDelegate = UIApplication.shared.delegate as! AppDelegate
-    // swiftlint:enable force_cast
+    let appDelegate = (UIApplication.shared.delegate as? AppDelegate)!
 
     var allItems: [DateCompareable] = []
     var sectionDates: [Date] = []

+ 1 - 4
iOSClient/Activity/NCActivityTableViewCell.swift

@@ -41,10 +41,6 @@ class NCActivityCollectionViewCell: UICollectionViewCell {
 
 class NCActivityTableViewCell: UITableViewCell, NCCellProtocol {
 
-    // swiftlint:disable force_cast
-    private let appDelegate = UIApplication.shared.delegate as! AppDelegate
-    // swiftlint:enable force_cast
-
     @IBOutlet weak var collectionView: UICollectionView!
     @IBOutlet weak var icon: UIImageView!
     @IBOutlet weak var avatar: UIImageView!
@@ -52,6 +48,7 @@ class NCActivityTableViewCell: UITableViewCell, NCCellProtocol {
     @IBOutlet weak var subjectTrailingConstraint: NSLayoutConstraint!
     @IBOutlet weak var collectionViewHeightConstraint: NSLayoutConstraint!
 
+    private let appDelegate = (UIApplication.shared.delegate as? AppDelegate)!
     private var user: String = ""
     private var index = IndexPath()
 

+ 1 - 4
iOSClient/Login/NCLogin.swift

@@ -36,10 +36,7 @@ class NCLogin: UIViewController, UITextFieldDelegate, NCLoginQRCodeDelegate {
     @IBOutlet weak var qrCode: UIButton!
     @IBOutlet weak var certificate: UIButton!
 
-    // swiftlint:disable force_cast
-    private let appDelegate = UIApplication.shared.delegate as! AppDelegate
-    // swiftlint:enable force_cast
-
+    private let appDelegate = (UIApplication.shared.delegate as? AppDelegate)!
     private var textColor: UIColor = .white
     private var textColorOpponent: UIColor = .black
     private var activeTextfieldDiff: CGFloat = 0

+ 1 - 3
iOSClient/Login/NCLoginWeb.swift

@@ -30,9 +30,7 @@ class NCLoginWeb: UIViewController {
 
     var webView: WKWebView?
 
-    // swiftlint:disable force_cast
-    let appDelegate = UIApplication.shared.delegate as! AppDelegate
-    // swiftlint:enable force_cast
+    let appDelegate = (UIApplication.shared.delegate as? AppDelegate)!
 
     var titleView: String = ""
 

+ 1 - 4
iOSClient/Main/Collection Common/NCCollectionViewCommon.swift

@@ -32,10 +32,7 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
 
     @IBOutlet weak var collectionView: UICollectionView!
 
-    // swiftlint:disable force_cast
-    let appDelegate = UIApplication.shared.delegate as! AppDelegate
-    // swiftlint:enable force_cast
-
+    internal let appDelegate = (UIApplication.shared.delegate as? AppDelegate)!
     internal let refreshControl = UIRefreshControl()
     internal var searchController: UISearchController?
     internal var emptyDataSet: NCEmptyDataSet?

+ 1 - 4
iOSClient/Main/Create cloud/NCCreateFormUploadDocuments.swift

@@ -33,10 +33,7 @@ import XLForm
     @IBOutlet weak var collectionView: UICollectionView!
     @IBOutlet weak var collectionViewHeigth: NSLayoutConstraint!
 
-    // swiftlint:disable force_cast
-    let appDelegate = UIApplication.shared.delegate as! AppDelegate
-    // swiftlint:enable force_cast
-
+    let appDelegate = (UIApplication.shared.delegate as? AppDelegate)!
     var editorId = ""
     var creatorId = ""
     var typeTemplate = ""

+ 1 - 4
iOSClient/Main/Create cloud/NCCreateFormUploadVoiceNote.swift

@@ -31,10 +31,7 @@ class NCCreateFormUploadVoiceNote: XLFormViewController, NCSelectDelegate, AVAud
     @IBOutlet weak var labelDuration: UILabel!
     @IBOutlet weak var progressView: UIProgressView!
 
-    // swiftlint:disable force_cast
-    let appDelegate = UIApplication.shared.delegate as! AppDelegate
-    // swiftlint:enable force_cast
-
+    private let appDelegate = (UIApplication.shared.delegate as? AppDelegate)!
     private var serverUrl = ""
     private var titleServerUrl = ""
     private var fileName = ""

+ 1 - 5
iOSClient/Main/NCMainTabBar.swift

@@ -28,11 +28,7 @@ class NCMainTabBar: UITabBar {
 
     private var fillColor: UIColor!
     private var shapeLayer: CALayer?
-
-    // swiftlint:disable force_cast
-    private let appDelegate = UIApplication.shared.delegate as! AppDelegate
-    // swiftlint:enable force_cast
-
+    private let appDelegate = (UIApplication.shared.delegate as? AppDelegate)!
     private let centerButtonY: CGFloat = -28
 
     public var menuRect: CGRect {

+ 2 - 8
iOSClient/Main/NCPickerViewController.swift

@@ -31,10 +31,7 @@ import NextcloudKit
 
 class NCPhotosPickerViewController: NSObject {
 
-    // swiftlint:disable force_cast
-    let appDelegate = UIApplication.shared.delegate as! AppDelegate
-    // swiftlint:enable force_cast
-
+    let appDelegate = (UIApplication.shared.delegate as? AppDelegate)!
     var sourceViewController: UIViewController
     var maxSelectedAssets = 1
     var singleSelectedMode = false
@@ -118,10 +115,7 @@ class customPhotoPickerViewController: TLPhotosPickerViewController {
 
 class NCDocumentPickerViewController: NSObject, UIDocumentPickerDelegate {
 
-    // swiftlint:disable force_cast
-    let appDelegate = UIApplication.shared.delegate as! AppDelegate
-    // swiftlint:enable force_cast
-
+    let appDelegate = (UIApplication.shared.delegate as? AppDelegate)!
     var isViewerMedia: Bool
     var viewController: UIViewController?
 

+ 1 - 3
iOSClient/Media/NCMedia.swift

@@ -35,9 +35,7 @@ class NCMedia: UIViewController, NCEmptyDataSetDelegate, NCSelectDelegate {
     private var gridLayout: NCGridMediaLayout!
     internal var documentPickerViewController: NCDocumentPickerViewController?
 
-    // swiftlint:disable force_cast
-    internal let appDelegate = UIApplication.shared.delegate as! AppDelegate
-    // swiftlint:enable force_cast
+    internal let appDelegate = (UIApplication.shared.delegate as? AppDelegate)!
 
     //private var account: String = ""
 

+ 1 - 5
iOSClient/Menu/AppDelegate+Menu.swift

@@ -32,11 +32,7 @@ extension AppDelegate {
     func toggleMenu(viewController: UIViewController) {
 
         var actions: [NCMenuAction] = []
-
-        // swiftlint:disable force_cast
-        let appDelegate = UIApplication.shared.delegate as! AppDelegate
-        // swiftlint:enable force_cast
-
+        let appDelegate = (UIApplication.shared.delegate as? AppDelegate)!
         let directEditingCreators = NCManageDatabase.shared.getDirectEditingCreators(account: appDelegate.account)
         let isDirectoryE2EE = NCUtility.shared.isDirectoryE2EE(serverUrl: appDelegate.activeServerUrl, userBase: appDelegate)
         let directory = NCManageDatabase.shared.getTableDirectory(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@", appDelegate.account, appDelegate.activeServerUrl))

+ 1 - 6
iOSClient/More/NCMore.swift

@@ -37,13 +37,8 @@ class NCMore: UIViewController, UITableViewDelegate, UITableViewDataSource {
     private var externalSiteMenu: [NKExternalSite] = []
     private var settingsMenu: [NKExternalSite] = []
     private var quotaMenu: [NKExternalSite] = []
-
-    // swiftlint:disable force_cast
-    private let appDelegate = UIApplication.shared.delegate as! AppDelegate
-    // swiftlint:enable force_cast
-
+    private let appDelegate = (UIApplication.shared.delegate as? AppDelegate)!
     private let applicationHandle = NCApplicationHandle()
-
     private var tabAccount: tableAccount?
 
     private struct Section {

+ 1 - 4
iOSClient/Networking/NCNetworking.swift

@@ -690,10 +690,7 @@ class NCNetworking: NSObject, NKCommonDelegate {
                         NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterUploadCancelFile, userInfo: ["ocId": metadata.ocId, "serverUrl": metadata.serverUrl, "account": metadata.account])
                     }))
 
-                    // swiftlint:disable force_cast
-                    let appDelegate = UIApplication.shared.delegate as! AppDelegate
-                    // swiftlint:enable force_cast
-
+                    let appDelegate = (UIApplication.shared.delegate as? AppDelegate)!
                     appDelegate.window?.rootViewController?.present(alertController, animated: true)
                 }
 #endif

+ 1 - 4
iOSClient/Networking/NCNetworkingProcessUpload.swift

@@ -33,10 +33,7 @@ class NCNetworkingProcessUpload: NSObject {
         return instance
     }()
 
-    // swiftlint:disable force_cast
-    private let appDelegate = UIApplication.shared.delegate as! AppDelegate
-    // swiftlint:enable force_cast
-
+    private let appDelegate = (UIApplication.shared.delegate as? AppDelegate)!
     private var notificationToken: NotificationToken?
     private var timerProcess: Timer?
     private var pauseProcess: Bool = false

+ 1 - 3
iOSClient/Networking/NCService.swift

@@ -32,9 +32,7 @@ class NCService: NSObject {
         return instance
     }()
 
-    // swiftlint:disable force_cast
-    let appDelegate = UIApplication.shared.delegate as! AppDelegate
-    // swiftlint:enable force_cast
+    let appDelegate = (UIApplication.shared.delegate as? AppDelegate)!
 
     // MARK: -
 

+ 1 - 4
iOSClient/Notification/NCNotification.swift

@@ -29,10 +29,7 @@ import JGProgressHUD
 
 class NCNotification: UITableViewController, NCNotificationCellDelegate, NCEmptyDataSetDelegate {
 
-    // swiftlint:disable force_cast
-    let appDelegate = UIApplication.shared.delegate as! AppDelegate
-    // swiftlint:enable force_cast
-
+    let appDelegate = (UIApplication.shared.delegate as? AppDelegate)!
     var notifications: [NKNotifications] = []
     var emptyDataSet: NCEmptyDataSet?
     var isReloadDataSourceNetworkInProgress: Bool = false

+ 1 - 3
iOSClient/RichWorkspace/NCRichWorkspaceCommon.swift

@@ -26,9 +26,7 @@ import NextcloudKit
 
 @objc class NCRichWorkspaceCommon: NSObject {
 
-    // swiftlint:disable force_cast
-    let appDelegate = UIApplication.shared.delegate as! AppDelegate
-    // swiftlint:enable force_cast
+    let appDelegate = (UIApplication.shared.delegate as? AppDelegate)!
 
     @objc func createViewerNextcloudText(serverUrl: String, viewController: UIViewController) {
 

+ 1 - 4
iOSClient/RichWorkspace/NCViewerRichWorkspace.swift

@@ -29,10 +29,7 @@ import MarkdownKit
 
     @IBOutlet weak var textView: UITextView!
 
-    // swiftlint:disable force_cast
-    private let appDelegate = UIApplication.shared.delegate as! AppDelegate
-    // swiftlint:enable force_cast
-
+    private let appDelegate = (UIApplication.shared.delegate as? AppDelegate)!
     private let richWorkspaceCommon = NCRichWorkspaceCommon()
     private var markdownParser = MarkdownParser()
     private var textViewColor: UIColor?

+ 1 - 5
iOSClient/Settings/NCEndToEndInitialize.swift

@@ -32,11 +32,7 @@ import NextcloudKit
 class NCEndToEndInitialize: NSObject {
 
     @objc weak var delegate: NCEndToEndInitializeDelegate?
-
-    // swiftlint:disable force_cast
-    let appDelegate = UIApplication.shared.delegate as! AppDelegate
-    // swiftlint:enable force_cast
-
+    let appDelegate = (UIApplication.shared.delegate as? AppDelegate)!
     var extractedPublicKey: String?
 
     override init() {

+ 1 - 4
iOSClient/Settings/NCManageAutoUploadFileName.swift

@@ -27,10 +27,7 @@ import NextcloudKit
 
 class NCManageAutoUploadFileName: XLFormViewController {
 
-    // swiftlint:disable force_cast
-    let appDelegate = UIApplication.shared.delegate as! AppDelegate
-    // swiftlint:enable force_cast
-
+    let appDelegate = (UIApplication.shared.delegate as? AppDelegate)!
     let dateExample = Date()
 
     func initializeForm() {

+ 2 - 10
iOSClient/Settings/NCManageE2EE.swift

@@ -30,10 +30,6 @@ import LocalAuthentication
 
     @objc func makeShipDetailsUI(account: String) -> UIViewController {
 
-        // swiftlint:disable force_cast
-        let account = (UIApplication.shared.delegate as! AppDelegate).account
-        // swiftlint:enable force_cast
-
         let details = NCViewE2EE(account: account)
         let vc = UIHostingController(rootView: details)
         vc.title = NSLocalizedString("_e2e_settings_", comment: "")
@@ -44,11 +40,7 @@ import LocalAuthentication
 class NCManageE2EE: NSObject, ObservableObject, NCEndToEndInitializeDelegate, TOPasscodeViewControllerDelegate {
 
     let endToEndInitialize = NCEndToEndInitialize()
-
-    // swiftlint:disable force_cast
-    let appDelegate = UIApplication.shared.delegate as! AppDelegate
-    // swiftlint:enable force_cast
-
+    let appDelegate = (UIApplication.shared.delegate as? AppDelegate)!
     var passcodeType = ""
 
     @Published var isEndToEndEnabled: Bool = false
@@ -202,7 +194,7 @@ struct NCViewE2EE: View {
                     }
                     .contentShape(Rectangle())
                     .onTapGesture {
-                        if let passcode = NCKeychain().passcode {
+                        if NCKeychain().passcode != nil {
                             manageE2EE.requestPasscodeType("readPassphrase")
                         } else {
                             NCContentPresenter.shared.showInfo(error: NKError(errorCode: 0, errorDescription: "_e2e_settings_lock_not_active_"))

+ 1 - 4
iOSClient/Share/NCShareNetworking.swift

@@ -25,10 +25,7 @@ import NextcloudKit
 
 class NCShareNetworking: NSObject {
 
-    // swiftlint:disable force_cast
-    private let appDelegate = UIApplication.shared.delegate as! AppDelegate
-    // swiftlint:enable force_cast
-
+    let appDelegate = (UIApplication.shared.delegate as? AppDelegate)!
     weak var delegate: NCShareNetworkingDelegate?
     var view: UIView
     var metadata: tableMetadata

+ 6 - 6
iOSClient/Utility/CCUtility.m

@@ -90,21 +90,21 @@
 {
     NSString* versionE2EE = [[NCGlobal shared] capabilityE2EEApiVersion];
 
-    NSString *certificate = [self getEndToEndCertificate:account];
+    // NSString *certificate = [self getEndToEndCertificate:account];
     NSString *publicKey = [self getEndToEndPublicKey:account];
     NSString *privateKey = [self getEndToEndPrivateKey:account];
     NSString *passphrase = [self getEndToEndPassphrase:account];
             
-    if (passphrase.length > 0 && privateKey.length > 0 && certificate.length > 0 && publicKey.length > 0 && [NCGlobal.shared.e2eeVersions containsObject:versionE2EE]) {
+    //if (passphrase.length > 0 && privateKey.length > 0 && certificate.length > 0 && publicKey.length > 0 && [NCGlobal.shared.e2eeVersions containsObject:versionE2EE]) {
         return YES;
-    } else {
-        return NO;
-    }
+    //} else {
+    //    return NO;
+    //}
 }
 
 + (void)clearAllKeysEndToEnd:(NSString *)account
 {
-    [self setEndToEndCertificate:account certificate:nil];
+   // [self setEndToEndCertificate:account certificate:nil];
     [self setEndToEndPrivateKey:account privateKey:nil];
     [self setEndToEndPublicKey:account publicKey:nil];
     [self setEndToEndPassphrase:account passphrase:nil];

+ 1 - 4
iOSClient/Viewer/NCViewer.swift

@@ -31,10 +31,7 @@ class NCViewer: NSObject {
         return instance
     }()
 
-    // swiftlint:disable force_cast
-    let appDelegate = UIApplication.shared.delegate as! AppDelegate
-    // swiftlint:enable force_cast
-
+    let appDelegate = (UIApplication.shared.delegate as? AppDelegate)!
     private var viewerQuickLook: NCViewerQuickLook?
     private var metadata = tableMetadata()
     private var metadatas: [tableMetadata] = []

+ 1 - 4
iOSClient/Viewer/NCViewerMedia/NCPlayer/NCPlayer.swift

@@ -28,10 +28,7 @@ import MobileVLCKit
 
 class NCPlayer: NSObject {
 
-    // swiftlint:disable force_cast
-    internal let appDelegate = UIApplication.shared.delegate as! AppDelegate
-    // swiftlint:enable force_cast
-
+    internal let appDelegate = (UIApplication.shared.delegate as? AppDelegate)!
     internal var url: URL?
     internal var player = VLCMediaPlayer()
     internal var dialogProvider: VLCDialogProvider?

+ 1 - 5
iOSClient/Viewer/NCViewerMedia/NCViewerMedia.swift

@@ -47,11 +47,7 @@ class NCViewerMedia: UIViewController {
 
     private var tipView: EasyTipView?
     private let player = VLCMediaPlayer()
-
-    // swiftlint:disable force_cast
-    let appDelegate = UIApplication.shared.delegate as! AppDelegate
-    // swiftlint:enable force_cast
-
+    private let appDelegate = (UIApplication.shared.delegate as? AppDelegate)!
     weak var viewerMediaPage: NCViewerMediaPage?
     var playerToolBar: NCPlayerToolBar?
     var ncplayer: NCPlayer?

+ 1 - 4
iOSClient/Viewer/NCViewerNextcloudText/NCViewerNextcloudText.swift

@@ -26,10 +26,7 @@ import WebKit
 
 class NCViewerNextcloudText: UIViewController, WKNavigationDelegate, WKScriptMessageHandler, WKUIDelegate {
 
-    // swiftlint:disable force_cast
-    let appDelegate = UIApplication.shared.delegate as! AppDelegate
-    // swiftlint:enable force_cast
-
+    let appDelegate = (UIApplication.shared.delegate as? AppDelegate)!
     var webView = WKWebView()
     var bottomConstraint: NSLayoutConstraint?
     var link: String = ""

+ 1 - 4
iOSClient/Viewer/NCViewerRichdocument/NCViewerRichdocument.swift

@@ -27,10 +27,7 @@ import NextcloudKit
 
 class NCViewerRichdocument: UIViewController, WKNavigationDelegate, WKScriptMessageHandler, NCSelectDelegate {
 
-    // swiftlint:disable force_cast
-    let appDelegate = UIApplication.shared.delegate as! AppDelegate
-    // swiftlint:enable force_cast
-
+    let appDelegate = (UIApplication.shared.delegate as? AppDelegate)!
     var webView = WKWebView()
     var bottomConstraint: NSLayoutConstraint?
     var documentController: UIDocumentInteractionController?