Browse Source

Auto upload Lint (#2618)

* coding

Signed-off-by: Marino Faggiana <marino@marinofaggiana.com>

* lint

Signed-off-by: Marino Faggiana <marino@marinofaggiana.com>
Marino Faggiana 1 year ago
parent
commit
6f26b741b7
64 changed files with 586 additions and 708 deletions
  1. 10 115
      .swiftlint.yml
  2. 1 1
      File Provider Extension/FileProviderData.swift
  3. 1 1
      File Provider Extension/FileProviderEnumerator.swift
  4. 1 3
      File Provider Extension/FileProviderExtension+Actions.swift
  5. 7 11
      File Provider Extension/FileProviderExtension.swift
  6. 0 6
      Widget/Dashboard/DashboardData.swift
  7. 7 5
      iOSClient/Activity/NCActivity.swift
  8. 6 4
      iOSClient/Activity/NCActivityTableViewCell.swift
  9. 19 18
      iOSClient/AppDelegate.swift
  10. 7 4
      iOSClient/Login/NCLogin.swift
  11. 6 2
      iOSClient/Login/NCLoginWeb.swift
  12. 29 34
      iOSClient/Main/Collection Common/NCCollectionViewCommon.swift
  13. 1 1
      iOSClient/Main/Collection Common/NCListCell.swift
  14. 12 12
      iOSClient/Main/Create cloud/NCCreateFormUploadConflict.swift
  15. 50 58
      iOSClient/Main/Create cloud/NCCreateFormUploadDocuments.swift
  16. 20 20
      iOSClient/Main/Create cloud/NCCreateFormUploadVoiceNote.swift
  17. 8 5
      iOSClient/Main/Create cloud/NCCreateMenuAdd.swift
  18. 7 6
      iOSClient/Main/NCMainTabBar.swift
  19. 8 2
      iOSClient/Main/NCPickerViewController.swift
  20. 11 8
      iOSClient/Media/NCMedia.swift
  21. 4 4
      iOSClient/Media/NCMediaCommandView.xib
  22. 63 52
      iOSClient/Menu/AppDelegate+Menu.swift
  23. 3 4
      iOSClient/Menu/NCCollectionViewCommon+Menu.swift
  24. 3 3
      iOSClient/Menu/NCLoginWeb+Menu.swift
  25. 9 8
      iOSClient/Menu/NCMedia+Menu.swift
  26. 23 21
      iOSClient/More/NCMore.swift
  27. 2 2
      iOSClient/Networking/E2EE/NCNetworkingE2EECreateFolder.swift
  28. 1 1
      iOSClient/Networking/E2EE/NCNetworkingE2EERename.swift
  29. 7 9
      iOSClient/Networking/E2EE/NCNetworkingE2EEUpload.swift
  30. 13 19
      iOSClient/Networking/NCAutoUpload.swift
  31. 2 0
      iOSClient/Networking/NCConfigServer.swift
  32. 15 17
      iOSClient/Networking/NCNetworking.swift
  33. 3 3
      iOSClient/Networking/NCNetworkingCheckRemoteUser.swift
  34. 7 4
      iOSClient/Networking/NCNetworkingProcessUpload.swift
  35. 2 3
      iOSClient/Networking/NCOperationQueue.swift
  36. 5 3
      iOSClient/Networking/NCService.swift
  37. 9 4
      iOSClient/Notification/NCNotification.swift
  38. 8 8
      iOSClient/Rename file/NCRenameFile.swift
  39. 3 1
      iOSClient/RichWorkspace/NCRichWorkspaceCommon.swift
  40. 3 0
      iOSClient/RichWorkspace/NCViewerRichWorkspace.swift
  41. 9 10
      iOSClient/Select/NCSelect.swift
  42. 3 0
      iOSClient/Settings/NCEndToEndInitialize.swift
  43. 11 8
      iOSClient/Settings/NCManageAutoUploadFileName.swift
  44. 11 0
      iOSClient/Settings/NCManageE2EE.swift
  45. 2 0
      iOSClient/Share/NCShareCommon.swift
  46. 2 0
      iOSClient/Share/NCShareNetworking.swift
  47. 3 13
      iOSClient/Transfers/NCTransfers.swift
  48. 6 6
      iOSClient/UserStatus/NCUserStatus.swift
  49. 0 8
      iOSClient/Utility/NCAskAuthorization.swift
  50. 4 0
      iOSClient/Utility/NCCameraRoll.swift
  51. 1 1
      iOSClient/Utility/NCContentPresenter.swift
  52. 1 1
      iOSClient/Utility/NCStoreReview.swift
  53. 25 70
      iOSClient/Utility/NCUtility.swift
  54. 4 4
      iOSClient/Utility/NCUtilityFileSystem.swift
  55. 22 25
      iOSClient/Viewer/NCViewer.swift
  56. 3 7
      iOSClient/Viewer/NCViewerMedia/NCPlayer/NCPlayer.swift
  57. 23 19
      iOSClient/Viewer/NCViewerMedia/NCPlayer/NCPlayerToolBar.swift
  58. 7 4
      iOSClient/Viewer/NCViewerMedia/NCViewerMedia.swift
  59. 12 7
      iOSClient/Viewer/NCViewerMedia/NCViewerMediaPage.swift
  60. 3 0
      iOSClient/Viewer/NCViewerNextcloudText/NCViewerNextcloudText.swift
  61. 8 8
      iOSClient/Viewer/NCViewerPDF/NCViewerPDF.swift
  62. 13 16
      iOSClient/Viewer/NCViewerPDF/NCViewerPDFSearch.swift
  63. 0 7
      iOSClient/Viewer/NCViewerProviderContextMenu.swift
  64. 17 12
      iOSClient/Viewer/NCViewerRichdocument/NCViewerRichdocument.swift

+ 10 - 115
.swiftlint.yml

@@ -10,24 +10,25 @@ empty_count:
   severity: warning
 
 line_length:
-  warning: 400
+  warning: 1000
   error: 5000
 
 function_body_length:
    warning: 400
 
 type_body_length:
-  warning: 800
-  error: 1000
-  
+  warning: 1500
+  error: 2000
+
 file_length:
-  warning: 1000
-  error: 1500
+  warning: 2000
+  error: 2500
   ignore_comment_only_lines: true
 
 identifier_name:
   min_length: 0
-  
+  max_length: 100
+
 disabled_rules:  
   - unused_setter_value
   - large_tuple
@@ -38,120 +39,14 @@ disabled_rules:
   - nesting
   - shorthand_operator
   - type_name
-    
+  - void_function_in_ternary
+
 excluded:
   - Carthage
   - Pods
   - Tests
-
-  # iOS Files Quarantine
-
   - Brand/NCBrand.swift
-  - File Provider Extension/FileProviderData.swift
-  - File Provider Extension/FileProviderDomain.swift
-  - File Provider Extension/FileProviderEnumerator.swift
-  - File Provider Extension/FileProviderExtension+Actions.swift
-  - File Provider Extension/FileProviderExtension+Thumbnail.swift
-  - File Provider Extension/FileProviderExtension.swift
-  - File Provider Extension/FileProviderUtility.swift
-  - Notification Service Extension/NotificationService.swift
-  - Widget/Widget.swift
-  - Widget/Dashboard/DashboardData.swift
-  - Widget/Dashboard/DashboardWidgetView.swift
-  - Widget/Files/FilesData.swift
-  - Widget/Files/FilesWidgetView.swift
-  - Widget/Lockscreen/LockscreenData.swift
-  - Widget/Lockscreen/LockscreenWidgetView.swift
-  - Widget/Lockscreen/LockscreenWidgetProvider.swift
-  - iOSClient/GUI
-  - iOSClient/ExternalResources
-  - iOSClient/Activity/NCActivity.swift
-  - iOSClient/Activity/NCActivityTableViewCell.swift
-  - iOSClient/AppDelegate.swift
-  - iOSClient/BackgroundImageColor/NCBackgroundImageColor.swift
-  - iOSClient/BrowserWeb/NCBrowserWeb.swift
-  - iOSClient/Diagnostics/NCCapabilitiesViewController.swift
-  - iOSClient/EmptyView/NCEmptyDataSet.swift
-  - iOSClient/Extensions/UIColor+Extensions.swift
-  - iOSClient/Extensions/UIImage+Extensions.swift
-  - iOSClient/FileViewInFolder/NCFileViewInFolder.swift
-  - iOSClient/Login/NCAppConfigView.swift
-  - iOSClient/Login/NCLogin.swift
-  - iOSClient/Login/NCLoginWeb.swift
-  - iOSClient/Main/Account Request/NCAccountRequest.swift
-  - iOSClient/Main/AudioRecorder/NCAudioRecorderViewController.swift
-  - iOSClient/Main/Collection Common/NCCollectionViewCommon.swift
-  - iOSClient/Main/Collection Common/NCGridCell.swift
-  - iOSClient/Main/Collection Common/NCListCell.swift
-  - iOSClient/Main/Create cloud/NCCreateFormUploadAssets.swift
-  - iOSClient/Main/Create cloud/NCCreateFormUploadConflict.swift
-  - iOSClient/Main/Create cloud/NCCreateFormUploadConflictCell.swift
-  - iOSClient/Main/Create cloud/NCCreateFormUploadDocuments.swift
-  - iOSClient/Main/Create cloud/NCCreateFormUploadScanDocument.swift
-  - iOSClient/Main/Create cloud/NCCreateFormUploadVoiceNote.swift
-  - iOSClient/Main/Create cloud/NCCreateMenuAdd.swift
-  - iOSClient/Main/NCFunctionCenter.swift
-  - iOSClient/Main/NCMainTabBar.swift
-  - iOSClient/Main/NCPickerViewController.swift
-  - iOSClient/Main/Section Header Footer/NCSectionHeaderFooter.swift
-  - iOSClient/Media/Cell/NCGridMediaCell.swift
-  - iOSClient/Media/NCMedia.swift
-  - iOSClient/Menu/AppDelegate+Menu.swift
-  - iOSClient/Menu/NCCollectionViewCommon+Menu.swift
-  - iOSClient/Menu/NCLoginWeb+Menu.swift
-  - iOSClient/Menu/NCMedia+Menu.swift
-  - iOSClient/Menu/NCSortMenu.swift
-  - iOSClient/Menu/NCViewer+Menu.swift
-  - iOSClient/More/NCMore.swift
   - iOSClient/NCGlobal.swift
-  - iOSClient/Networking/NCAutoUpload.swift
-  - iOSClient/Networking/NCNetworking.swift
-  - iOSClient/Networking/NCNetworkingCheckRemoteUser.swift
-  - iOSClient/Networking/NCNetworkingChunkedUpload.swift
-  - iOSClient/Networking/E2EE/NCNetworkingE2EE.swift
-  - iOSClient/Networking/E2EE/NCNetworkingE2EEUpload.swift
-  - iOSClient/Networking/E2EE/NCNetworkingE2EEDelete.swift
-  - iOSClient/Networking/E2EE/NCNetworkingE2EERename.swift
-  - iOSClient/Networking/E2EE/NCNetworkingE2EECreateFolder.swift
-  - iOSClient/Networking/NCNetworkingProcessUpload.swift
-  - iOSClient/Networking/NCOperationQueue.swift
-  - iOSClient/Networking/NCService.swift
-  - iOSClient/Networking/NCConfigServer.swift
-  - iOSClient/Notification/NCNotification.swift
-  - iOSClient/Recent/NCRecent.swift
-  - iOSClient/Rename file/NCRenameFile.swift
-  - iOSClient/RichWorkspace/NCRichWorkspaceCommon.swift
-  - iOSClient/RichWorkspace/NCViewerRichWorkspace.swift
-  - iOSClient/ScanDocument/ScanCollectionView.swift
-  - iOSClient/Security/NCEndToEndMetadata.swift
-  - iOSClient/Security/NCViewCertificateDetails.swift
-  - iOSClient/Select/NCSelect.swift
-  - iOSClient/Settings/NCEndToEndInitialize.swift
-  - iOSClient/Settings/NCManageAutoUploadFileName.swift
-  - iOSClient/Settings/NCManageE2EE.swift
-  - iOSClient/Share/NCShareCommon.swift
-  - iOSClient/Share/NCShareNetworking.swift
-  - iOSClient/Shares/NCShares.swift
-  - iOSClient/Transfers/NCTransferCell.swift
-  - iOSClient/Transfers/NCTransfers.swift
-  - iOSClient/UserStatus/NCUserStatus.swift
-  - iOSClient/Utility/NCAskAuthorization.swift
-  - iOSClient/Utility/NCContentPresenter.swift
   - iOSClient/Utility/NCLivePhoto.swift
-  - iOSClient/Utility/NCPopupViewController.swift
-  - iOSClient/Utility/NCStoreReview.swift
-  - iOSClient/Utility/NCUtility.swift
-  - iOSClient/Utility/NCUtilityFileSystem.swift
-  - iOSClient/Utility/NCUtilityGUI.swift
-  - iOSClient/Viewer/NCViewer.swift
-  - iOSClient/Viewer/NCViewerMedia/NCPlayer/NCPlayer.swift
-  - iOSClient/Viewer/NCViewerMedia/NCPlayer/NCPlayerToolBar.swift
-  - iOSClient/Viewer/NCViewerMedia/NCViewerMedia.swift
-  - iOSClient/Viewer/NCViewerMedia/NCViewerMediaPage.swift
-  - iOSClient/Viewer/NCViewerNextcloudText/NCViewerNextcloudText.swift
-  - iOSClient/Viewer/NCViewerPDF/NCViewerPDF.swift
-  - iOSClient/Viewer/NCViewerPDF/NCViewerPDFSearch.swift
-  - iOSClient/Viewer/NCViewerProviderContextMenu.swift
-  - iOSClient/Viewer/NCViewerRichdocument/NCViewerRichdocument.swift
 
 reporter: "xcode"

+ 1 - 1
File Provider Extension/FileProviderData.swift

@@ -101,7 +101,7 @@ class fileProviderData: NSObject {
 
         // DOMAIN
         let accounts = NCManageDatabase.shared.getAllAccount()
-        if accounts.count == 0 { return nil }
+        if accounts.isEmpty { return nil }
 
         for activeAccount in accounts {
             guard let url = NSURL(string: activeAccount.urlBase) else { continue }

+ 1 - 1
File Provider Extension/FileProviderEnumerator.swift

@@ -173,7 +173,7 @@ class FileProviderEnumerator: NSObject, NSFileProviderEnumerator {
 
             for metadata in metadatas! {
 
-                if metadata.e2eEncrypted || (metadata.session != "" && metadata.session != NCNetworking.shared.sessionIdentifierBackgroundExtension) { continue }
+                if metadata.e2eEncrypted || (!metadata.session.isEmpty && metadata.session != NCNetworking.shared.sessionIdentifierBackgroundExtension) { continue }
 
                 fileProviderUtility.shared.createocIdentifierOnFileSystem(metadata: metadata)
 

+ 1 - 3
File Provider Extension/FileProviderExtension+Actions.swift

@@ -43,9 +43,7 @@ extension FileProviderExtension {
 
                 NextcloudKit.shared.readFileOrFolder(serverUrlFileName: serverUrlFileName, depth: "0", showHiddenFiles: CCUtility.getShowHiddenFiles()) { _, files, _, error in
 
-                    if error == .success && files.count > 0 {
-
-                        let file = files.first!
+                    if error == .success, let file = files.first {
 
                         let isDirectoryEncrypted = NCUtility.shared.isDirectoryE2EE(file: file)
                         let metadata = NCManageDatabase.shared.convertFileToMetadata(file, isDirectoryE2EE: isDirectoryEncrypted)

+ 7 - 11
File Provider Extension/FileProviderExtension.swift

@@ -190,26 +190,22 @@ class FileProviderExtension: NSFileProviderExtension, NCNetworkingDelegate {
         let pathComponents = url.pathComponents
         let identifier = NSFileProviderItemIdentifier(pathComponents[pathComponents.count - 2])
 
-        if let _ = outstandingSessionTasks[url] {
-            completionHandler(nil)
-            return
+        if outstandingSessionTasks[url] != nil {
+            return completionHandler(nil)
         }
 
         guard let metadata = fileProviderUtility.shared.getTableMetadataFromItemIdentifier(identifier) else {
-            completionHandler(NSFileProviderError(.noSuchItem))
-            return
+            return completionHandler(NSFileProviderError(.noSuchItem))
         }
 
         // Document VIEW ONLY
         if metadata.isDocumentViewableOnly {
-            completionHandler(NSFileProviderError(.noSuchItem))
-            return
+            return completionHandler(NSFileProviderError(.noSuchItem))
         }
 
         let tableLocalFile = NCManageDatabase.shared.getTableLocalFile(predicate: NSPredicate(format: "ocId == %@", metadata.ocId))
         if tableLocalFile != nil && CCUtility.fileProviderStorageExists(metadata) && tableLocalFile?.etag == metadata.etag {
-            completionHandler(nil)
-            return
+            return completionHandler(nil)
         }
 
         let serverUrlFileName = metadata.serverUrl + "/" + metadata.fileName
@@ -337,8 +333,8 @@ class FileProviderExtension: NSFileProviderExtension, NCNetworkingDelegate {
                 // typefile directory ? (NOT PERMITTED)
                 do {
                     let attributes = try fileProviderUtility.shared.fileManager.attributesOfItem(atPath: fileURL.path)
-                    size = attributes[FileAttributeKey.size] as! Int64
-                    let typeFile = attributes[FileAttributeKey.type] as! FileAttributeType
+                    size = attributes[FileAttributeKey.size] as? Int64 ?? 0
+                    let typeFile = attributes[FileAttributeKey.type] as? FileAttributeType
                     if typeFile == FileAttributeType.typeDirectory {
                         completionHandler(nil, NSFileProviderError(.noSuchItem))
                         return

+ 0 - 6
Widget/Dashboard/DashboardData.swift

@@ -51,12 +51,6 @@ struct DashboardData: Identifiable, Hashable {
     let imageColor: UIColor?
 }
 
-struct DashboardDataButton: Hashable {
-    let type: String
-    let Text: String
-    let link: String
-}
-
 let dashboardDatasTest: [DashboardData] = [
     .init(id: 0, title: "title0", subTitle: "subTitle-description0", link: URL(string: "https://nextcloud.com/")!, icon: UIImage(named: "widget")!, template: true, avatar: false, imageColor: nil),
     .init(id: 1, title: "title1", subTitle: "subTitle-description1", link: URL(string: "https://nextcloud.com/")!, icon: UIImage(named: "widget")!, template: true, avatar: false, imageColor: nil),

+ 7 - 5
iOSClient/Activity/NCActivity.swift

@@ -39,7 +39,9 @@ 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
 
     var allItems: [DateCompareable] = []
     var sectionDates: [Date] = []
@@ -247,7 +249,7 @@ extension NCActivity: UITableViewDataSource {
         cell.viewController = self
 
         // icon
-        if activity.icon.count > 0 {
+        if !activity.icon.isEmpty {
 
             let fileNameIcon = (activity.icon as NSString).lastPathComponent
             let fileNameLocalPath = CCUtility.getDirectoryUserData() + "/" + fileNameIcon
@@ -269,7 +271,7 @@ extension NCActivity: UITableViewDataSource {
         }
 
         // avatar
-        if activity.user.count > 0 && activity.user != appDelegate.userId {
+        if !activity.user.isEmpty && activity.user != appDelegate.userId {
 
             cell.subjectTrailingConstraint.constant = 50
             cell.avatar.isHidden = false
@@ -282,7 +284,7 @@ extension NCActivity: UITableViewDataSource {
 
         // subject
         cell.subject.text = activity.subject
-        if activity.subjectRich.count > 0 {
+        if !activity.subjectRich.isEmpty {
 
             var subject = activity.subjectRich
             var keys: [String] = []
@@ -316,7 +318,7 @@ extension NCActivity: UITableViewDataSource {
 
         // CollectionView
         cell.activityPreviews = NCManageDatabase.shared.getActivityPreview(account: activity.account, idActivity: activity.idActivity, orderKeysId: orderKeysId)
-        if cell.activityPreviews.count == 0 {
+        if cell.activityPreviews.isEmpty {
             cell.collectionViewHeightConstraint.constant = 0
         } else {
             cell.collectionViewHeightConstraint.constant = 60
@@ -507,7 +509,7 @@ extension NCActivity: NCShareCommentsCellDelegate {
                     })
 
                     alert.addAction(UIAlertAction(title: NSLocalizedString("_ok_", comment: ""), style: .default, handler: { _ in
-                        guard let message = alert.textFields?.first?.text, message != "" else { return }
+                        guard let message = alert.textFields?.first?.text, !message.isEmpty else { return }
 
                         NextcloudKit.shared.updateComments(fileId: metadata.fileId, messageId: tableComments.messageId, message: message) { _, error in
                             if error == .success {

+ 6 - 4
iOSClient/Activity/NCActivityTableViewCell.swift

@@ -40,7 +40,9 @@ 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!
@@ -62,7 +64,7 @@ class NCActivityTableViewCell: UITableViewCell, NCCellProtocol {
         set { index = newValue }
     }
     var fileAvatarImageView: UIImageView? {
-        get { return avatar }
+        return avatar
     }
     var fileUser: String? {
         get { return user }
@@ -95,8 +97,6 @@ extension NCActivityTableViewCell: UICollectionViewDelegate {
             return
         }
 
-        let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "collectionCell", for: indexPath) as? NCActivityCollectionViewCell
-
         let activityPreview = activityPreviews[indexPath.row]
 
         if activityPreview.view == "trashbin" {
@@ -148,7 +148,9 @@ extension NCActivityTableViewCell: UICollectionViewDataSource {
 
     func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
 
-        let cell: NCActivityCollectionViewCell = collectionView.dequeueReusableCell(withReuseIdentifier: "collectionCell", for: indexPath) as! NCActivityCollectionViewCell
+        guard let cell: NCActivityCollectionViewCell = collectionView.dequeueReusableCell(withReuseIdentifier: "collectionCell", for: indexPath) as? NCActivityCollectionViewCell else {
+            return UICollectionViewCell()
+        }
 
         cell.imageView.image = nil
         cell.indexPath = indexPath

+ 19 - 18
iOSClient/AppDelegate.swift

@@ -59,9 +59,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
     private var privacyProtectionWindow: UIWindow?
 
     var isUiTestingEnabled: Bool {
-         get {
-             return ProcessInfo.processInfo.arguments.contains("UI_TESTING")
-         }
+        return ProcessInfo.processInfo.arguments.contains("UI_TESTING")
      }
 
     func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
@@ -500,7 +498,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
             }
         } else if contextViewController is UINavigationController {
             if let contextViewController = contextViewController, let viewController = viewController {
-                (contextViewController as! UINavigationController).pushViewController(viewController, animated: true)
+                (contextViewController as? UINavigationController)?.pushViewController(viewController, animated: true)
             }
         } else {
             if let viewController = viewController, let contextViewController = contextViewController {
@@ -520,9 +518,8 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
     }
 
     @objc private func checkErrorNetworking() {
-        if account != "" && CCUtility.getPassword(account)!.count == 0 {
-            openLogin(viewController: window?.rootViewController, selector: NCGlobal.shared.introLogin, openLoginWeb: true)
-        }
+        guard !account.isEmpty, CCUtility.getPassword(account)!.isEmpty else { return }
+        openLogin(viewController: window?.rootViewController, selector: NCGlobal.shared.introLogin, openLoginWeb: true)
     }
 
     func trustCertificateError(host: String) {
@@ -549,8 +546,8 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
         alertController.addAction(UIAlertAction(title: NSLocalizedString("_no_", comment: ""), style: .default, handler: { _ in }))
 
         alertController.addAction(UIAlertAction(title: NSLocalizedString("_certificate_details_", comment: ""), style: .default, handler: { _ in
-            if let navigationController = UIStoryboard(name: "NCViewCertificateDetails", bundle: nil).instantiateInitialViewController() as? UINavigationController {
-                let viewController = navigationController.topViewController as! NCViewCertificateDetails
+            if let navigationController = UIStoryboard(name: "NCViewCertificateDetails", bundle: nil).instantiateInitialViewController() as? UINavigationController,
+               let viewController = navigationController.topViewController as? NCViewCertificateDetails {
                 viewController.delegate = self
                 viewController.host = host
                 self.window?.rootViewController?.present(navigationController, animated: true)
@@ -846,7 +843,8 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
                 case NCGlobal.shared.actionUploadAsset:
 
                     NCAskAuthorization.shared.askAuthorizationPhotoLibrary(viewController: rootViewController) { hasPermission in
-                        if hasPermission {NCPhotosPickerViewController(viewController: rootViewController, maxSelectedAssets: 0, singleSelectedMode: false)
+                        if hasPermission {
+                            NCPhotosPickerViewController(viewController: rootViewController, maxSelectedAssets: 0, singleSelectedMode: false)
                         }
                     }
 
@@ -856,11 +854,13 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
 
                 case NCGlobal.shared.actionTextDocument:
 
-                    guard let navigationController = UIStoryboard(name: "NCCreateFormUploadDocuments", bundle: nil).instantiateInitialViewController(), let directEditingCreators = NCManageDatabase.shared.getDirectEditingCreators(account: account), let directEditingCreator = directEditingCreators.first(where: { $0.editor == NCGlobal.shared.editorText}) else { return false }
+                    guard let navigationController = UIStoryboard(name: "NCCreateFormUploadDocuments", bundle: nil).instantiateInitialViewController(),
+                          let directEditingCreators = NCManageDatabase.shared.getDirectEditingCreators(account: account),
+                          let directEditingCreator = directEditingCreators.first(where: { $0.editor == NCGlobal.shared.editorText}),
+                          let viewController = (navigationController as? UINavigationController)?.topViewController as? NCCreateFormUploadDocuments else { return false }
 
                     navigationController.modalPresentationStyle = UIModalPresentationStyle.formSheet
 
-                    let viewController = (navigationController as! UINavigationController).topViewController as! NCCreateFormUploadDocuments
                     viewController.editorId = NCGlobal.shared.editorText
                     viewController.creatorId = directEditingCreator.identifier
                     viewController.typeTemplate = NCGlobal.shared.templateDocument
@@ -874,14 +874,15 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
                     NCAskAuthorization.shared.askAuthorizationAudioRecord(viewController: rootViewController) { hasPermission in
                         if hasPermission {
                             let fileName = CCUtility.createFileNameDate(NSLocalizedString("_voice_memo_filename_", comment: ""), extension: "m4a")!
-                            let viewController = UIStoryboard(name: "NCAudioRecorderViewController", bundle: nil).instantiateInitialViewController() as! NCAudioRecorderViewController
+                            if let viewController = UIStoryboard(name: "NCAudioRecorderViewController", bundle: nil).instantiateInitialViewController() as? NCAudioRecorderViewController {
 
-                            viewController.delegate = self
-                            viewController.createRecorder(fileName: fileName)
-                            viewController.modalTransitionStyle = .crossDissolve
-                            viewController.modalPresentationStyle = UIModalPresentationStyle.overCurrentContext
+                                viewController.delegate = self
+                                viewController.createRecorder(fileName: fileName)
+                                viewController.modalTransitionStyle = .crossDissolve
+                                viewController.modalPresentationStyle = UIModalPresentationStyle.overCurrentContext
 
-                            rootViewController.present(viewController, animated: true, completion: nil)
+                                rootViewController.present(viewController, animated: true, completion: nil)
+                            }
                         }
                     }
 

+ 7 - 4
iOSClient/Login/NCLogin.swift

@@ -36,7 +36,10 @@ 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 var textColor: UIColor = .white
     private var textColorOpponent: UIColor = .black
     private var activeTextfieldDiff: CGFloat = 0
@@ -213,7 +216,7 @@ class NCLogin: UIViewController, UITextFieldDelegate, NCLoginQRCodeDelegate {
 
         guard var url = baseUrl.text?.trimmingCharacters(in: .whitespacesAndNewlines) else { return }
         if url.hasSuffix("/") { url = String(url.dropLast()) }
-        if url.count == 0 { return }
+        if url.isEmpty { return }
 
         // Check whether baseUrl contain protocol. If not add https:// by default.
         if url.hasPrefix("https") == false && url.hasPrefix("http") == false {
@@ -327,8 +330,8 @@ class NCLogin: UIViewController, UITextFieldDelegate, NCLoginQRCodeDelegate {
                     alertController.addAction(UIAlertAction(title: NSLocalizedString("_no_", comment: ""), style: .default, handler: { _ in }))
 
                     alertController.addAction(UIAlertAction(title: NSLocalizedString("_certificate_details_", comment: ""), style: .default, handler: { _ in
-                        if let navigationController = UIStoryboard(name: "NCViewCertificateDetails", bundle: nil).instantiateInitialViewController() as? UINavigationController {
-                            let viewController = navigationController.topViewController as! NCViewCertificateDetails
+                        if let navigationController = UIStoryboard(name: "NCViewCertificateDetails", bundle: nil).instantiateInitialViewController() as? UINavigationController,
+                           let viewController = navigationController.topViewController as? NCViewCertificateDetails {
                             if let host = URL(string: url)?.host {
                                 viewController.host = host
                             }
@@ -391,7 +394,7 @@ class NCLogin: UIViewController, UITextFieldDelegate, NCLoginQRCodeDelegate {
             let account = user + " " + user
 
             NextcloudKit.shared.setup(account: account, user: user, userId: user, password: password, urlBase: urlBase)
-            NextcloudKit.shared.getUserProfile { _, userProfile, data, error in
+            NextcloudKit.shared.getUserProfile { _, userProfile, _, error in
 
                 if error == .success, let userProfile {
 

+ 6 - 2
iOSClient/Login/NCLoginWeb.swift

@@ -29,7 +29,11 @@ import FloatingPanel
 class NCLoginWeb: UIViewController {
 
     var webView: WKWebView?
+
+    // swiftlint:disable force_cast
     let appDelegate = UIApplication.shared.delegate as! AppDelegate
+    // swiftlint:enable force_cast
+
     var titleView: String = ""
 
     var urlBase = ""
@@ -232,7 +236,7 @@ extension NCLoginWeb: WKNavigationDelegate {
                 if value.contains("password:") { password = value }
             }
 
-            if server != "" && user != "" && password != "" {
+            if !server.isEmpty, !user.isEmpty, !password.isEmpty {
 
                 let server: String = server.replacingOccurrences(of: "/server:", with: "")
                 let username: String = user.replacingOccurrences(of: "user:", with: "").replacingOccurrences(of: "+", with: " ")
@@ -286,7 +290,7 @@ extension NCLoginWeb: WKNavigationDelegate {
         let user = username
 
         NextcloudKit.shared.setup(account: account, user: user, userId: user, password: password, urlBase: urlBase)
-        NextcloudKit.shared.getUserProfile { _, userProfile, data, error in
+        NextcloudKit.shared.getUserProfile { _, userProfile, _, error in
 
             if error == .success, let userProfile {
 

+ 29 - 34
iOSClient/Main/Collection Common/NCCollectionViewCommon.swift

@@ -31,7 +31,9 @@ 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 refreshControl = UIRefreshControl()
     internal var searchController: UISearchController?
@@ -198,7 +200,7 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
 
         NotificationCenter.default.addObserver(self, selector: #selector(triggerProgressTask(_:)), name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterProgressTask), object: nil)
 
-        if serverUrl == "" {
+        if serverUrl.isEmpty {
             appDelegate.activeServerUrl = NCUtilityFileSystem.shared.getHomeServer(urlBase: appDelegate.urlBase, userId: appDelegate.userId)
         } else {
             appDelegate.activeServerUrl = serverUrl
@@ -566,7 +568,7 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
     func showTip() {
 
         if self is NCFiles, self.view.window != nil, !NCBrandOptions.shared.disable_multiaccount, !NCBrandOptions.shared.disable_manage_account, self.serverUrl == NCUtilityFileSystem.shared.getHomeServer(urlBase: appDelegate.urlBase, userId: appDelegate.userId), let view = self.navigationItem.leftBarButtonItem?.customView {
-            if !NCManageDatabase.shared.tipExists(NCGlobal.shared.tipNCCollectionViewCommonAccountRequest), NCManageDatabase.shared.getAllAccountOrderAlias().count > 0 {
+            if !NCManageDatabase.shared.tipExists(NCGlobal.shared.tipNCCollectionViewCommonAccountRequest), !NCManageDatabase.shared.getAllAccountOrderAlias().isEmpty {
                 self.tipView?.show(forView: view)
             }
         }
@@ -612,7 +614,7 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
         button.action(for: .touchUpInside) { _ in
 
             let accounts = NCManageDatabase.shared.getAllAccountOrderAlias()
-            if accounts.count > 0 && !NCBrandOptions.shared.disable_multiaccount && !NCBrandOptions.shared.disable_manage_account {
+            if !accounts.isEmpty, !NCBrandOptions.shared.disable_multiaccount, !NCBrandOptions.shared.disable_manage_account {
 
                 if let vcAccountRequest = UIStoryboard(name: "NCAccountRequest", bundle: nil).instantiateInitialViewController() as? NCAccountRequest {
 
@@ -673,7 +675,7 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
             view.emptyTitle.text = NSLocalizedString("_request_in_progress_", comment: "")
             view.emptyDescription.text = ""
         } else {
-            if serverUrl == "" {
+            if serverUrl.isEmpty {
                 view.emptyImage.image = emptyImage
                 view.emptyTitle.text = NSLocalizedString(emptyTitle, comment: "")
                 view.emptyDescription.text = NSLocalizedString(emptyDescription, comment: "")
@@ -869,11 +871,11 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
 
         becomeFirstResponder()
 
-        if serverUrl != "" {
+        if !serverUrl.isEmpty {
             listMenuItems.append(UIMenuItem(title: NSLocalizedString("_paste_file_", comment: ""), action: #selector(pasteFilesMenu)))
         }
 
-        if listMenuItems.count > 0 {
+        if !listMenuItems.isEmpty {
             UIMenuController.shared.menuItems = listMenuItems
             UIMenuController.shared.showMenu(from: collectionView, rect: CGRect(x: touchPoint.x, y: touchPoint.y, width: 0, height: 0))
         }
@@ -946,7 +948,7 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
                     providers: self.providers,
                     searchResults: self.searchResults)
             } update: { _, _, searchResult, metadatas in
-                guard let metadatas = metadatas, metadatas.count > 0, self.isSearchingMode, let searchResult = searchResult else { return }
+                guard let metadatas, !metadatas.isEmpty, self.isSearchingMode, let searchResult else { return }
                 NCOperationQueue.shared.unifiedSearchAddSection(collectionViewCommon: self, metadatas: metadatas, searchResult: searchResult)
             } completion: { _, _ in
                 self.refreshControl.endRefreshing()
@@ -1172,9 +1174,9 @@ extension NCCollectionViewCommon: UICollectionViewDelegate {
         var image: UIImage?
         let cell = collectionView.cellForItem(at: indexPath)
         if cell is NCListCell {
-            image = (cell as! NCListCell).imageItem.image
+            image = (cell as? NCListCell)?.imageItem.image
         } else if cell is NCGridCell {
-            image = (cell as! NCGridCell).imageItem.image
+            image = (cell as? NCGridCell)?.imageItem.image
         }
 
         return UIContextMenuConfiguration(identifier: identifier, previewProvider: {
@@ -1206,7 +1208,7 @@ extension NCCollectionViewCommon: UICollectionViewDataSource {
         if !metadata.directory {
             if metadata.name == NCGlobal.shared.appName {
                     if let image = NCUtility.shared.createFilePreviewImage(ocId: metadata.ocId, etag: metadata.etag, fileNameView: metadata.fileNameView, classFile: metadata.classFile, status: metadata.status, createPreviewMedia: !metadata.hasPreview) {
-                    (cell as! NCCellProtocol).filePreviewImageView?.image = image
+                    (cell as? NCCellProtocol)?.filePreviewImageView?.image = image
                 } else {
                     NCOperationQueue.shared.downloadThumbnail(metadata: metadata, placeholder: true, cell: cell, view: collectionView)
                 }
@@ -1214,23 +1216,23 @@ extension NCCollectionViewCommon: UICollectionViewDataSource {
                 // Unified search
                 switch metadata.iconName {
                 case let str where str.contains("contacts"):
-                    (cell as! NCCellProtocol).filePreviewImageView?.image = NCBrandColor.cacheImages.iconContacts
+                    (cell as? NCCellProtocol)?.filePreviewImageView?.image = NCBrandColor.cacheImages.iconContacts
                 case let str where str.contains("conversation"):
-                    (cell as! NCCellProtocol).filePreviewImageView?.image = NCBrandColor.cacheImages.iconTalk
+                    (cell as? NCCellProtocol)?.filePreviewImageView?.image = NCBrandColor.cacheImages.iconTalk
                 case let str where str.contains("calendar"):
-                    (cell as! NCCellProtocol).filePreviewImageView?.image = NCBrandColor.cacheImages.iconCalendar
+                    (cell as? NCCellProtocol)?.filePreviewImageView?.image = NCBrandColor.cacheImages.iconCalendar
                 case let str where str.contains("deck"):
-                    (cell as! NCCellProtocol).filePreviewImageView?.image = NCBrandColor.cacheImages.iconDeck
+                    (cell as? NCCellProtocol)?.filePreviewImageView?.image = NCBrandColor.cacheImages.iconDeck
                 case let str where str.contains("mail"):
-                    (cell as! NCCellProtocol).filePreviewImageView?.image = NCBrandColor.cacheImages.iconMail
+                    (cell as? NCCellProtocol)?.filePreviewImageView?.image = NCBrandColor.cacheImages.iconMail
                 case let str where str.contains("talk"):
-                    (cell as! NCCellProtocol).filePreviewImageView?.image = NCBrandColor.cacheImages.iconTalk
+                    (cell as? NCCellProtocol)?.filePreviewImageView?.image = NCBrandColor.cacheImages.iconTalk
                 case let str where str.contains("confirm"):
-                    (cell as! NCCellProtocol).filePreviewImageView?.image = NCBrandColor.cacheImages.iconConfirm
+                    (cell as? NCCellProtocol)?.filePreviewImageView?.image = NCBrandColor.cacheImages.iconConfirm
                 case let str where str.contains("pages"):
-                    (cell as! NCCellProtocol).filePreviewImageView?.image = NCBrandColor.cacheImages.iconPages
+                    (cell as? NCCellProtocol)?.filePreviewImageView?.image = NCBrandColor.cacheImages.iconPages
                 default:
-                    (cell as! NCCellProtocol).filePreviewImageView?.image = NCBrandColor.cacheImages.file
+                    (cell as? NCCellProtocol)?.filePreviewImageView?.image = NCBrandColor.cacheImages.file
                 }
 
                 if !metadata.iconUrl.isEmpty {
@@ -1243,7 +1245,7 @@ extension NCCollectionViewCommon: UICollectionViewDataSource {
         }
 
         // Avatar
-        if metadata.ownerId.count > 0,
+        if !metadata.ownerId.isEmpty,
            metadata.ownerId != appDelegate.userId,
            appDelegate.account == metadata.account,
            let cell = cell as? NCCellProtocol {
@@ -1415,32 +1417,25 @@ extension NCCollectionViewCommon: UICollectionViewDataSource {
         switch metadata.status {
         case NCGlobal.shared.metadataStatusWaitDownload:
             cell.fileInfoLabel?.text = CCUtility.transformedSize(metadata.size) + " - " + NSLocalizedString("_status_wait_download_", comment: "")
-            break
         case NCGlobal.shared.metadataStatusInDownload:
             cell.fileInfoLabel?.text = CCUtility.transformedSize(metadata.size) + " - " + NSLocalizedString("_status_in_download_", comment: "")
-            break
         case NCGlobal.shared.metadataStatusDownloading:
             cell.fileInfoLabel?.text = CCUtility.transformedSize(metadata.size) + " - ↓ …"
-            break
         case NCGlobal.shared.metadataStatusWaitUpload:
             cell.fileInfoLabel?.text = CCUtility.transformedSize(metadata.size) + " - " + NSLocalizedString("_status_wait_upload_", comment: "")
             cell.fileLocalImage?.image = nil
-            break
         case NCGlobal.shared.metadataStatusInUpload:
             cell.fileInfoLabel?.text = CCUtility.transformedSize(metadata.size) + " - " + NSLocalizedString("_status_in_upload_", comment: "")
             cell.fileLocalImage?.image = nil
-            break
         case NCGlobal.shared.metadataStatusUploading:
             cell.fileInfoLabel?.text = CCUtility.transformedSize(metadata.size) + " - ↑ …"
             cell.fileLocalImage?.image = nil
-            break
         case NCGlobal.shared.metadataStatusUploadError:
-            if metadata.sessionError != "" {
-                cell.fileInfoLabel?.text = NSLocalizedString("_status_wait_upload_", comment: "") + " " + metadata.sessionError
-            } else {
+            if metadata.sessionError.isEmpty {
                 cell.fileInfoLabel?.text = NSLocalizedString("_status_wait_upload_", comment: "")
+            } else {
+                cell.fileInfoLabel?.text = NSLocalizedString("_status_wait_upload_", comment: "") + " " + metadata.sessionError
             }
-            break
         default:
             break
         }
@@ -1511,7 +1506,7 @@ extension NCCollectionViewCommon: UICollectionViewDataSource {
 
             if indexPath.section == 0 {
 
-                let header = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: "sectionHeaderMenu", for: indexPath) as! NCSectionHeaderMenu
+                guard let header = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: "sectionHeaderMenu", for: indexPath) as? NCSectionHeaderMenu else { return UICollectionReusableView() }
                 let (_, heightHeaderRichWorkspace, heightHeaderSection) = getHeaderHeight(section: indexPath.section)
 
                 self.headerMenu = header
@@ -1556,7 +1551,7 @@ extension NCCollectionViewCommon: UICollectionViewDataSource {
 
             } else {
 
-                let header = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: "sectionHeader", for: indexPath) as! NCSectionHeader
+                guard let header = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: "sectionHeader", for: indexPath) as? NCSectionHeader else { return UICollectionReusableView() }
 
                 header.labelSection.text = self.dataSource.getSectionValueLocalization(indexPath: indexPath)
                 header.labelSection.textColor = .label
@@ -1566,7 +1561,7 @@ extension NCCollectionViewCommon: UICollectionViewDataSource {
 
         } else {
 
-            let footer = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: "sectionFooter", for: indexPath) as! NCSectionFooter
+            guard let footer = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: "sectionFooter", for: indexPath) as? NCSectionFooter else { return UICollectionReusableView() }
             let sections = dataSource.numberOfSections()
             let section = indexPath.section
             let metadataForSection = self.dataSource.getMetadataForSection(indexPath.section)
@@ -1644,7 +1639,7 @@ extension NCCollectionViewCommon: UICollectionViewDelegateFlowLayout {
 
         if let richWorkspaceText = richWorkspaceText, !headerRichWorkspaceDisable {
             let trimmed = richWorkspaceText.trimmingCharacters(in: .whitespaces)
-            if trimmed.count > 0 && !isSearchingMode {
+            if !trimmed.isEmpty && !isSearchingMode {
                 headerRichWorkspace = UIScreen.main.bounds.size.height / 6
             }
         }

+ 1 - 1
iOSClient/Main/Collection Common/NCListCell.swift

@@ -54,7 +54,7 @@ class NCListCell: UICollectionViewCell, UIGestureRecognizerDelegate, NCCellProto
     var namedButtonMore = ""
 
     var fileAvatarImageView: UIImageView? {
-        get { return imageShared }
+        return imageShared
     }
     var fileObjectId: String? {
         get { return objectId }

+ 12 - 12
iOSClient/Main/Create cloud/NCCreateFormUploadConflict.swift

@@ -27,7 +27,7 @@ import NextcloudKit
 import Photos
 import JGProgressHUD
 
-protocol NCCreateFormUploadConflictDelegate {
+protocol NCCreateFormUploadConflictDelegate: AnyObject {
     func dismissCreateFormUploadConflict(metadatas: [tableMetadata]?)
 }
 
@@ -256,7 +256,7 @@ class NCCreateFormUploadConflict: UIViewController {
                 metadata.fileNameView = newFileName
 
                 // This is not an asset - [file]
-                if metadata.assetLocalIdentifier == "" || metadata.isExtractFile {
+                if metadata.assetLocalIdentifier.isEmpty || metadata.isExtractFile {
                     let newPath = CCUtility.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: newFileName)
                     CCUtility.moveFile(atPath: oldPath, toPath: newPath)
                 }
@@ -335,10 +335,10 @@ extension NCCreateFormUploadConflict: UITableViewDataSource {
                 }
 
             } else {
-                if metadataAlreadyExists.iconName.count > 0 {
-                    cell.imageAlreadyExistingFile.image = UIImage(named: metadataAlreadyExists.iconName)
-                } else {
+                if metadataAlreadyExists.iconName.isEmpty {
                     cell.imageAlreadyExistingFile.image = UIImage(named: "file")
+                } else {
+                    cell.imageAlreadyExistingFile.image = UIImage(named: metadataAlreadyExists.iconName)
                 }
             }
             cell.labelDetailAlreadyExistingFile.text = CCUtility.dateDiff(metadataAlreadyExists.date as Date) + "\n" + CCUtility.transformedSize(metadataAlreadyExists.size)
@@ -351,13 +351,13 @@ extension NCCreateFormUploadConflict: UITableViewDataSource {
 
             // -----> New File
 
-            if metadataNewFile.iconName.count > 0 {
-                cell.imageNewFile.image = UIImage(named: metadataNewFile.iconName)
-            } else {
+            if metadataNewFile.iconName.isEmpty {
                 cell.imageNewFile.image = UIImage(named: "file")
+            } else {
+                cell.imageNewFile.image = UIImage(named: metadataNewFile.iconName)
             }
             let filePathNewFile = CCUtility.getDirectoryProviderStorageOcId(metadataNewFile.ocId, fileNameView: metadataNewFile.fileNameView)!
-            if metadataNewFile.assetLocalIdentifier.count > 0 {
+            if !metadataNewFile.assetLocalIdentifier.isEmpty {
 
                 let result = PHAsset.fetchAssets(withLocalIdentifiers: [metadataNewFile.assetLocalIdentifier], options: nil)
                 let date = result.firstObject!.modificationDate
@@ -378,7 +378,7 @@ extension NCCreateFormUploadConflict: UITableViewDataSource {
                         }
 
                         let fileDictionary = try FileManager.default.attributesOfItem(atPath: fileNamePath)
-                        let fileSize = fileDictionary[FileAttributeKey.size] as! Int64
+                        let fileSize = fileDictionary[FileAttributeKey.size] as? Int64 ?? 0
 
                         cell.labelDetailNewFile.text = CCUtility.dateDiff(date) + "\n" + CCUtility.transformedSize(fileSize)
 
@@ -393,7 +393,7 @@ extension NCCreateFormUploadConflict: UITableViewDataSource {
                             self.fileNamesPath[metadataNewFile.fileNameView] = fileNamePath!
                             do {
                                 let fileDictionary = try FileManager.default.attributesOfItem(atPath: fileNamePath!)
-                                let fileSize = fileDictionary[FileAttributeKey.size] as! Int64
+                                let fileSize = fileDictionary[FileAttributeKey.size] as? Int64 ?? 0
                                 if mediaType == PHAssetMediaType.image {
                                     let data = try Data(contentsOf: URL(fileURLWithPath: fileNamePath!))
                                     if let image = UIImage(data: data) {
@@ -421,7 +421,7 @@ extension NCCreateFormUploadConflict: UITableViewDataSource {
                     }
 
                     let fileDictionary = try FileManager.default.attributesOfItem(atPath: filePathNewFile)
-                    let fileSize = fileDictionary[FileAttributeKey.size] as! Int64
+                    let fileSize = fileDictionary[FileAttributeKey.size] as? Int64 ?? 0
 
                     cell.labelDetailNewFile.text = CCUtility.dateDiff(metadataNewFile.date as Date) + "\n" + CCUtility.transformedSize(fileSize)
 

+ 50 - 58
iOSClient/Main/Create cloud/NCCreateFormUploadDocuments.swift

@@ -33,7 +33,9 @@ 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
 
     var editorId = ""
     var creatorId = ""
@@ -136,10 +138,10 @@ import XLForm
     }
 
     override func tableView(_ tableView: UITableView, willDisplayHeaderView view: UIView, forSection section: Int) {
-        let header: UITableViewHeaderFooterView = view as! UITableViewHeaderFooterView
-        header.textLabel?.font = UIFont.systemFont(ofSize: 13.0)
-        header.textLabel?.textColor = .gray
-        header.tintColor = tableView.backgroundColor
+        let header = view as? UITableViewHeaderFooterView
+        header?.textLabel?.font = UIFont.systemFont(ofSize: 13.0)
+        header?.textLabel?.textColor = .gray
+        header?.tintColor = tableView.backgroundColor
     }
 
     // MARK: - CollectionView
@@ -165,13 +167,13 @@ import XLForm
         let template = listOfTemplate[indexPath.row]
 
         // image
-        let imagePreview = cell.viewWithTag(100) as! UIImageView
-        if template.preview != "" {
+        let imagePreview = cell.viewWithTag(100) as? UIImageView
+        if !template.preview.isEmpty {
             let fileNameLocalPath = String(CCUtility.getDirectoryUserData()) + "/" + template.name + ".png"
             if FileManager.default.fileExists(atPath: fileNameLocalPath) {
                 let imageURL = URL(fileURLWithPath: fileNameLocalPath)
                 if let image = UIImage(contentsOfFile: imageURL.path) {
-                    imagePreview.image = image
+                    imagePreview?.image = image
                 }
             } else {
                 getImageFromTemplate(name: template.name, preview: template.preview, indexPath: indexPath)
@@ -179,19 +181,19 @@ import XLForm
         }
 
         // name
-        let name = cell.viewWithTag(200) as! UILabel
-        name.text = template.name
-        name.textColor = .secondarySystemGroupedBackground
+        let name = cell.viewWithTag(200) as? UILabel
+        name?.text = template.name
+        name?.textColor = .secondarySystemGroupedBackground
 
         // select
-        let imageSelect = cell.viewWithTag(300) as! UIImageView
+        let imageSelect = cell.viewWithTag(300) as? UIImageView
         if selectTemplate != nil && selectTemplate?.name == template.name {
             cell.backgroundColor = .label
-            imageSelect.image = UIImage(named: "plus100")
-            imageSelect.isHidden = false
+            imageSelect?.image = UIImage(named: "plus100")
+            imageSelect?.isHidden = false
         } else {
             cell.backgroundColor = .secondarySystemGroupedBackground
-            imageSelect.isHidden = true
+            imageSelect?.isHidden = true
         }
 
         return cell
@@ -233,13 +235,14 @@ import XLForm
         self.deselectFormRow(sender)
 
         let storyboard = UIStoryboard(name: "NCSelect", bundle: nil)
-        let navigationController = storyboard.instantiateInitialViewController() as! UINavigationController
-        let viewController = navigationController.topViewController as! NCSelect
+        if let navigationController = storyboard.instantiateInitialViewController() as? UINavigationController,
+           let viewController = navigationController.topViewController as? NCSelect {
 
-        viewController.delegate = self
-        viewController.typeOfCommandView = .selectCreateFolder
+            viewController.delegate = self
+            viewController.typeOfCommandView = .selectCreateFolder
 
-        self.present(navigationController, animated: true, completion: nil)
+            self.present(navigationController, animated: true, completion: nil)
+        }
     }
 
     @objc func save() {
@@ -250,58 +253,47 @@ import XLForm
         templateIdentifier = selectTemplate.identifier
 
         let rowFileName: XLFormRowDescriptor = self.form.formRow(withTag: "fileName")!
-        guard var fileNameForm = rowFileName.value else {
-            return
-        }
-
-        if fileNameForm as! String == "" {
-            return
-        } else {
+        guard var fileNameForm: String = rowFileName.value as? String, !fileNameForm.isEmpty else { return }
 
-            // Trim whitespaces after checks above
-            fileNameForm = (fileNameForm as! String).trimmingCharacters(in: .whitespacesAndNewlines)
+        // Trim whitespaces after checks above
+        fileNameForm = fileNameForm.trimmingCharacters(in: .whitespacesAndNewlines)
 
-            let result = NextcloudKit.shared.nkCommonInstance.getInternalType(fileName: fileNameForm as! String, mimeType: "", directory: false)
-            if NCUtility.shared.isDirectEditing(account: appDelegate.account, contentType: result.mimeType).count == 0 {
-                fileNameForm = (fileNameForm as! NSString).deletingPathExtension + "." + fileNameExtension
-            }
+        let result = NextcloudKit.shared.nkCommonInstance.getInternalType(fileName: fileNameForm, mimeType: "", directory: false)
+        if NCUtility.shared.isDirectEditing(account: appDelegate.account, contentType: result.mimeType).isEmpty {
+            fileNameForm = (fileNameForm as NSString).deletingPathExtension + "." + fileNameExtension
+        }
 
-            if NCManageDatabase.shared.getMetadataConflict(account: appDelegate.account, serverUrl: serverUrl, fileNameView: String(describing: fileNameForm)) != nil {
+        if NCManageDatabase.shared.getMetadataConflict(account: appDelegate.account, serverUrl: serverUrl, fileNameView: String(describing: fileNameForm)) != nil {
 
-                let metadataForUpload = NCManageDatabase.shared.createMetadata(account: appDelegate.account, user: appDelegate.user, userId: appDelegate.userId, fileName: String(describing: fileNameForm), fileNameView: String(describing: fileNameForm), ocId: "", serverUrl: serverUrl, urlBase: appDelegate.urlBase, url: "", contentType: "")
+            let metadataForUpload = NCManageDatabase.shared.createMetadata(account: appDelegate.account, user: appDelegate.user, userId: appDelegate.userId, fileName: String(describing: fileNameForm), fileNameView: String(describing: fileNameForm), ocId: "", serverUrl: serverUrl, urlBase: appDelegate.urlBase, url: "", contentType: "")
 
-                guard let conflict = UIStoryboard(name: "NCCreateFormUploadConflict", bundle: nil).instantiateInitialViewController() as? NCCreateFormUploadConflict else { return }
+            guard let conflict = UIStoryboard(name: "NCCreateFormUploadConflict", bundle: nil).instantiateInitialViewController() as? NCCreateFormUploadConflict else { return }
 
-                conflict.textLabelDetailNewFile = NSLocalizedString("_now_", comment: "")
-                conflict.alwaysNewFileNameNumber = true
-                conflict.serverUrl = serverUrl
-                conflict.metadatasUploadInConflict = [metadataForUpload]
-                conflict.delegate = self
+            conflict.textLabelDetailNewFile = NSLocalizedString("_now_", comment: "")
+            conflict.alwaysNewFileNameNumber = true
+            conflict.serverUrl = serverUrl
+            conflict.metadatasUploadInConflict = [metadataForUpload]
+            conflict.delegate = self
 
-                self.present(conflict, animated: true, completion: nil)
+            self.present(conflict, animated: true, completion: nil)
 
-            } else {
+        } else {
 
-                let fileNamePath = CCUtility.returnFileNamePath(fromFileName: String(describing: fileNameForm), serverUrl: serverUrl, urlBase: appDelegate.urlBase, userId: appDelegate.userId, account: appDelegate.account)!
-                createDocument(fileNamePath: fileNamePath, fileName: String(describing: fileNameForm))
-            }
+            let fileNamePath = CCUtility.returnFileNamePath(fromFileName: String(describing: fileNameForm), serverUrl: serverUrl, urlBase: appDelegate.urlBase, userId: appDelegate.userId, account: appDelegate.account)!
+            createDocument(fileNamePath: fileNamePath, fileName: String(describing: fileNameForm))
         }
     }
 
     func dismissCreateFormUploadConflict(metadatas: [tableMetadata]?) {
 
-        if metadatas == nil || metadatas?.count == 0 {
-
+        if let metadatas {
+            let fileName = metadatas[0].fileName
+            let fileNamePath = CCUtility.returnFileNamePath(fromFileName: fileName, serverUrl: serverUrl, urlBase: appDelegate.urlBase, userId: appDelegate.userId, account: appDelegate.account)!
+            createDocument(fileNamePath: fileNamePath, fileName: fileName)
+        } else {
             DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) {
                 self.cancel()
             }
-
-        } else {
-
-            let fileName = metadatas![0].fileName
-            let fileNamePath = CCUtility.returnFileNamePath(fromFileName: fileName, serverUrl: serverUrl, urlBase: appDelegate.urlBase, userId: appDelegate.userId, account: appDelegate.account)!
-
-            createDocument(fileNamePath: fileNamePath, fileName: fileName)
         }
     }
 
@@ -401,7 +393,7 @@ import XLForm
                         self.listOfTemplate.append(temp)
 
                         // default: template empty
-                        if temp.preview == "" {
+                        if temp.preview.isEmpty {
                             self.selectTemplate = temp
                             self.fileNameExtension = template.ext
                             self.navigationItem.rightBarButtonItem?.isEnabled = true
@@ -409,7 +401,7 @@ import XLForm
                     }
                 }
 
-                if self.listOfTemplate.count == 0 {
+                if self.listOfTemplate.isEmpty {
 
                     let temp = NKEditorTemplates()
 
@@ -460,7 +452,7 @@ import XLForm
                         self.listOfTemplate.append(temp)
 
                         // default: template empty
-                        if temp.preview == "" {
+                        if temp.preview.isEmpty {
                             self.selectTemplate = temp
                             self.fileNameExtension = temp.ext
                             self.navigationItem.rightBarButtonItem?.isEnabled = true
@@ -468,7 +460,7 @@ import XLForm
                     }
                 }
 
-                if self.listOfTemplate.count == 0 {
+                if self.listOfTemplate.isEmpty {
 
                     let temp = NKEditorTemplates()
 

+ 20 - 20
iOSClient/Main/Create cloud/NCCreateFormUploadVoiceNote.swift

@@ -31,7 +31,9 @@ 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 var serverUrl = ""
     private var titleServerUrl = ""
@@ -182,10 +184,10 @@ class NCCreateFormUploadVoiceNote: XLFormViewController, NCSelectDelegate, AVAud
     // MARK: TableViewDelegate
 
     override func tableView(_ tableView: UITableView, willDisplayHeaderView view: UIView, forSection section: Int) {
-        let header: UITableViewHeaderFooterView = view as! UITableViewHeaderFooterView
-        header.textLabel?.font = UIFont.systemFont(ofSize: 13.0)
-        header.textLabel?.textColor = .gray
-        header.tintColor = cellBackgoundColor
+        let header = view as? UITableViewHeaderFooterView
+        header?.textLabel?.font = UIFont.systemFont(ofSize: 13.0)
+        header?.textLabel?.textColor = .gray
+        header?.tintColor = cellBackgoundColor
     }
 
     // MARK: - Action
@@ -212,16 +214,14 @@ class NCCreateFormUploadVoiceNote: XLFormViewController, NCSelectDelegate, AVAud
     @objc func save() {
 
         let rowFileName: XLFormRowDescriptor = self.form.formRow(withTag: "fileName")!
-        guard let name = rowFileName.value else {
-            return
-        }
-        let ext = (name as! NSString).pathExtension.uppercased()
+        guard let name = rowFileName.value as? String else { return }
+        let ext = (name as NSString).pathExtension.uppercased()
         var fileNameSave = ""
 
-        if ext == "" {
-            fileNameSave = name as! String + ".m4a"
+        if ext.isEmpty {
+            fileNameSave = name + ".m4a"
         } else {
-            fileNameSave = (name as! NSString).deletingPathExtension + ".m4a"
+            fileNameSave = (name as NSString).deletingPathExtension + ".m4a"
         }
 
         let metadataForUpload = NCManageDatabase.shared.createMetadata(account: self.appDelegate.account, user: self.appDelegate.user, userId: self.appDelegate.userId, fileName: fileNameSave, fileNameView: fileNameSave, ocId: UUID().uuidString, serverUrl: self.serverUrl, urlBase: self.appDelegate.urlBase, url: "", contentType: "")
@@ -250,10 +250,9 @@ class NCCreateFormUploadVoiceNote: XLFormViewController, NCSelectDelegate, AVAud
 
     func dismissCreateFormUploadConflict(metadatas: [tableMetadata]?) {
 
-        if metadatas != nil && metadatas!.count > 0 {
-
+        if let metadatas {
             DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) {
-                self.dismissAndUpload(metadatas![0])
+                self.dismissAndUpload(metadatas[0])
             }
         }
     }
@@ -278,14 +277,15 @@ class NCCreateFormUploadVoiceNote: XLFormViewController, NCSelectDelegate, AVAud
         self.deselectFormRow(sender)
 
         let storyboard = UIStoryboard(name: "NCSelect", bundle: nil)
-        let navigationController = storyboard.instantiateInitialViewController() as! UINavigationController
-        let viewController = navigationController.topViewController as! NCSelect
+        if let navigationController = storyboard.instantiateInitialViewController() as? UINavigationController,
+           let viewController = navigationController.topViewController as? NCSelect {
 
-        viewController.delegate = self
-        viewController.typeOfCommandView = .selectCreateFolder
-        viewController.includeDirectoryE2EEncryption = true
+            viewController.delegate = self
+            viewController.typeOfCommandView = .selectCreateFolder
+            viewController.includeDirectoryE2EEncryption = true
 
-        self.present(navigationController, animated: true, completion: nil)
+            self.present(navigationController, animated: true, completion: nil)
+        }
     }
 
     // MARK: Player - Timer

+ 8 - 5
iOSClient/Main/Create cloud/NCCreateMenuAdd.swift

@@ -26,7 +26,10 @@ import Sheeeeeeeeet
 
 class NCCreateMenuAdd: NSObject {
 
+    // swiftlint:disable force_cast
     weak var appDelegate = UIApplication.shared.delegate as! AppDelegate
+    // swiftlint:enable force_cast
+
     var isNextcloudTextAvailable = false
 
     @objc init(viewController: UIViewController, view: UIView) {
@@ -68,7 +71,7 @@ class NCCreateMenuAdd: NSObject {
         items.append(MenuItem(title: NSLocalizedString("_create_folder_", comment: ""), value: 60, image: CCGraphics.changeThemingColorImage(UIImage(named: "folder"), width: 50, height: 50, color: NCBrandColor.sharedInstance.brandElement)))
 
         if let richdocumentsMimetypes = NCManageDatabase.sharedInstance.getRichdocumentsMimetypes(account: appDelegate.activeAccount) {
-            if richdocumentsMimetypes.count > 0 {
+            if !richdocumentsMimetypes.isEmpty {
                 items.append(MenuItem(title: NSLocalizedString("_create_new_document_", comment: ""), value: 70, image: UIImage(named: "create_file_document")))
                 items.append(MenuItem(title: NSLocalizedString("_create_new_spreadsheet_", comment: ""), value: 80, image: UIImage(named: "create_file_xls")))
                 items.append(MenuItem(title: NSLocalizedString("_create_new_presentation_", comment: ""), value: 90, image: UIImage(named: "create_file_ppt")))
@@ -96,7 +99,7 @@ class NCCreateMenuAdd: NSObject {
                 }
                 navigationController.modalPresentationStyle = UIModalPresentationStyle.formSheet
 
-                let viewController = (navigationController as! UINavigationController).topViewController as! NCCreateFormUploadDocuments
+                let viewController = (navigationController as? UINavigationController)?.topViewController as? NCCreateFormUploadDocuments
                 viewController.typeTemplate = k_template_document
                 viewController.serverUrl = self.appDelegate.activeMain.serverUrl
                 viewController.titleForm = NSLocalizedString("_create_nextcloudtext_document_", comment: "")
@@ -119,7 +122,7 @@ class NCCreateMenuAdd: NSObject {
                 }
                 navigationController.modalPresentationStyle = UIModalPresentationStyle.formSheet
 
-                let viewController = (navigationController as! UINavigationController).topViewController as! NCCreateFormUploadDocuments
+                let viewController = (navigationController as? UINavigationController).topViewController as? NCCreateFormUploadDocuments
                 viewController.typeTemplate = k_template_document
                 viewController.serverUrl = self.appDelegate.activeMain.serverUrl
                 viewController.titleForm = NSLocalizedString("_create_new_document_", comment: "")
@@ -132,7 +135,7 @@ class NCCreateMenuAdd: NSObject {
                 }
                 navigationController.modalPresentationStyle = UIModalPresentationStyle.formSheet
 
-                let viewController = (navigationController as! UINavigationController).topViewController as! NCCreateFormUploadDocuments
+                let viewController = (navigationController as? UINavigationController).topViewController as? NCCreateFormUploadDocuments
                 viewController.typeTemplate = k_template_spreadsheet
                 viewController.serverUrl = self.appDelegate.activeMain.serverUrl
                 viewController.titleForm = NSLocalizedString("_create_new_spreadsheet_", comment: "")
@@ -145,7 +148,7 @@ class NCCreateMenuAdd: NSObject {
                 }
                 navigationController.modalPresentationStyle = UIModalPresentationStyle.formSheet
 
-                let viewController = (navigationController as! UINavigationController).topViewController as! NCCreateFormUploadDocuments
+                let viewController = (navigationController as? UINavigationController).topViewController as? NCCreateFormUploadDocuments
                 viewController.typeTemplate = k_template_presentation
                 viewController.serverUrl = self.appDelegate.activeMain.serverUrl
                 viewController.titleForm = NSLocalizedString("_create_new_presentation_", comment: "")

+ 7 - 6
iOSClient/Main/NCMainTabBar.swift

@@ -28,16 +28,17 @@ 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 centerButtonY: CGFloat = -28
 
     public var menuRect: CGRect {
-        get {
-            let tabBarItemWidth = Int(self.frame.size.width) / (self.items?.count ?? 0)
-            let rect = CGRect(x: 0, y: -5, width: tabBarItemWidth, height: Int(self.frame.size.height))
-
-            return rect
-        }
+        let tabBarItemWidth = Int(self.frame.size.width) / (self.items?.count ?? 0)
+        let rect = CGRect(x: 0, y: -5, width: tabBarItemWidth, height: Int(self.frame.size.height))
+        return rect
     }
 
     // MARK: - Life Cycle

+ 8 - 2
iOSClient/Main/NCPickerViewController.swift

@@ -31,7 +31,10 @@ import NextcloudKit
 
 class NCPhotosPickerViewController: NSObject {
 
+    // swiftlint:disable force_cast
     let appDelegate = UIApplication.shared.delegate as! AppDelegate
+    // swiftlint:enable force_cast
+
     var sourceViewController: UIViewController
     var maxSelectedAssets = 1
     var singleSelectedMode = false
@@ -115,7 +118,10 @@ class customPhotoPickerViewController: TLPhotosPickerViewController {
 
 class NCDocumentPickerViewController: NSObject, UIDocumentPickerDelegate {
 
+    // swiftlint:disable force_cast
     let appDelegate = UIApplication.shared.delegate as! AppDelegate
+    // swiftlint:enable force_cast
+
     var isViewerMedia: Bool
     var viewController: UIViewController?
 
@@ -165,7 +171,7 @@ class NCDocumentPickerViewController: NSObject, UIDocumentPickerDelegate {
                 let toPath = CCUtility.getDirectoryProviderStorageOcId(ocId, fileNameView: fileName)!
                 let urlOut = URL(fileURLWithPath: toPath)
 
-                guard let _ = self.copySecurityScopedResource(url: urlIn, urlOut: urlOut) else { continue }
+                guard self.copySecurityScopedResource(url: urlIn, urlOut: urlOut) != nil else { continue }
 
                 let metadataForUpload = NCManageDatabase.shared.createMetadata(account: appDelegate.account, user: appDelegate.user, userId: appDelegate.userId, fileName: fileName, fileNameView: fileName, ocId: ocId, serverUrl: serverUrl, urlBase: appDelegate.urlBase, url: "", contentType: "")
 
@@ -174,7 +180,7 @@ class NCDocumentPickerViewController: NSObject, UIDocumentPickerDelegate {
                 metadataForUpload.size = NCUtilityFileSystem.shared.getFileSize(filePath: toPath)
                 metadataForUpload.status = NCGlobal.shared.metadataStatusWaitUpload
 
-                if let _ = NCManageDatabase.shared.getMetadataConflict(account: appDelegate.account, serverUrl: serverUrl, fileNameView: fileName) {
+                if NCManageDatabase.shared.getMetadataConflict(account: appDelegate.account, serverUrl: serverUrl, fileNameView: fileName) != nil {
                     metadatasInConflict.append(metadataForUpload)
                 } else {
                     metadatas.append(metadataForUpload)

+ 11 - 8
iOSClient/Media/NCMedia.swift

@@ -34,7 +34,9 @@ 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
 
     public var metadatas: [tableMetadata] = []
     private var account: String = ""
@@ -385,9 +387,10 @@ extension NCMedia: UICollectionViewDataSource {
 
     func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
 
+        guard let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "gridCell", for: indexPath) as? NCGridMediaCell else { return UICollectionViewCell() }
+
         if indexPath.section < collectionView.numberOfSections && indexPath.row < collectionView.numberOfItems(inSection: indexPath.section) && indexPath.row < metadatas.count {
 
-            let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "gridCell", for: indexPath) as! NCGridMediaCell
             let metadata = metadatas[indexPath.row]
 
             self.cellHeigth = cell.frame.size.height
@@ -418,7 +421,7 @@ extension NCMedia: UICollectionViewDataSource {
 
         } else {
 
-            return collectionView.dequeueReusableCell(withReuseIdentifier: "gridCell", for: indexPath) as! NCGridMediaCell
+            return cell
         }
     }
 }
@@ -496,7 +499,7 @@ extension NCMedia {
 
     func updateMediaControlVisibility() {
 
-        if self.metadatas.count == 0 {
+        if self.metadatas.isEmpty {
             if !self.filterClassTypeImage && !self.filterClassTypeVideo {
                 self.mediaCommandView?.toggleEmptyView(isEmpty: true)
                 self.mediaCommandView?.isHidden = false
@@ -549,13 +552,13 @@ extension NCMedia {
             }
 
             if error == .success && account == self.appDelegate.account {
-                if files.count > 0 {
+                if !files.isEmpty {
                     NCManageDatabase.shared.convertFilesToMetadatas(files, useMetadataFolder: false) { _, _, metadatas in
                         let predicateDate = NSPredicate(format: "date > %@ AND date < %@", greaterDate as NSDate, lessDate as NSDate)
                         let predicateResult = NSCompoundPredicate(andPredicateWithSubpredicates: [predicateDate, self.predicateDefault!])
                         let metadatasResult = NCManageDatabase.shared.getMetadatas(predicate: predicateResult)
                         let metadatasChanged = NCManageDatabase.shared.updateMetadatas(metadatas, metadatasResult: metadatasResult, addCompareLivePhoto: false)
-                        if metadatasChanged.metadatasUpdate.count == 0 {
+                        if metadatasChanged.metadatasUpdate.isEmpty {
                             self.researchOldMedia(value: value, limit: limit, withElseReloadDataSource: true)
                         } else {
                             self.reloadDataSourceWithCompletion { _ in }
@@ -630,17 +633,17 @@ extension NCMedia {
                     self.mediaCommandView?.activityIndicator.stopAnimating()
                 }
 
-                if error == .success && account == self.appDelegate.account && files.count > 0 {
+                if error == .success, account == self.appDelegate.account, !files.isEmpty {
                     NCManageDatabase.shared.convertFilesToMetadatas(files, useMetadataFolder: false) { _, _, metadatas in
                         let predicate = NSPredicate(format: "date > %@ AND date < %@", greaterDate as NSDate, lessDate as NSDate)
                         let predicateResult = NSCompoundPredicate(andPredicateWithSubpredicates: [predicate, self.predicate!])
                         let metadatasResult = NCManageDatabase.shared.getMetadatas(predicate: predicateResult)
                         let updateMetadatas = NCManageDatabase.shared.updateMetadatas(metadatas, metadatasResult: metadatasResult, addCompareLivePhoto: false)
-                        if updateMetadatas.metadatasUpdate.count > 0 || updateMetadatas.metadatasDelete.count > 0 {
+                        if !updateMetadatas.metadatasUpdate.isEmpty || !updateMetadatas.metadatasDelete.isEmpty {
                             self.reloadDataSourceWithCompletion { _ in }
                         }
                     }
-                } else if error == .success && files.count == 0 && self.metadatas.count == 0 {
+                } else if error == .success, files.isEmpty, self.metadatas.isEmpty {
                     self.searchOldMedia()
                 } else if error != .success {
                     NextcloudKit.shared.nkCommonInstance.writeLog("[ERROR] Media search new media error code \(error.errorCode) " + error.errorDescription)

+ 4 - 4
iOSClient/Media/NCMediaCommandView.xib

@@ -1,9 +1,9 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="21701" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
+<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="22154" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
     <device id="retina6_12" orientation="portrait" appearance="light"/>
     <dependencies>
         <deployment identifier="iOS"/>
-        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="21678"/>
+        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="22130"/>
         <capability name="Image references" minToolsVersion="12.0"/>
         <capability name="Safe area layout guides" minToolsVersion="9.0"/>
         <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
@@ -29,7 +29,7 @@
                                 </constraints>
                                 <color key="tintColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
                                 <inset key="imageEdgeInsets" minX="12" minY="12" maxX="12" maxY="12"/>
-                                <state key="normal" image="plus.slash.minus" catalog="system">
+                                <state key="normal" image="plus.forwardslash.minus" catalog="system">
                                     <color key="titleColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
                                 </state>
                                 <state key="disabled">
@@ -173,6 +173,6 @@
         <image name="ellipsis" catalog="system" width="128" height="37"/>
         <image name="minus" catalog="system" width="128" height="26"/>
         <image name="plus" catalog="system" width="128" height="113"/>
-        <image name="plus.slash.minus" catalog="system" width="128" height="115"/>
+        <image name="plus.forwardslash.minus" catalog="system" width="128" height="115"/>
     </resources>
 </document>

+ 63 - 52
iOSClient/Menu/AppDelegate+Menu.swift

@@ -33,7 +33,10 @@ extension AppDelegate {
 
         var actions: [NCMenuAction] = []
 
+        // swiftlint:disable force_cast
         let appDelegate = UIApplication.shared.delegate as! AppDelegate
+        // swiftlint:enable force_cast
+
         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))
@@ -68,14 +71,15 @@ extension AppDelegate {
                     }
                     navigationController.modalPresentationStyle = UIModalPresentationStyle.formSheet
 
-                    let viewController = (navigationController as! UINavigationController).topViewController as! NCCreateFormUploadDocuments
-                    viewController.editorId = NCGlobal.shared.editorText
-                    viewController.creatorId = directEditingCreator.identifier
-                    viewController.typeTemplate = NCGlobal.shared.templateDocument
-                    viewController.serverUrl = appDelegate.activeServerUrl
-                    viewController.titleForm = NSLocalizedString("_create_nextcloudtext_document_", comment: "")
+                    if let viewController = (navigationController as? UINavigationController)?.topViewController as? NCCreateFormUploadDocuments {
+                        viewController.editorId = NCGlobal.shared.editorText
+                        viewController.creatorId = directEditingCreator.identifier
+                        viewController.typeTemplate = NCGlobal.shared.templateDocument
+                        viewController.serverUrl = appDelegate.activeServerUrl
+                        viewController.titleForm = NSLocalizedString("_create_nextcloudtext_document_", comment: "")
 
-                    appDelegate.window?.rootViewController?.present(navigationController, animated: true, completion: nil)
+                        appDelegate.window?.rootViewController?.present(navigationController, animated: true, completion: nil)
+                    }
                 })
             )
         }
@@ -96,14 +100,15 @@ extension AppDelegate {
                     NCAskAuthorization.shared.askAuthorizationAudioRecord(viewController: viewController) { hasPermission in
                         if hasPermission {
                             let fileName = CCUtility.createFileNameDate(NSLocalizedString("_voice_memo_filename_", comment: ""), extension: "m4a")!
-                            let viewController = UIStoryboard(name: "NCAudioRecorderViewController", bundle: nil).instantiateInitialViewController() as! NCAudioRecorderViewController
+                            if let viewController = UIStoryboard(name: "NCAudioRecorderViewController", bundle: nil).instantiateInitialViewController() as? NCAudioRecorderViewController {
 
-                            viewController.delegate = self
-                            viewController.createRecorder(fileName: fileName)
-                            viewController.modalTransitionStyle = .crossDissolve
-                            viewController.modalPresentationStyle = UIModalPresentationStyle.overCurrentContext
+                                viewController.delegate = self
+                                viewController.createRecorder(fileName: fileName)
+                                viewController.modalTransitionStyle = .crossDissolve
+                                viewController.modalPresentationStyle = UIModalPresentationStyle.overCurrentContext
 
-                            appDelegate.window?.rootViewController?.present(viewController, animated: true, completion: nil)
+                                appDelegate.window?.rootViewController?.present(viewController, animated: true, completion: nil)
+                            }
                         }
                     }
                 }
@@ -170,14 +175,15 @@ extension AppDelegate {
                         }
                         navigationController.modalPresentationStyle = UIModalPresentationStyle.formSheet
 
-                        let viewController = (navigationController as! UINavigationController).topViewController as! NCCreateFormUploadDocuments
-                        viewController.editorId = NCGlobal.shared.editorOnlyoffice
-                        viewController.creatorId = directEditingCreator.identifier
-                        viewController.typeTemplate = NCGlobal.shared.templateDocument
-                        viewController.serverUrl = appDelegate.activeServerUrl
-                        viewController.titleForm = NSLocalizedString("_create_new_document_", comment: "")
+                        if let viewController = (navigationController as? UINavigationController)?.topViewController as? NCCreateFormUploadDocuments {
+                            viewController.editorId = NCGlobal.shared.editorOnlyoffice
+                            viewController.creatorId = directEditingCreator.identifier
+                            viewController.typeTemplate = NCGlobal.shared.templateDocument
+                            viewController.serverUrl = appDelegate.activeServerUrl
+                            viewController.titleForm = NSLocalizedString("_create_new_document_", comment: "")
 
-                        appDelegate.window?.rootViewController?.present(navigationController, animated: true, completion: nil)
+                            appDelegate.window?.rootViewController?.present(navigationController, animated: true, completion: nil)
+                        }
                     }
                 )
             )
@@ -193,14 +199,15 @@ extension AppDelegate {
                         }
                         navigationController.modalPresentationStyle = UIModalPresentationStyle.formSheet
 
-                        let viewController = (navigationController as! UINavigationController).topViewController as! NCCreateFormUploadDocuments
-                        viewController.editorId = NCGlobal.shared.editorOnlyoffice
-                        viewController.creatorId = directEditingCreator.identifier
-                        viewController.typeTemplate = NCGlobal.shared.templateSpreadsheet
-                        viewController.serverUrl = appDelegate.activeServerUrl
-                        viewController.titleForm = NSLocalizedString("_create_new_spreadsheet_", comment: "")
+                        if let viewController = (navigationController as? UINavigationController)?.topViewController as? NCCreateFormUploadDocuments {
+                            viewController.editorId = NCGlobal.shared.editorOnlyoffice
+                            viewController.creatorId = directEditingCreator.identifier
+                            viewController.typeTemplate = NCGlobal.shared.templateSpreadsheet
+                            viewController.serverUrl = appDelegate.activeServerUrl
+                            viewController.titleForm = NSLocalizedString("_create_new_spreadsheet_", comment: "")
 
-                        appDelegate.window?.rootViewController?.present(navigationController, animated: true, completion: nil)
+                            appDelegate.window?.rootViewController?.present(navigationController, animated: true, completion: nil)
+                        }
                     }
                 )
             )
@@ -216,14 +223,15 @@ extension AppDelegate {
                         }
                         navigationController.modalPresentationStyle = UIModalPresentationStyle.formSheet
 
-                        let viewController = (navigationController as! UINavigationController).topViewController as! NCCreateFormUploadDocuments
-                        viewController.editorId = NCGlobal.shared.editorOnlyoffice
-                        viewController.creatorId = directEditingCreator.identifier
-                        viewController.typeTemplate = NCGlobal.shared.templatePresentation
-                        viewController.serverUrl = appDelegate.activeServerUrl
-                        viewController.titleForm = NSLocalizedString("_create_new_presentation_", comment: "")
+                        if let viewController = (navigationController as? UINavigationController)?.topViewController as? NCCreateFormUploadDocuments {
+                            viewController.editorId = NCGlobal.shared.editorOnlyoffice
+                            viewController.creatorId = directEditingCreator.identifier
+                            viewController.typeTemplate = NCGlobal.shared.templatePresentation
+                            viewController.serverUrl = appDelegate.activeServerUrl
+                            viewController.titleForm = NSLocalizedString("_create_new_presentation_", comment: "")
 
-                        appDelegate.window?.rootViewController?.present(navigationController, animated: true, completion: nil)
+                            appDelegate.window?.rootViewController?.present(navigationController, animated: true, completion: nil)
+                        }
                     }
                 )
             )
@@ -239,13 +247,14 @@ extension AppDelegate {
                             }
                             navigationController.modalPresentationStyle = UIModalPresentationStyle.formSheet
 
-                            let viewController = (navigationController as! UINavigationController).topViewController as! NCCreateFormUploadDocuments
-                            viewController.editorId = NCGlobal.shared.editorCollabora
-                            viewController.typeTemplate = NCGlobal.shared.templateDocument
-                            viewController.serverUrl = appDelegate.activeServerUrl
-                            viewController.titleForm = NSLocalizedString("_create_nextcloudtext_document_", comment: "")
+                            if let viewController = (navigationController as? UINavigationController)?.topViewController as? NCCreateFormUploadDocuments {
+                                viewController.editorId = NCGlobal.shared.editorCollabora
+                                viewController.typeTemplate = NCGlobal.shared.templateDocument
+                                viewController.serverUrl = appDelegate.activeServerUrl
+                                viewController.titleForm = NSLocalizedString("_create_nextcloudtext_document_", comment: "")
 
-                            appDelegate.window?.rootViewController?.present(navigationController, animated: true, completion: nil)
+                                appDelegate.window?.rootViewController?.present(navigationController, animated: true, completion: nil)
+                            }
                         }
                     )
                 )
@@ -258,13 +267,14 @@ extension AppDelegate {
                             }
                             navigationController.modalPresentationStyle = UIModalPresentationStyle.formSheet
 
-                            let viewController = (navigationController as! UINavigationController).topViewController as! NCCreateFormUploadDocuments
-                            viewController.editorId = NCGlobal.shared.editorCollabora
-                            viewController.typeTemplate = NCGlobal.shared.templateSpreadsheet
-                            viewController.serverUrl = appDelegate.activeServerUrl
-                            viewController.titleForm = NSLocalizedString("_create_new_spreadsheet_", comment: "")
+                            if let viewController = (navigationController as? UINavigationController)?.topViewController as? NCCreateFormUploadDocuments {
+                                viewController.editorId = NCGlobal.shared.editorCollabora
+                                viewController.typeTemplate = NCGlobal.shared.templateSpreadsheet
+                                viewController.serverUrl = appDelegate.activeServerUrl
+                                viewController.titleForm = NSLocalizedString("_create_new_spreadsheet_", comment: "")
 
-                            appDelegate.window?.rootViewController?.present(navigationController, animated: true, completion: nil)
+                                appDelegate.window?.rootViewController?.present(navigationController, animated: true, completion: nil)
+                            }
                         }
                     )
                 )
@@ -277,13 +287,14 @@ extension AppDelegate {
                             }
                             navigationController.modalPresentationStyle = UIModalPresentationStyle.formSheet
 
-                            let viewController = (navigationController as! UINavigationController).topViewController as! NCCreateFormUploadDocuments
-                            viewController.editorId = NCGlobal.shared.editorCollabora
-                            viewController.typeTemplate = NCGlobal.shared.templatePresentation
-                            viewController.serverUrl = appDelegate.activeServerUrl
-                            viewController.titleForm = NSLocalizedString("_create_new_presentation_", comment: "")
+                            if let viewController = (navigationController as? UINavigationController)?.topViewController as? NCCreateFormUploadDocuments {
+                                viewController.editorId = NCGlobal.shared.editorCollabora
+                                viewController.typeTemplate = NCGlobal.shared.templatePresentation
+                                viewController.serverUrl = appDelegate.activeServerUrl
+                                viewController.titleForm = NSLocalizedString("_create_new_presentation_", comment: "")
 
-                            appDelegate.window?.rootViewController?.present(navigationController, animated: true, completion: nil)
+                                appDelegate.window?.rootViewController?.present(navigationController, animated: true, completion: nil)
+                            }
                         }
                     )
                 )

+ 3 - 4
iOSClient/Menu/NCCollectionViewCommon+Menu.swift

@@ -38,14 +38,13 @@ extension NCCollectionViewCommon {
 
         guard let metadata = NCManageDatabase.shared.getMetadataFromOcId(metadata.ocId) else { return }
         let serverUrl = metadata.serverUrl + "/" + metadata.fileName
-        let serverUrlHome = NCUtilityFileSystem.shared.getHomeServer(urlBase: appDelegate.urlBase, userId: appDelegate.userId)
-        let isOffline: Bool
+        var isOffline: Bool = false
 
         if metadata.directory, let directory = NCManageDatabase.shared.getTableDirectory(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@", appDelegate.account, serverUrl)) {
             isOffline = directory.offline
         } else if let localFile = NCManageDatabase.shared.getTableLocalFile(predicate: NSPredicate(format: "ocId == %@", metadata.ocId)) {
             isOffline = localFile.offline
-        } else { isOffline = false }
+        }
 
         let editors = NCUtility.shared.isDirectEditing(account: metadata.account, contentType: metadata.contentType)
         let isRichDocument = NCUtility.shared.isRichDocument(metadata)
@@ -242,7 +241,7 @@ extension NCCollectionViewCommon {
                 icon = NCUtility.shared.loadImage(named: "collabora")
             }
 
-            if editor != "" {
+            if !editor.isEmpty {
                 actions.append(
                     NCMenuAction(
                         title: title,

+ 3 - 3
iOSClient/Menu/NCLoginWeb+Menu.swift

@@ -73,10 +73,10 @@ extension NCLoginWeb {
                     self.appDelegate.deleteAccount(self.appDelegate.account, wipe: false)
                     self.dismiss(animated: true) {
                         let accounts = NCManageDatabase.shared.getAllAccount()
-                        if accounts.count > 0 {
-                            self.appDelegate.changeAccount(accounts.first!.account, userProfile: nil)
-                        } else {
+                        if accounts.isEmpty {
                             self.appDelegate.openLogin(viewController: nil, selector: NCGlobal.shared.introLogin, openLoginWeb: false)
+                        } else {
+                            self.appDelegate.changeAccount(accounts.first!.account, userProfile: nil)
                         }
                     }
                 }

+ 9 - 8
iOSClient/Menu/NCMedia+Menu.swift

@@ -40,7 +40,7 @@ extension NCMedia {
         defer { presentMenu(with: actions) }
 
         if !isEditMode {
-            if metadatas.count > 0 {
+            if !metadatas.isEmpty {
                 actions.append(
                     NCMenuAction(
                         title: NSLocalizedString("_select_", comment: ""),
@@ -85,15 +85,16 @@ extension NCMedia {
                     title: NSLocalizedString("_select_media_folder_", comment: ""),
                     icon: NCUtility.shared.loadImage(named: "folder"),
                     action: { _ in
-                        let navigationController = UIStoryboard(name: "NCSelect", bundle: nil).instantiateInitialViewController() as! UINavigationController
-                        let viewController = navigationController.topViewController as! NCSelect
+                        if let navigationController = UIStoryboard(name: "NCSelect", bundle: nil).instantiateInitialViewController() as? UINavigationController,
+                           let viewController = navigationController.topViewController as? NCSelect {
 
-                        viewController.delegate = self
-                        viewController.typeOfCommandView = .select
-                        viewController.type = "mediaFolder"
-                        viewController.selectIndexPath = self.selectIndexPath
+                            viewController.delegate = self
+                            viewController.typeOfCommandView = .select
+                            viewController.type = "mediaFolder"
+                            viewController.selectIndexPath = self.selectIndexPath
 
-                        self.present(navigationController, animated: true, completion: nil)
+                            self.present(navigationController, animated: true, completion: nil)
+                        }
                     }
                 )
             )

+ 23 - 21
iOSClient/More/NCMore.swift

@@ -37,7 +37,10 @@ class NCMore: UIViewController, UITableViewDelegate, UITableViewDataSource {
     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 applicationHandle = NCApplicationHandle()
 
     private var tabAccount: tableAccount?
@@ -184,7 +187,7 @@ class NCMore: UIViewController, UITableViewDelegate, UITableViewDataSource {
         item.url = "segueSettings"
         settingsMenu.append(item)
 
-        if quotaMenu.count > 0 {
+        if !quotaMenu.isEmpty {
             let item = quotaMenu[0]
             labelQuotaExternalSite.text = item.name
         }
@@ -221,7 +224,7 @@ class NCMore: UIViewController, UITableViewDelegate, UITableViewDataSource {
         if NCBrandOptions.shared.disable_more_external_site == false {
             if let externalSites = NCManageDatabase.shared.getAllExternalSites(account: appDelegate.account) {
                 for externalSite in externalSites {
-                    if (externalSite.name != "" && externalSite.url != ""), let urlEncoded = externalSite.url.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed) {
+                    if !externalSite.name.isEmpty, !externalSite.url.isEmpty, let urlEncoded = externalSite.url.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed) {
                         item = NKExternalSite()
                         item.name = externalSite.name
                         item.url = urlEncoded
@@ -264,15 +267,15 @@ class NCMore: UIViewController, UITableViewDelegate, UITableViewDataSource {
 
     @objc func tapLabelQuotaExternalSite() {
 
-        if quotaMenu.count > 0 {
-
+        if !quotaMenu.isEmpty {
             let item = quotaMenu[0]
-            let browserWebVC = UIStoryboard(name: "NCBrowserWeb", bundle: nil).instantiateInitialViewController() as! NCBrowserWeb
-            browserWebVC.urlBase = item.url
-            browserWebVC.isHiddenButtonExit = true
+            if let browserWebVC = UIStoryboard(name: "NCBrowserWeb", bundle: nil).instantiateInitialViewController() as? NCBrowserWeb {
+                browserWebVC.urlBase = item.url
+                browserWebVC.isHiddenButtonExit = true
 
-            self.navigationController?.pushViewController(browserWebVC, animated: true)
-            self.navigationController?.navigationBar.isHidden = false
+                self.navigationController?.pushViewController(browserWebVC, animated: true)
+                self.navigationController?.navigationBar.isHidden = false
+            }
         }
     }
 
@@ -318,7 +321,7 @@ class NCMore: UIViewController, UITableViewDelegate, UITableViewDataSource {
 
         if section.type == .account {
 
-            let cell = tableView.dequeueReusableCell(withIdentifier: NCMoreUserCell.reuseIdentifier, for: indexPath) as! NCMoreUserCell
+            guard let cell = tableView.dequeueReusableCell(withIdentifier: NCMoreUserCell.reuseIdentifier, for: indexPath) as? NCMoreUserCell else { return UITableViewCell() }
 
             cell.avatar.image = nil
             cell.icon.image = nil
@@ -328,7 +331,7 @@ class NCMore: UIViewController, UITableViewDelegate, UITableViewDataSource {
             if let account = tabAccount {
                 cell.avatar.image = NCUtility.shared.loadUserImage(for: account.user, displayName: account.displayName, userBaseUrl: appDelegate)
 
-                if account.alias == "" {
+                if account.alias.isEmpty {
                     cell.displayName?.text = account.displayName
                 } else {
                     cell.displayName?.text = account.displayName + " (" + account.alias + ")"
@@ -355,11 +358,10 @@ class NCMore: UIViewController, UITableViewDelegate, UITableViewDataSource {
             return cell
 
         } else if section.type == .moreApps {
-            let cell = tableView.dequeueReusableCell(withIdentifier: NCMoreAppSuggestionsCell.reuseIdentifier, for: indexPath) as! NCMoreAppSuggestionsCell
-
+            guard let cell = tableView.dequeueReusableCell(withIdentifier: NCMoreAppSuggestionsCell.reuseIdentifier, for: indexPath) as? NCMoreAppSuggestionsCell else { return UITableViewCell() }
             return cell
         } else {
-            let cell = tableView.dequeueReusableCell(withIdentifier: CCCellMore.reuseIdentifier, for: indexPath) as! CCCellMore
+            guard let cell = tableView.dequeueReusableCell(withIdentifier: CCCellMore.reuseIdentifier, for: indexPath) as? CCCellMore else { return UITableViewCell() }
 
             let item = sections[indexPath.section].items[indexPath.row]
 
@@ -414,13 +416,13 @@ class NCMore: UIViewController, UITableViewDelegate, UITableViewDataSource {
                 present(controller, animated: true, completion: nil)
             }
         } else if item.url.contains("//") {
-            let browserWebVC = UIStoryboard(name: "NCBrowserWeb", bundle: nil).instantiateInitialViewController() as! NCBrowserWeb
-            browserWebVC.urlBase = item.url
-            browserWebVC.isHiddenButtonExit = true
-            browserWebVC.titleBrowser = item.name
-
-            self.navigationController?.pushViewController(browserWebVC, animated: true)
-            self.navigationController?.navigationBar.isHidden = false
+            if let browserWebVC = UIStoryboard(name: "NCBrowserWeb", bundle: nil).instantiateInitialViewController() as? NCBrowserWeb {
+                browserWebVC.urlBase = item.url
+                browserWebVC.isHiddenButtonExit = true
+                browserWebVC.titleBrowser = item.name
+                self.navigationController?.pushViewController(browserWebVC, animated: true)
+                self.navigationController?.navigationBar.isHidden = false
+            }
         } else if item.url == "logout" {
             let alertController = UIAlertController(title: "", message: NSLocalizedString("_want_delete_", comment: ""), preferredStyle: .alert)
 

+ 2 - 2
iOSClient/Networking/E2EE/NCNetworkingE2EECreateFolder.swift

@@ -36,7 +36,7 @@ class NCNetworkingE2EECreateFolder: NSObject {
         if fileNameFolder.isEmpty {
             return NKError(errorCode: NCGlobal.shared.errorUnexpectedResponseFromDB, errorDescription: NSLocalizedString("_e2e_error_", comment: ""))
         }
-        guard let directory = NCManageDatabase.shared.getTableDirectory(predicate:  NSPredicate(format: "account == %@ AND serverUrl == %@", account, serverUrl)) else {
+        guard let directory = NCManageDatabase.shared.getTableDirectory(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@", account, serverUrl)) else {
             return NKError(errorCode: NCGlobal.shared.errorUnexpectedResponseFromDB, errorDescription: NSLocalizedString("_e2e_error_", comment: ""))
         }
 
@@ -122,7 +122,7 @@ class NCNetworkingE2EECreateFolder: NSObject {
             return resultsCreateFolder.error
         }
 
-        // MARK FOLDER AS E2EE
+        // SET FOLDER AS E2EE
         //
         let resultsMarkE2EEFolder = await NextcloudKit.shared.markE2EEFolder(fileId: fileId, delete: false, route: NCNetworkingE2EE.shared.getRoute())
         guard resultsMarkE2EEFolder.error == .success  else {

+ 1 - 1
iOSClient/Networking/E2EE/NCNetworkingE2EERename.swift

@@ -86,7 +86,7 @@ class NCNetworkingE2EERename: NSObject {
         // UNLOCK
         //
         await NCNetworkingE2EE.shared.unlock(account: metadata.account, serverUrl: metadata.serverUrl)
-        
+
         NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterRenameFile, userInfo: ["ocId": metadata.ocId, "account": metadata.account, "indexPath": indexPath])
 
         return NKError()

+ 7 - 9
iOSClient/Networking/E2EE/NCNetworkingE2EEUpload.swift

@@ -51,9 +51,8 @@ class NCNetworkingE2EEUpload: NSObject {
         metadata.session = NextcloudKit.shared.nkCommonInstance.sessionIdentifierUpload
         metadata.sessionError = ""
         guard let result = NCManageDatabase.shared.addMetadata(metadata),
-              let directory = NCManageDatabase.shared.getTableDirectory(predicate:  NSPredicate(format: "account == %@ AND serverUrl == %@", metadata.account, metadata.serverUrl)) else {
+              let directory = NCManageDatabase.shared.getTableDirectory(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@", metadata.account, metadata.serverUrl)) else {
             return NKError(errorCode: NCGlobal.shared.errorUnexpectedResponseFromDB, errorDescription: NSLocalizedString("_e2e_error_", comment: ""))
-            
         }
         metadata = result
 
@@ -115,7 +114,6 @@ class NCNetworkingE2EEUpload: NSObject {
             return uploadMetadataError
         }
 
-
         // LOCK
         //
         let resultsLock = await NCNetworkingE2EE.shared.lock(account: metadata.account, serverUrl: metadata.serverUrl)
@@ -142,7 +140,7 @@ class NCNetworkingE2EEUpload: NSObject {
         // UNLOCK
         //
         await NCNetworkingE2EE.shared.unlock(account: metadata.account, serverUrl: metadata.serverUrl)
-        
+
         if let afError = resultsSendFile.afError, afError.isExplicitlyCancelledError {
 
             CCUtility.removeFile(atPath: CCUtility.getDirectoryProviderStorageOcId(metadata.ocId))
@@ -180,7 +178,7 @@ class NCNetworkingE2EEUpload: NSObject {
 
     // BRIDGE for chunk
     //
-    private func sendFile(metadata: tableMetadata, e2eToken: String, uploadE2EEDelegate: uploadE2EEDelegate? = nil) async -> (ocId: String?, etag: String?, date: NSDate? ,afError: AFError?, error: NKError) {
+    private func sendFile(metadata: tableMetadata, e2eToken: String, uploadE2EEDelegate: uploadE2EEDelegate? = nil) async -> (ocId: String?, etag: String?, date: NSDate?, afError: AFError?, error: NKError) {
 
         if metadata.chunk > 0 {
 
@@ -189,8 +187,8 @@ class NCNetworkingE2EEUpload: NSObject {
                     uploadE2EEDelegate?.start()
                 } progressHandler: { totalBytesExpected, totalBytes, fractionCompleted in
                     uploadE2EEDelegate?.uploadE2EEProgress(totalBytesExpected, totalBytes, fractionCompleted)
-                } completion: { account, file, afError, error in
-                    continuation.resume(returning: (ocId: file?.ocId, etag: file?.etag, date: file?.date ,afError: afError, error: error))
+                } completion: { _, file, afError, error in
+                    continuation.resume(returning: (ocId: file?.ocId, etag: file?.etag, date: file?.date, afError: afError, error: error))
                 }
             })
 
@@ -202,8 +200,8 @@ class NCNetworkingE2EEUpload: NSObject {
                     uploadE2EEDelegate?.start()
                 } progressHandler: { totalBytesExpected, totalBytes, fractionCompleted in
                     uploadE2EEDelegate?.uploadE2EEProgress(totalBytesExpected, totalBytes, fractionCompleted)
-                } completion: { account, ocId, etag, date, size, allHeaderFields, afError, error in
-                    continuation.resume(returning: (ocId: ocId, etag: etag, date: date ,afError: afError, error: error))
+                } completion: { _, ocId, etag, date, _, _, afError, error in
+                    continuation.resume(returning: (ocId: ocId, etag: etag, date: date, afError: afError, error: error))
                 }
             })
         }

+ 13 - 19
iOSClient/Networking/NCAutoUpload.swift

@@ -48,10 +48,9 @@ class NCAutoUpload: NSObject {
         NCAskAuthorization.shared.askAuthorizationPhotoLibrary(viewController: viewController) { hasPermission in
             guard hasPermission else {
                 NCManageDatabase.shared.setAccountAutoUploadProperty("autoUpload", state: false)
-                completion(0)
-                return
+                return completion(0)
             }
-            DispatchQueue.global().async {
+            Task {
                 self.uploadAssetsNewAndFull(viewController: viewController, selector: NCGlobal.shared.selectorUploadAutoUpload, log: "Init Auto Upload") { items in
                     completion(items)
                 }
@@ -68,7 +67,7 @@ class NCAutoUpload: NSObject {
             let error = NKError(errorCode: NCGlobal.shared.errorInternalError, errorDescription: "_create_full_upload_")
             NCContentPresenter.shared.showWarning(error: error, priority: .max)
             NCActivityIndicator.shared.start()
-            DispatchQueue.global().async {
+            Task {
                 self.uploadAssetsNewAndFull(viewController: viewController, selector: NCGlobal.shared.selectorUploadAutoUploadAll, log: log) { _ in
                     NCActivityIndicator.shared.stop()
                 }
@@ -77,21 +76,19 @@ class NCAutoUpload: NSObject {
     }
 
     private func uploadAssetsNewAndFull(viewController: UIViewController?, selector: String, log: String, completion: @escaping (_ items: Int) -> Void) {
-        guard let account = NCManageDatabase.shared.getActiveAccount() else {
-            completion(0)
-            return
-        }
 
+        guard let account = NCManageDatabase.shared.getActiveAccount() else { return completion(0) }
         let autoUploadPath = NCManageDatabase.shared.getAccountAutoUploadPath(urlBase: account.urlBase, userId: account.userId, account: account.account)
         let autoUploadSubfolderGranularity = NCManageDatabase.shared.getAccountAutoUploadSubfolderGranularity()
         var metadatas: [tableMetadata] = []
 
         self.getCameraRollAssets(viewController: viewController, account: account, selector: selector, alignPhotoLibrary: false) { assets in
-            guard let assets = assets, !assets.isEmpty else {
+
+            guard let assets, !assets.isEmpty else {
                 NextcloudKit.shared.nkCommonInstance.writeLog("[INFO] Automatic upload, no new assets found [" + log + "]")
-                completion(0)
-                return
+                return completion(0)
             }
+
             NextcloudKit.shared.nkCommonInstance.writeLog("[INFO] Automatic upload, new \(assets.count) assets found [" + log + "]")
             // Create the folder for auto upload & if request the subfolders
             if !NCNetworking.shared.createFolder(assets: assets, selector: selector, useSubFolder: account.autoUploadCreateSubfolder, account: account.account, urlBase: account.urlBase, userId: account.userId, withPush: false) {
@@ -191,6 +188,7 @@ class NCAutoUpload: NSObject {
     // MARK: -
 
     @objc func alignPhotoLibrary(viewController: UIViewController?) {
+
         guard let activeAccount = NCManageDatabase.shared.getActiveAccount() else { return }
 
         getCameraRollAssets(viewController: viewController, account: activeAccount, selector: NCGlobal.shared.selectorUploadAutoUploadAll, alignPhotoLibrary: true) { assets in
@@ -205,15 +203,11 @@ class NCAutoUpload: NSObject {
     private func getCameraRollAssets(viewController: UIViewController?, account: tableAccount, selector: String, alignPhotoLibrary: Bool, completion: @escaping (_ assets: [PHAsset]?) -> Void) {
 
         NCAskAuthorization.shared.askAuthorizationPhotoLibrary(viewController: viewController) { hasPermission in
-            guard hasPermission else {
-                completion(nil)
-                return
-            }
+
             let assetCollection = PHAssetCollection.fetchAssetCollections(with: PHAssetCollectionType.smartAlbum, subtype: PHAssetCollectionSubtype.smartAlbumUserLibrary, options: nil)
-            if assetCollection.count == 0 {
-                completion(nil)
-                return
-            }
+            // swiftlint:disable empty_count
+            guard hasPermission, assetCollection.count != 0 else { return completion(nil) }
+            // swiftlint:enable empty_count
 
             let predicateImage = NSPredicate(format: "mediaType == %i", PHAssetMediaType.image.rawValue)
             let predicateVideo = NSPredicate(format: "mediaType == %i", PHAssetMediaType.video.rawValue)

+ 2 - 0
iOSClient/Networking/NCConfigServer.swift

@@ -53,9 +53,11 @@ import NextcloudKit
         NCNetworking.shared.checkTrustedChallenge(session, didReceive: challenge, completionHandler: completionHandler)
     }
 
+    // swiftlint:disable identifier_name
     private enum ConfigState: Int {
         case Stopped, Ready, InstalledConfig, BackToApp
     }
+    // swiftlint:enable identifier_name
 
     internal let listeningPort: in_port_t = 8080
     internal var configName: String = "Profile install"

+ 15 - 17
iOSClient/Networking/NCNetworking.swift

@@ -273,8 +273,8 @@ class NCNetworking: NSObject, NKCommonDelegate {
                     completion(error)
                 }))
                 alertController.addAction(UIAlertAction(title: NSLocalizedString("_certificate_details_", comment: ""), style: .default, handler: { _ in
-                    if let navigationController = UIStoryboard(name: "NCViewCertificateDetails", bundle: nil).instantiateInitialViewController() as? UINavigationController {
-                        let vcCertificateDetails = navigationController.topViewController as! NCViewCertificateDetails
+                    if let navigationController = UIStoryboard(name: "NCViewCertificateDetails", bundle: nil).instantiateInitialViewController() as? UINavigationController,
+                       let vcCertificateDetails = navigationController.topViewController as? NCViewCertificateDetails {
                         vcCertificateDetails.host = host
                         viewController?.present(navigationController, animated: true)
                     }
@@ -525,7 +525,6 @@ class NCNetworking: NSObject, NKCommonDelegate {
                 if let afError, !afError.isExplicitlyCancelledError {
                     NCContentPresenter.shared.messageNotification("_error_", error: error, delay: NCGlobal.shared.dismissAfterSecond, type: .error)
                 }
-                break
             case NKError.chunkMoveFile:
                 NCManageDatabase.shared.deleteChunks(account: account, ocId: metadata.ocId, directory: directory)
                 NCContentPresenter.shared.messageNotification("_chunk_move_", error: error, delay: NCGlobal.shared.dismissAfterSecond, type: .error)
@@ -655,7 +654,10 @@ 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
+
                     appDelegate.window?.rootViewController?.present(alertController, animated: true)
                 }
 #endif
@@ -843,7 +845,7 @@ class NCNetworking: NSObject, NKCommonDelegate {
 
     func readFolder(serverUrl: String, account: String, completion: @escaping (_ account: String, _ metadataFolder: tableMetadata?, _ metadatas: [tableMetadata]?, _ metadatasUpdate: [tableMetadata]?, _ metadatasLocalUpdate: [tableMetadata]?, _ metadatasDelete: [tableMetadata]?, _ error: NKError) -> Void) {
 
-        NextcloudKit.shared.readFileOrFolder(serverUrlFileName: serverUrl, 
+        NextcloudKit.shared.readFileOrFolder(serverUrlFileName: serverUrl,
                                              depth: "1",
                                              showHiddenFiles: CCUtility.getShowHiddenFiles(),
                                              includeHiddenFiles: NCGlobal.shared.includeHiddenFiles,
@@ -920,7 +922,7 @@ class NCNetworking: NSObject, NKCommonDelegate {
         </d:propfind>
         """
 
-        NextcloudKit.shared.readFileOrFolder(serverUrlFileName: serverUrlFileName, 
+        NextcloudKit.shared.readFileOrFolder(serverUrlFileName: serverUrlFileName,
                                              depth: "0",
                                              requestBody: requestBody.data(using: .utf8),
                                              options: NKRequestOptions(queue: NextcloudKit.shared.nkCommonInstance.backgroundQueue)) { account, files, _, error in
@@ -937,17 +939,16 @@ class NCNetworking: NSObject, NKCommonDelegate {
 
     // MARK: - Synchronization ServerUrl
 
-
     func synchronizationServerUrl(_ serverUrl: String, account: String, selector: String) {
 
 #if !EXTENSION
-        NextcloudKit.shared.readFileOrFolder(serverUrlFileName: serverUrl, 
+        NextcloudKit.shared.readFileOrFolder(serverUrlFileName: serverUrl,
                                              depth: "infinity",
                                              showHiddenFiles: CCUtility.getShowHiddenFiles(),
                                              options: NKRequestOptions(queue: NextcloudKit.shared.nkCommonInstance.backgroundQueue)) { account, files, _, error in
 
             if error == .success {
-                NCManageDatabase.shared.convertFilesToMetadatas(files, useMetadataFolder: true) { metadataFolder, metadatasFolder, metadatas in
+                NCManageDatabase.shared.convertFilesToMetadatas(files, useMetadataFolder: true) { metadataFolder, _, metadatas in
                     NCManageDatabase.shared.addDirectory(encrypted: metadataFolder.e2eEncrypted, favorite: metadataFolder.favorite, ocId: metadataFolder.ocId, fileId: metadataFolder.fileId, etag: metadataFolder.etag, permissions: metadataFolder.permissions, serverUrl: metadataFolder.serverUrl + "/" + metadataFolder.fileName, account: metadataFolder.account)
                     let metadatasResult = NCManageDatabase.shared.getMetadatas(predicate: NSPredicate(format: "account == %@ AND serverUrl BEGINSWITH %@ AND status == %d", account, serverUrl, NCGlobal.shared.metadataStatusNormal))
                     NCManageDatabase.shared.updateMetadatas(metadatas, metadatasResult: metadatasResult)
@@ -965,7 +966,6 @@ class NCNetworking: NSObject, NKCommonDelegate {
 #endif
     }
 
-
     // MARK: - Search
 
     /// WebDAV search
@@ -1035,7 +1035,6 @@ class NCNetworking: NSObject, NKCommonDelegate {
                         semaphore.wait()
                     } else { print(#function, "[ERROR]: File search entry has no path: \(entry)") }
                 })
-                break
             case "fulltextsearch":
                 // NOTE: FTS could also return attributes like files
                 // https://github.com/nextcloud/files_fulltextsearch/issues/143
@@ -1094,7 +1093,6 @@ class NCNetworking: NSObject, NKCommonDelegate {
                         semaphore.wait()
                     } else { print(#function, "[ERROR]: File search entry has no path: \(entry)") }
                 })
-                break
             case "fulltextsearch":
                 // NOTE: FTS could also return attributes like files
                 // https://github.com/nextcloud/files_fulltextsearch/issues/143
@@ -1171,7 +1169,7 @@ class NCNetworking: NSObject, NKCommonDelegate {
         if !overwrite {
             fileNameFolder = NCUtilityFileSystem.shared.createFileName(fileNameFolder, serverUrl: serverUrl, account: account)
         }
-        if fileNameFolder.count == 0 {
+        if fileNameFolder.isEmpty {
             return completion(NKError())
         }
         let fileNameFolderUrl = serverUrl + "/" + fileNameFolder
@@ -1332,7 +1330,7 @@ class NCNetworking: NSObject, NKCommonDelegate {
 
         // verify permission
         let permission = NCUtility.shared.permissionsContainsString(metadata.permissions, permissions: NCGlobal.shared.permissionCanDelete)
-        if metadata.permissions != "" && permission == false {
+        if !metadata.permissions.isEmpty && permission == false {
             return NKError(errorCode: NCGlobal.shared.errorInternalError, errorDescription: "_no_permission_delete_file_")
         }
 
@@ -1456,13 +1454,13 @@ class NCNetworking: NSObject, NKCommonDelegate {
     private func renameMetadataPlain(_ metadata: tableMetadata, fileNameNew: String, indexPath: IndexPath, completion: @escaping (_ error: NKError) -> Void) {
 
         let permission = NCUtility.shared.permissionsContainsString(metadata.permissions, permissions: NCGlobal.shared.permissionCanRename)
-        if !(metadata.permissions == "") && !permission {
+        if !metadata.permissions.isEmpty && !permission {
             return completion(NKError(errorCode: NCGlobal.shared.errorInternalError, errorDescription: "_no_permission_modify_file_"))
         }
         guard let fileNameNew = CCUtility.removeForbiddenCharactersServer(fileNameNew) else {
             return completion(NKError())
         }
-        if fileNameNew.count == 0 || fileNameNew == metadata.fileNameView {
+        if fileNameNew.isEmpty || fileNameNew == metadata.fileNameView {
             return completion(NKError())
         }
 
@@ -1536,7 +1534,7 @@ class NCNetworking: NSObject, NKCommonDelegate {
     private func moveMetadataPlain(_ metadata: tableMetadata, serverUrlTo: String, overwrite: Bool) async -> NKError {
 
         let permission = NCUtility.shared.permissionsContainsString(metadata.permissions, permissions: NCGlobal.shared.permissionCanRename)
-        if !(metadata.permissions == "") && !permission {
+        if !metadata.permissions.isEmpty && !permission {
             return NKError(errorCode: NCGlobal.shared.errorInternalError, errorDescription: "_no_permission_modify_file_")
         }
 
@@ -1572,7 +1570,7 @@ class NCNetworking: NSObject, NKCommonDelegate {
     private func copyMetadataPlain(_ metadata: tableMetadata, serverUrlTo: String, overwrite: Bool) async -> NKError {
 
         let permission = NCUtility.shared.permissionsContainsString(metadata.permissions, permissions: NCGlobal.shared.permissionCanRename)
-        if !(metadata.permissions == "") && !permission {
+        if !metadata.permissions.isEmpty && !permission {
             return NKError(errorCode: NCGlobal.shared.errorInternalError, errorDescription: "_no_permission_modify_file_")
         }
 

+ 3 - 3
iOSClient/Networking/NCNetworkingCheckRemoteUser.swift

@@ -27,9 +27,9 @@ class NCNetworkingCheckRemoteUser {
 
     func checkRemoteUser(account: String, error: NKError) {
 
-        guard let tableAccount = NCManageDatabase.shared.getAccount(predicate: NSPredicate(format: "account == %@", account)),  
-            let token = CCUtility.getPassword(account), !token.isEmpty,
-            let appDelegate = UIApplication.shared.delegate as? AppDelegate else { return }
+        guard let tableAccount = NCManageDatabase.shared.getAccount(predicate: NSPredicate(format: "account == %@", account)),
+              let token = CCUtility.getPassword(account), !token.isEmpty,
+              let appDelegate = UIApplication.shared.delegate as? AppDelegate else { return }
 
         NCNetworking.shared.cancelSessions(inBackground: true)
 

+ 7 - 4
iOSClient/Networking/NCNetworkingProcessUpload.swift

@@ -33,7 +33,10 @@ class NCNetworkingProcessUpload: NSObject {
         return instance
     }()
 
+    // swiftlint:disable force_cast
     private let appDelegate = UIApplication.shared.delegate as! AppDelegate
+    // swiftlint:enable force_cast
+
     private var notificationToken: NotificationToken?
     private var timerProcess: Timer?
     private var pauseProcess: Bool = false
@@ -47,7 +50,7 @@ class NCNetworkingProcessUpload: NSObject {
                 case .initial:
                     print("Initial")
                 case .update(_, let deletions, let insertions, let modifications):
-                    if deletions.count > 0 || insertions.count > 0 || modifications.count > 0 {
+                    if !deletions.isEmpty || !insertions.isEmpty || !modifications.isEmpty {
                         self?.invalidateObserveTableMetadata()
                         self?.start(completition: { items in
                             print("[LOG] PROCESS-UPLOAD-OBSERVE \(items)")
@@ -125,7 +128,7 @@ class NCNetworkingProcessUpload: NSObject {
                 }
             }
             // CHUNK
-            if metadatasUpload.filter({ $0.chunk > 0 }).count > 0 {
+            if !metadatasUpload.filter({ $0.chunk > 0 }).isEmpty {
                 self.pauseProcess = false
                 return completition(counterUpload)
             }
@@ -136,7 +139,7 @@ class NCNetworkingProcessUpload: NSObject {
 
                     let limit = maxConcurrentOperationUpload - counterUpload
                     let metadatas = NCManageDatabase.shared.getAdvancedMetadatas(predicate: NSPredicate(format: "account == %@ AND sessionSelector == %@ AND status == %d", self.appDelegate.account, sessionSelector, NCGlobal.shared.metadataStatusWaitUpload), page: 1, limit: limit, sorted: "date", ascending: true)
-                    if metadatas.count > 0 {
+                    if !metadatas.isEmpty {
                         NextcloudKit.shared.nkCommonInstance.writeLog("[INFO] PROCESS-UPLOAD find \(metadatas.count) items")
                     }
 
@@ -193,7 +196,7 @@ class NCNetworkingProcessUpload: NSObject {
                     for metadata in metadatas {
                         // Verify QUOTA
                         if metadata.sessionError.contains("\(NCGlobal.shared.errorQuota)") {
-                            NextcloudKit.shared.getUserProfile { account, userProfile, _, error in
+                            NextcloudKit.shared.getUserProfile { _, userProfile, _, error in
                                 if error == .success, let userProfile, userProfile.quotaFree > 0, userProfile.quotaFree > metadata.size {
                                     NCManageDatabase.shared.setMetadataSession(ocId: metadata.ocId, session: NCNetworking.shared.sessionIdentifierBackground, sessionError: "", sessionTaskIdentifier: 0, status: NCGlobal.shared.metadataStatusWaitUpload)
                                 }

+ 2 - 3
iOSClient/Networking/NCOperationQueue.swift

@@ -51,7 +51,7 @@ import JGProgressHUD
     // MARK: - Download file
 
     func download(metadata: tableMetadata, selector: String) {
-        
+
         for case let operation as NCOperationDownload in downloadQueue.operations where operation.metadata.ocId == metadata.ocId { return }
         downloadQueue.addOperation(NCOperationDownload(metadata: metadata, selector: selector))
     }
@@ -150,7 +150,7 @@ class NCOperationDownload: ConcurrentOperation {
     override func start() {
 
         guard !isCancelled else { return self.finish() }
-        
+
         NCNetworking.shared.download(metadata: metadata, selector: self.selector) { _, _ in
             self.finish()
         }
@@ -460,4 +460,3 @@ class NCOperationSaveLivePhoto: ConcurrentOperation {
         })
     }
 }
-

+ 5 - 3
iOSClient/Networking/NCService.swift

@@ -31,7 +31,9 @@ class NCService: NSObject {
         return instance
     }()
 
+    // swiftlint:disable force_cast
     let appDelegate = UIApplication.shared.delegate as! AppDelegate
+    // swiftlint:enable force_cast
 
     // MARK: -
 
@@ -42,7 +44,7 @@ class NCService: NSObject {
         let account = appDelegate.account
 
         NCPushNotification.shared().pushNotification()
-        
+
         Task {
             addInternalTypeIdentifier()
             let result = await requestServerStatus()
@@ -153,7 +155,7 @@ class NCService: NSObject {
         let fileNameLocalPath = String(CCUtility.getDirectoryUserData()) + "/" + fileName
         let etag = NCManageDatabase.shared.getTableAvatar(fileName: fileName)?.etag
 
-        NextcloudKit.shared.downloadAvatar(user: appDelegate.userId, 
+        NextcloudKit.shared.downloadAvatar(user: appDelegate.userId,
                                            fileNameLocalPath: fileNameLocalPath,
                                            sizeImage: NCGlobal.shared.avatarSize,
                                            avatarSizeRounded: NCGlobal.shared.avatarSizeRounded,
@@ -165,7 +167,7 @@ class NCService: NSObject {
             } else if error.errorCode == NCGlobal.shared.errorNotModified {
                 NCManageDatabase.shared.setAvatarLoaded(fileName: fileName)
             }
-            NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterReloadAvatar, userInfo: ["error":error])
+            NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterReloadAvatar, userInfo: ["error": error])
         }
     }
 

+ 9 - 4
iOSClient/Notification/NCNotification.swift

@@ -29,7 +29,10 @@ import JGProgressHUD
 
 class NCNotification: UITableViewController, NCNotificationCellDelegate, NCEmptyDataSetDelegate {
 
+    // swiftlint:disable force_cast
     let appDelegate = UIApplication.shared.delegate as! AppDelegate
+    // swiftlint:enable force_cast
+
     var notifications: [NKNotifications] = []
     var emptyDataSet: NCEmptyDataSet?
     var isReloadDataSourceNetworkInProgress: Bool = false
@@ -115,7 +118,7 @@ class NCNotification: UITableViewController, NCNotificationCellDelegate, NCEmpty
 
     override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
 
-        let cell = self.tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath) as! NCNotificationCell
+        guard let cell = self.tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath) as? NCNotificationCell else { return UITableViewCell() }
         cell.delegate = self
         cell.selectionStyle = .none
         cell.indexPath = indexPath
@@ -308,10 +311,12 @@ class NCNotification: UITableViewController, NCNotificationCellDelegate, NCEmpty
                 self.notifications.removeAll()
                 let sortedListOfNotifications = (notifications! as NSArray).sortedArray(using: [NSSortDescriptor(key: "date", ascending: false)])
                 for notification in sortedListOfNotifications {
-                    if let icon = (notification as! NKNotifications).icon {
+                    if let icon = (notification as? NKNotifications)?.icon {
                         NCUtility.shared.convertSVGtoPNGWriteToUserData(svgUrlString: icon, fileName: nil, width: 25, rewrite: false, account: self.appDelegate.account, completion: { _, _ in })
                     }
-                    self.notifications.append(notification as! NKNotifications)
+                    if let notification = (notification as? NKNotifications) {
+                        self.notifications.append(notification)
+                    }
                 }
                 self.refreshControl?.endRefreshing()
                 self.isReloadDataSourceNetworkInProgress = false
@@ -349,7 +354,7 @@ class NCNotificationCell: UITableViewCell, NCCellProtocol {
         set { index = newValue }
     }
     var fileAvatarImageView: UIImageView? {
-        get { return avatar }
+        return avatar
     }
     var fileUser: String? {
         get { return user }

+ 8 - 8
iOSClient/Rename file/NCRenameFile.swift

@@ -156,6 +156,8 @@ class NCRenameFile: UIViewController, UITextFieldDelegate {
 
     @IBAction func renameFile(_ sender: Any) {
 
+        // swiftlint:disable empty_count
+
         var fileNameNoExtensionNew = ""
         var extNew = ""
         var fileNameNew = ""
@@ -165,8 +167,7 @@ class NCRenameFile: UIViewController, UITextFieldDelegate {
             let extCurrent = (metadata.fileNameView as NSString).pathExtension
 
             if fileNameNoExtension.text == nil || fileNameNoExtension.text?.count == 0 {
-                self.fileNameNoExtension.text = (metadata.fileNameView as NSString).deletingPathExtension
-                return
+                return self.fileNameNoExtension.text = (metadata.fileNameView as NSString).deletingPathExtension
             } else {
                 fileNameNoExtensionNew = fileNameNoExtension.text!
             }
@@ -179,8 +180,7 @@ class NCRenameFile: UIViewController, UITextFieldDelegate {
             } else {
 
                 if ext.text == nil || ext.text?.count == 0 {
-                    self.ext.text = metadata.fileExtension
-                    return
+                    return self.ext.text = metadata.fileExtension
                 } else {
                     extNew = ext.text!
                 }
@@ -214,11 +214,9 @@ class NCRenameFile: UIViewController, UITextFieldDelegate {
         } else if let fileName = self.fileName {
 
             if fileNameNoExtension.text == nil || fileNameNoExtension.text?.count == 0 {
-                fileNameNoExtension.text = (fileName as NSString).deletingPathExtension
-                return
+                return fileNameNoExtension.text = (fileName as NSString).deletingPathExtension
             } else if ext.text == nil || ext.text?.count == 0 {
-                ext.text = (fileName as NSString).pathExtension
-                return
+                return ext.text = (fileName as NSString).pathExtension
             }
 
             fileNameNew = (fileNameNoExtension.text ?? "") + "." + (ext.text ?? "")
@@ -226,6 +224,8 @@ class NCRenameFile: UIViewController, UITextFieldDelegate {
                 self.delegate?.rename(fileName: fileName, fileNameNew: fileNameNew)
             }
         }
+
+        // swiftlint:enable empty_count
     }
 
     // MARK: - Networking

+ 3 - 1
iOSClient/RichWorkspace/NCRichWorkspaceCommon.swift

@@ -26,7 +26,9 @@ import NextcloudKit
 
 @objc class NCRichWorkspaceCommon: NSObject {
 
+    // swiftlint:disable force_cast
     let appDelegate = UIApplication.shared.delegate as! AppDelegate
+    // swiftlint:enable force_cast
 
     @objc func createViewerNextcloudText(serverUrl: String, viewController: UIViewController) {
 
@@ -71,7 +73,7 @@ import NextcloudKit
 
         if let metadata = NCManageDatabase.shared.getMetadata(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@ AND fileNameView LIKE[c] %@", appDelegate.account, serverUrl, NCGlobal.shared.fileNameRichWorkspace.lowercased())) {
 
-            if metadata.url == "" {
+            if metadata.url.isEmpty {
 
                 NCActivityIndicator.shared.start(backgroundView: viewController.view)
 

+ 3 - 0
iOSClient/RichWorkspace/NCViewerRichWorkspace.swift

@@ -29,7 +29,10 @@ 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 richWorkspaceCommon = NCRichWorkspaceCommon()
     private var markdownParser = MarkdownParser()
     private var textViewColor: UIColor?

+ 9 - 10
iOSClient/Select/NCSelect.swift

@@ -158,7 +158,7 @@ class NCSelect: UIViewController, UIGestureRecognizerDelegate, UIAdaptivePresent
         self.navigationItem.title = titleCurrentFolder
 
         // set the serverUrl
-        if serverUrl == "" {
+        if serverUrl.isEmpty {
             serverUrl = NCUtilityFileSystem.shared.getHomeServer(urlBase: activeAccount.urlBase, userId: activeAccount.userId)
         }
 
@@ -298,14 +298,14 @@ extension NCSelect: UICollectionViewDataSource {
         // Thumbnail
         if !metadata.directory {
             if FileManager().fileExists(atPath: CCUtility.getDirectoryProviderStorageIconOcId(metadata.ocId, etag: metadata.etag)) {
-                (cell as! NCCellProtocol).filePreviewImageView?.image = UIImage(contentsOfFile: CCUtility.getDirectoryProviderStorageIconOcId(metadata.ocId, etag: metadata.etag))
+                (cell as? NCCellProtocol)?.filePreviewImageView?.image = UIImage(contentsOfFile: CCUtility.getDirectoryProviderStorageIconOcId(metadata.ocId, etag: metadata.etag))
             } else {
                 NCOperationQueue.shared.downloadThumbnail(metadata: metadata, placeholder: true, cell: cell, view: collectionView)
             }
         }
 
         // Avatar
-        if metadata.ownerId.count > 0,
+        if !metadata.ownerId.isEmpty,
            metadata.ownerId != activeAccount.userId,
            activeAccount.account == metadata.account,
            let cell = cell as? NCCellProtocol {
@@ -330,17 +330,14 @@ extension NCSelect: UICollectionViewDataSource {
 
     func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
 
-        guard let metadata = dataSource.cellForItemAt(indexPath: indexPath) else {
-            return collectionView.dequeueReusableCell(withReuseIdentifier: "listCell", for: indexPath) as! NCListCell
-        }
-
+        guard let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "listCell", for: indexPath) as? NCListCell,
+              let metadata = dataSource.cellForItemAt(indexPath: indexPath) else { return UICollectionViewCell() }
         var isShare = false
         var isMounted = false
 
         isShare = metadata.permissions.contains(NCGlobal.shared.permissionShared) && !metadataFolder.permissions.contains(NCGlobal.shared.permissionShared)
         isMounted = metadata.permissions.contains(NCGlobal.shared.permissionMounted) && !metadataFolder.permissions.contains(NCGlobal.shared.permissionMounted)
 
-        let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "listCell", for: indexPath) as! NCListCell
         cell.delegate = self
 
         cell.fileObjectId = metadata.ocId
@@ -428,7 +425,7 @@ extension NCSelect: UICollectionViewDataSource {
 
         if kind == UICollectionView.elementKindSectionHeader {
 
-            let header = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: "sectionHeaderMenu", for: indexPath) as! NCSectionHeaderMenu
+            guard let header = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: "sectionHeaderMenu", for: indexPath) as? NCSectionHeaderMenu else { return UICollectionReusableView() }
             let (_, heightHeaderRichWorkspace, _) = getHeaderHeight(section: indexPath.section)
 
             self.headerMenu = header
@@ -442,7 +439,7 @@ extension NCSelect: UICollectionViewDataSource {
 
         } else {
 
-            let footer = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: "sectionFooter", for: indexPath) as! NCSectionFooter
+            guard let footer = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: "sectionFooter", for: indexPath) as? NCSectionFooter else { return UICollectionReusableView() }
             let sections = dataSource.numberOfSections()
             let section = indexPath.section
 
@@ -469,9 +466,11 @@ extension NCSelect: UICollectionViewDelegateFlowLayout {
 
         if let richWorkspaceText = richWorkspaceText {
             let trimmed = richWorkspaceText.trimmingCharacters(in: .whitespaces)
+            // swiftlint:disable empty_count
             if trimmed.count > 0 {
                 headerRichWorkspace = UIScreen.main.bounds.size.height / 6
             }
+            // swiftlint:enable empty_count
         }
 
         return (0, headerRichWorkspace, 0)

+ 3 - 0
iOSClient/Settings/NCEndToEndInitialize.swift

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

+ 11 - 8
iOSClient/Settings/NCManageAutoUploadFileName.swift

@@ -27,7 +27,10 @@ import NextcloudKit
 
 class NCManageAutoUploadFileName: XLFormViewController {
 
+    // swiftlint:disable force_cast
     let appDelegate = UIApplication.shared.delegate as! AppDelegate
+    // swiftlint:enable force_cast
+
     let dateExample = Date()
 
     func initializeForm() {
@@ -73,7 +76,7 @@ class NCManageAutoUploadFileName: XLFormViewController {
 
         row = XLFormRowDescriptor(tag: "maskFileName", rowType: XLFormRowDescriptorTypeText, title: (NSLocalizedString("_filename_", comment: "")))
         let fileNameMask: String = CCUtility.getFileNameMask(NCGlobal.shared.keyFileNameAutoUploadMask)
-        if fileNameMask.count > 0 {
+        if !fileNameMask.isEmpty {
             row.value = fileNameMask
         }
         row.hidden = "$\("maintainOriginalFileName") == 1"
@@ -167,7 +170,7 @@ class NCManageAutoUploadFileName: XLFormViewController {
             // reload cell
             if fileName != nil {
 
-                if newValue as! String != formRow.value as! String {
+                if newValue as? String != formRow.value as? String {
 
                     self.reloadFormRow(formRow)
 
@@ -194,18 +197,18 @@ class NCManageAutoUploadFileName: XLFormViewController {
 
             let valueRenameTrimming = valueRename.trimmingCharacters(in: CharacterSet.whitespacesAndNewlines)
 
-            if valueRenameTrimming.count > 0 {
+            if valueRenameTrimming.isEmpty {
+
+                CCUtility.setFileNameMask("", key: NCGlobal.shared.keyFileNameAutoUploadMask)
+                returnString = CCUtility.createFileName("IMG_0001.JPG", fileDate: dateExample, fileType: PHAssetMediaType.image, keyFileName: nil, keyFileNameType: NCGlobal.shared.keyFileNameAutoUploadType, keyFileNameOriginal: NCGlobal.shared.keyFileNameOriginalAutoUpload, forcedNewFileName: false)
+
+            } else {
 
                 self.form.delegate = nil
                 CCUtility.setFileNameMask(valueRename, key: NCGlobal.shared.keyFileNameAutoUploadMask)
                 self.form.delegate = self
 
                 returnString = CCUtility.createFileName("IMG_0001.JPG", fileDate: dateExample, fileType: PHAssetMediaType.image, keyFileName: NCGlobal.shared.keyFileNameAutoUploadMask, keyFileNameType: NCGlobal.shared.keyFileNameAutoUploadType, keyFileNameOriginal: NCGlobal.shared.keyFileNameOriginalAutoUpload, forcedNewFileName: false)
-
-            } else {
-
-                CCUtility.setFileNameMask("", key: NCGlobal.shared.keyFileNameAutoUploadMask)
-                returnString = CCUtility.createFileName("IMG_0001.JPG", fileDate: dateExample, fileType: PHAssetMediaType.image, keyFileName: nil, keyFileNameType: NCGlobal.shared.keyFileNameAutoUploadType, keyFileNameOriginal: NCGlobal.shared.keyFileNameOriginalAutoUpload, forcedNewFileName: false)
             }
 
         } else {

+ 11 - 0
iOSClient/Settings/NCManageE2EE.swift

@@ -29,7 +29,11 @@ import LocalAuthentication
 @objc class NCManageE2EEInterface: NSObject {
 
     @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: "")
@@ -40,7 +44,11 @@ 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
+
     var passcodeType = ""
 
     @Published var isEndToEndEnabled: Bool = false
@@ -365,7 +373,10 @@ struct NCViewE2EETest: View {
 
 struct NCViewE2EE_Previews: PreviewProvider {
     static var previews: some View {
+
+        // swiftlint:disable force_cast
         let account = (UIApplication.shared.delegate as! AppDelegate).account
         NCViewE2EE(account: account)
+        // swiftlint:enable force_cast
     }
 }

+ 2 - 0
iOSClient/Share/NCShareCommon.swift

@@ -29,6 +29,7 @@ class NCShareCommon: NSObject {
         return instance
     }()
 
+    // swiftlint:disable identifier_name
     let SHARE_TYPE_USER = 0
     let SHARE_TYPE_GROUP = 1
     let SHARE_TYPE_LINK = 3
@@ -39,6 +40,7 @@ class NCShareCommon: NSObject {
     let SHARE_TYPE_GUEST = 8
     let SHARE_TYPE_REMOTE_GROUP = 9
     let SHARE_TYPE_ROOM = 10
+    // swiftlint:enable identifier_name
 
     func createLinkAvatar(imageName: String, colorCircle: UIColor) -> UIImage? {
 

+ 2 - 0
iOSClient/Share/NCShareNetworking.swift

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

+ 3 - 13
iOSClient/Transfers/NCTransfers.swift

@@ -170,11 +170,9 @@ class NCTransfers: NCCollectionViewCommon, NCTransferCellDelegate {
 
     override func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
 
-        guard let metadata = dataSource.cellForItemAt(indexPath: indexPath) else {
-            return collectionView.dequeueReusableCell(withReuseIdentifier: "transferCell", for: indexPath) as! NCTransferCell
-        }
+        guard let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "transferCell", for: indexPath) as? NCTransferCell,
+              let metadata = dataSource.cellForItemAt(indexPath: indexPath) else { return UICollectionViewCell() }
 
-        let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "transferCell", for: indexPath) as! NCTransferCell
         cell.delegate = self
 
         cell.fileObjectId = metadata.ocId
@@ -187,7 +185,7 @@ class NCTransfers: NCCollectionViewCommon, NCTransferCellDelegate {
         cell.labelTitle.textColor = .label
         let serverUrlHome = NCUtilityFileSystem.shared.getHomeServer(urlBase: metadata.urlBase, userId: metadata.userId)
         var pathText = metadata.serverUrl.replacingOccurrences(of: serverUrlHome, with: "")
-        if pathText == "" { pathText = "/" }
+        if pathText.isEmpty { pathText = "/" }
         cell.labelPath.text = pathText
         cell.setButtonMore(named: NCGlobal.shared.buttonMoreStop, image: NCBrandColor.cacheImages.buttonStop)
         cell.progressView.progress = 0.0
@@ -209,35 +207,27 @@ class NCTransfers: NCCollectionViewCommon, NCTransferCellDelegate {
         case NCGlobal.shared.metadataStatusWaitDownload:
             cell.labelStatus.text = NSLocalizedString("_status_wait_download_", comment: "")
             cell.labelInfo.text = CCUtility.transformedSize(metadata.size)
-            break
         case NCGlobal.shared.metadataStatusInDownload:
             cell.labelStatus.text = NSLocalizedString("_status_in_download_", comment: "")
             cell.labelInfo.text = CCUtility.transformedSize(metadata.size)
-            break
         case NCGlobal.shared.metadataStatusDownloading:
             cell.labelStatus.text = NSLocalizedString("_status_downloading_", comment: "")
             cell.labelInfo.text = CCUtility.transformedSize(metadata.size) + " - ↓ …"
-            break
         case NCGlobal.shared.metadataStatusWaitUpload:
             cell.labelStatus.text = NSLocalizedString("_status_wait_upload_", comment: "")
             cell.labelInfo.text = ""
-            break
         case NCGlobal.shared.metadataStatusInUpload:
             cell.labelStatus.text = NSLocalizedString("_status_in_upload_", comment: "")
             cell.labelInfo.text = CCUtility.transformedSize(metadata.size)
-            break
         case NCGlobal.shared.metadataStatusUploading:
             cell.labelStatus.text = NSLocalizedString("_status_uploading_", comment: "")
             cell.labelInfo.text = CCUtility.transformedSize(metadata.size) + " - ↑ …"
-            break
         case NCGlobal.shared.metadataStatusUploadError:
             cell.labelStatus.text = NSLocalizedString("_status_upload_error_", comment: "")
             cell.labelInfo.text = metadata.sessionError
-            break
         default:
             cell.labelStatus.text = ""
             cell.labelInfo.text = ""
-            break
         }
         if self.appDelegate.account != metadata.account {
             cell.labelInfo.text = NSLocalizedString("_waiting_for_", comment: "") + " " + NSLocalizedString("_user_", comment: "").lowercased() + " \(metadata.userId) " + NSLocalizedString("_in_", comment: "") + " \(metadata.urlBase)"

+ 6 - 6
iOSClient/UserStatus/NCUserStatus.swift

@@ -481,7 +481,7 @@ extension NCUserStatus: UITextFieldDelegate {
 
         if textField is emojiTextField {
 
-            if string.count == 0 {
+            if string.isEmpty {
                 textField.text = "😀"
                 return false
             }
@@ -585,20 +585,20 @@ extension NCUserStatus: UITableViewDataSource {
 
         let status = statusPredefinedStatuses[indexPath.row]
 
-        let icon = cell.viewWithTag(10) as! UILabel
-        let message = cell.viewWithTag(20) as! UILabel
+        let icon = cell.viewWithTag(10) as? UILabel
+        let message = cell.viewWithTag(20) as? UILabel
 
-        icon.text = status.icon
+        icon?.text = status.icon
         var timeString = getPredefinedClearStatusText(clearAt: status.clearAt, clearAtTime: status.clearAtTime, clearAtType: status.clearAtType)
 
         if let messageText = status.message {
 
-            message.text = messageText
+            message?.text = messageText
             timeString = " - " + timeString
 
             let attributedString: NSMutableAttributedString = NSMutableAttributedString(string: messageText + timeString)
             attributedString.setColor(color: .lightGray, font: UIFont.systemFont(ofSize: 15), forText: timeString)
-            message.attributedText = attributedString
+            message?.attributedText = attributedString
         }
 
         return cell

+ 0 - 8
iOSClient/Utility/NCAskAuthorization.swift

@@ -36,7 +36,6 @@ class NCAskAuthorization: NSObject {
         switch AVAudioSession.sharedInstance().recordPermission {
         case AVAudioSession.RecordPermission.granted:
             completion(true)
-            break
         case AVAudioSession.RecordPermission.denied:
             let alert = UIAlertController(title: NSLocalizedString("_error_", comment: ""), message: NSLocalizedString("_err_permission_microphone_", comment: ""), preferredStyle: .alert)
             alert.addAction(UIAlertAction(title: NSLocalizedString("_open_settings_", comment: ""), style: .default, handler: { _ in
@@ -51,7 +50,6 @@ class NCAskAuthorization: NSObject {
             DispatchQueue.main.async {
                 viewController?.present(alert, animated: true, completion: nil)
             }
-            break
         case AVAudioSession.RecordPermission.undetermined:
             AVAudioSession.sharedInstance().requestRecordPermission { allowed in
                 DispatchQueue.main.async {
@@ -62,10 +60,8 @@ class NCAskAuthorization: NSObject {
                     }
                 }
             }
-            break
         default:
             completion(false)
-            break
         }
     }
 
@@ -74,7 +70,6 @@ class NCAskAuthorization: NSObject {
         switch PHPhotoLibrary.authorizationStatus() {
         case PHAuthorizationStatus.authorized:
             completion(true)
-            break
         case PHAuthorizationStatus.denied, PHAuthorizationStatus.limited, PHAuthorizationStatus.restricted:
             let alert = UIAlertController(title: NSLocalizedString("_error_", comment: ""), message: NSLocalizedString("_err_permission_photolibrary_", comment: ""), preferredStyle: .alert)
             alert.addAction(UIAlertAction(title: NSLocalizedString("_open_settings_", comment: ""), style: .default, handler: { _ in
@@ -89,7 +84,6 @@ class NCAskAuthorization: NSObject {
             DispatchQueue.main.async {
                 viewController?.present(alert, animated: true, completion: nil)
             }
-            break
         case PHAuthorizationStatus.notDetermined:
             isRequesting = true
             PHPhotoLibrary.requestAuthorization { allowed in
@@ -105,10 +99,8 @@ class NCAskAuthorization: NSObject {
                     }
                 }
             }
-            break
         default:
             completion(false)
-            break
         }
     }
 

+ 4 - 0
iOSClient/Utility/NCCameraRoll.swift

@@ -72,6 +72,7 @@ class NCCameraRoll: NSObject {
                 let toPath = CCUtility.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileNameView)!
                 NCUtilityFileSystem.shared.moveFile(atPath: fileNamePath, toPath: toPath)
                 let fetchAssets = PHAsset.fetchAssets(withLocalIdentifiers: [metadataSource.assetLocalIdentifier], options: nil)
+                // swiftlint:disable empty_count
                 if metadata.livePhoto, fetchAssets.count > 0 {
                     self.createMetadataLivePhoto(metadata: metadata, asset: fetchAssets.firstObject) { metadata in
                         if let metadata = metadata, let metadata = NCManageDatabase.shared.addMetadata(metadata) {
@@ -82,6 +83,7 @@ class NCCameraRoll: NSObject {
                 } else {
                     completition(metadatas)
                 }
+                // swiftlint:enable empty_count
             } else {
                 completition(metadatas)
             }
@@ -127,9 +129,11 @@ class NCCameraRoll: NSObject {
         }
 
         let fetchAssets = PHAsset.fetchAssets(withLocalIdentifiers: [metadata.assetLocalIdentifier], options: nil)
+        // swiftlint:disable empty_count
         guard fetchAssets.count > 0, let asset = fetchAssets.firstObject else {
             return callCompletionWithError()
         }
+        // swiftlint:enable empty_count
 
         let extensionAsset = asset.originalFilename.pathExtension.uppercased()
         let creationDate = asset.creationDate ?? Date()

+ 1 - 1
iOSClient/Utility/NCContentPresenter.swift

@@ -126,7 +126,7 @@ class NCContentPresenter: NSObject {
                         print("Something went wrong")
                     }
                 }
-                if error.errorDescription.trimmingCharacters(in: .whitespacesAndNewlines) == "" { return }
+                if error.errorDescription.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty { return }
                 let description = NSLocalizedString(error.errorDescription, comment: "")
                 self.flatTop(title: NSLocalizedString(title, comment: ""), description: description + responseMessage + " \(error.errorCode)", delay: delay, imageName: nil, type: type, priority: priority, dropEnqueuedEntries: dropEnqueuedEntries)
             }

+ 1 - 1
iOSClient/Utility/NCStoreReview.swift

@@ -36,7 +36,7 @@ class NCStoreReview: NSObject {
 
         var runs = 0
         if savedRuns != nil {
-            runs = savedRuns as! Int
+            runs = savedRuns as? Int ?? 0
         }
 
         print("Nextcloud iOS run Counts are \(runs)")

+ 25 - 70
iOSClient/Utility/NCUtility.swift

@@ -75,8 +75,7 @@ class NCUtility: NSObject {
                             let renderFormat = UIGraphicsImageRendererFormat.default()
                             renderFormat.opaque = false
                             let renderer = UIGraphicsImageRenderer(size: CGSize(width: newSize.width, height: newSize.height), format: renderFormat)
-                            newImage = renderer.image {
-                                _ in
+                            newImage = renderer.image { _ in
                                 image.draw(in: CGRect(x: 0, y: 0, width: newSize.width, height: newSize.height))
                             }
                         }
@@ -150,7 +149,7 @@ class NCUtility: NSObject {
         }
 
         // mimetype
-        if NCGlobal.shared.capabilityRichdocumentsMimetypes.count > 0 && mimeType.components(separatedBy: ".").count > 2 {
+        if !NCGlobal.shared.capabilityRichdocumentsMimetypes.isEmpty && mimeType.components(separatedBy: ".").count > 2 {
 
             let mimeTypeArray = mimeType.components(separatedBy: ".")
             let mimeType = mimeTypeArray[mimeTypeArray.count - 2] + "." + mimeTypeArray[mimeTypeArray.count - 1]
@@ -319,7 +318,7 @@ class NCUtility: NSObject {
             statusMessage += userMessage
         }
         statusMessage = statusMessage.trimmingCharacters(in: .whitespaces)
-        if statusMessage == "" {
+        if statusMessage.isEmpty {
             statusMessage = messageUserDefined
         }
 
@@ -619,72 +618,28 @@ class NCUtility: NSObject {
     }
 
     func getEncondingDataType(data: Data) -> String.Encoding? {
-        if let _ = String(data: data, encoding: .utf8) {
-            return .utf8
-        }
-        if let _ = String(data: data, encoding: .ascii) {
-            return .ascii
-        }
-        if let _ = String(data: data, encoding: .isoLatin1) {
-            return .isoLatin1
-        }
-        if let _ = String(data: data, encoding: .isoLatin2) {
-            return .isoLatin2
-        }
-        if let _ = String(data: data, encoding: .windowsCP1250) {
-            return .windowsCP1250
-        }
-        if let _ = String(data: data, encoding: .windowsCP1251) {
-            return .windowsCP1251
-        }
-        if let _ = String(data: data, encoding: .windowsCP1252) {
-            return .windowsCP1252
-        }
-        if let _ = String(data: data, encoding: .windowsCP1253) {
-            return .windowsCP1253
-        }
-        if let _ = String(data: data, encoding: .windowsCP1254) {
-            return .windowsCP1254
-        }
-        if let _ = String(data: data, encoding: .macOSRoman) {
-            return .macOSRoman
-        }
-        if let _ = String(data: data, encoding: .japaneseEUC) {
-            return .japaneseEUC
-        }
-        if let _ = String(data: data, encoding: .nextstep) {
-            return .nextstep
-        }
-        if let _ = String(data: data, encoding: .nonLossyASCII) {
-            return .nonLossyASCII
-        }
-        if let _ = String(data: data, encoding: .shiftJIS) {
-            return .shiftJIS
-        }
-        if let _ = String(data: data, encoding: .symbol) {
-            return .symbol
-        }
-        if let _ = String(data: data, encoding: .unicode) {
-            return .unicode
-        }
-        if let _ = String(data: data, encoding: .utf16) {
-            return .utf16
-        }
-        if let _ = String(data: data, encoding: .utf16BigEndian) {
-            return .utf16BigEndian
-        }
-        if let _ = String(data: data, encoding: .utf16LittleEndian) {
-            return .utf16LittleEndian
-        }
-        if let _ = String(data: data, encoding: .utf32) {
-            return .utf32
-        }
-        if let _ = String(data: data, encoding: .utf32BigEndian) {
-            return .utf32BigEndian
-        }
-        if let _ = String(data: data, encoding: .utf32LittleEndian) {
-            return .utf32LittleEndian
-        }
+        if String(data: data, encoding: .utf8) != nil { return .utf8 }
+        if String(data: data, encoding: .ascii) != nil { return .ascii }
+        if String(data: data, encoding: .isoLatin1) != nil { return .isoLatin1 }
+        if String(data: data, encoding: .isoLatin2) != nil { return .isoLatin2 }
+        if String(data: data, encoding: .windowsCP1250) != nil { return .windowsCP1250 }
+        if String(data: data, encoding: .windowsCP1251) != nil { return .windowsCP1251 }
+        if String(data: data, encoding: .windowsCP1252) != nil { return .windowsCP1252 }
+        if String(data: data, encoding: .windowsCP1253) != nil { return .windowsCP1253 }
+        if String(data: data, encoding: .windowsCP1254) != nil { return .windowsCP1254 }
+        if String(data: data, encoding: .macOSRoman) != nil { return .macOSRoman }
+        if String(data: data, encoding: .japaneseEUC) != nil { return .japaneseEUC }
+        if String(data: data, encoding: .nextstep) != nil { return .nextstep }
+        if String(data: data, encoding: .nonLossyASCII) != nil { return .nonLossyASCII }
+        if String(data: data, encoding: .shiftJIS) != nil { return .shiftJIS }
+        if String(data: data, encoding: .symbol) != nil { return .symbol }
+        if String(data: data, encoding: .unicode) != nil { return .unicode }
+        if String(data: data, encoding: .utf16) != nil { return .utf16 }
+        if String(data: data, encoding: .utf16BigEndian) != nil { return .utf16BigEndian }
+        if String(data: data, encoding: .utf16LittleEndian) != nil { return .utf16LittleEndian }
+        if String(data: data, encoding: .utf32) != nil { return .utf32 }
+        if String(data: data, encoding: .utf32BigEndian) != nil { return .utf32BigEndian }
+        if String(data: data, encoding: .utf32LittleEndian) != nil { return .utf32LittleEndian }
         return nil
     }
 

+ 4 - 4
iOSClient/Utility/NCUtilityFileSystem.swift

@@ -199,7 +199,7 @@ class NCUtilityFileSystem: NSObject {
                     let characters = Array(name)
 
                     if characters.count < 2 {
-                        if ext == "" {
+                        if ext.isEmpty {
                             resultFileName = name + " " + "1"
                         } else {
                             resultFileName = name + " " + "1" + "." + ext
@@ -211,13 +211,13 @@ class NCUtilityFileSystem: NSObject {
                         if space == " " && num != nil {
                             name = String(name.dropLast())
                             num = num! + 1
-                            if ext == "" {
+                            if ext.isEmpty {
                                 resultFileName = name + "\(num!)"
                             } else {
                                 resultFileName = name + "\(num!)" + "." + ext
                             }
                         } else {
-                            if ext == "" {
+                            if ext.isEmpty {
                                 resultFileName = name + " " + "1"
                             } else {
                                 resultFileName = name + " " + "1" + "." + ext
@@ -287,7 +287,7 @@ class NCUtilityFileSystem: NSObject {
                         // check offline
                         if offlineFiles.contains(fileURL.path) { continue }
                         let filter = offlineDir.filter({ fileURL.path.hasPrefix($0)})
-                        if filter.count > 0 { continue }
+                        if !filter.isEmpty { continue }
                         // check date
                         if meetsRequirement(date: date) {
                             let folderURL = fileURL.deletingLastPathComponent()

+ 22 - 25
iOSClient/Viewer/NCViewer.swift

@@ -31,7 +31,10 @@ class NCViewer: NSObject {
         return instance
     }()
 
+    // swiftlint:disable force_cast
     let appDelegate = UIApplication.shared.delegate as! AppDelegate
+    // swiftlint:enable force_cast
+
     private var viewerQuickLook: NCViewerQuickLook?
     private var metadata = tableMetadata()
     private var metadatas: [tableMetadata] = []
@@ -70,9 +73,8 @@ class NCViewer: NSObject {
         // IMAGE AUDIO VIDEO
         if metadata.isImage || metadata.isAudioOrVideo {
 
-            if let navigationController = viewController.navigationController {
-
-                let viewerMediaPageContainer: NCViewerMediaPage = UIStoryboard(name: "NCViewerMediaPage", bundle: nil).instantiateInitialViewController() as! NCViewerMediaPage
+            if let navigationController = viewController.navigationController,
+               let viewerMediaPageContainer: NCViewerMediaPage = UIStoryboard(name: "NCViewerMediaPage", bundle: nil).instantiateInitialViewController() as? NCViewerMediaPage {
                 var index = 0
                 for medatasImage in metadatas {
                     if medatasImage.ocId == metadata.ocId {
@@ -94,9 +96,8 @@ class NCViewer: NSObject {
             // PDF
             if metadata.contentType == "application/pdf" || metadata.contentType == "com.adobe.pdf" {
 
-                if let navigationController = viewController.navigationController {
-
-                    let viewController: NCViewerPDF = UIStoryboard(name: "NCViewerPDF", bundle: nil).instantiateInitialViewController() as! NCViewerPDF
+                if let navigationController = viewController.navigationController,
+                   let viewController: NCViewerPDF = UIStoryboard(name: "NCViewerPDF", bundle: nil).instantiateInitialViewController() as? NCViewerPDF {
 
                     viewController.metadata = metadata
                     viewController.titleView = metadata.fileNameView
@@ -112,9 +113,9 @@ class NCViewer: NSObject {
             let availableRichDocument = NCUtility.shared.isRichDocument(metadata)
 
             // RichDocument: Collabora
-            if (isRichDocument || (availableRichDocument && editors.count == 0)) && NextcloudKit.shared.isNetworkReachable() {
+            if (isRichDocument || (availableRichDocument && editors.isEmpty)) && NextcloudKit.shared.isNetworkReachable() {
 
-                if metadata.url == "" {
+                if metadata.url.isEmpty {
 
                     NCActivityIndicator.shared.start(backgroundView: viewController.view)
                     NextcloudKit.shared.createUrlRichdocuments(fileID: metadata.fileId) { account, url, _, error in
@@ -123,9 +124,8 @@ class NCViewer: NSObject {
 
                         if error == .success && account == self.appDelegate.account && url != nil {
 
-                            if let navigationController = viewController.navigationController {
-
-                                let viewController: NCViewerRichdocument = UIStoryboard(name: "NCViewerRichdocument", bundle: nil).instantiateInitialViewController() as! NCViewerRichdocument
+                            if let navigationController = viewController.navigationController,
+                               let viewController: NCViewerRichdocument = UIStoryboard(name: "NCViewerRichdocument", bundle: nil).instantiateInitialViewController() as? NCViewerRichdocument {
 
                                 viewController.metadata = metadata
                                 viewController.link = url!
@@ -142,9 +142,8 @@ class NCViewer: NSObject {
 
                 } else {
 
-                    if let navigationController = viewController.navigationController {
-
-                        let viewController: NCViewerRichdocument = UIStoryboard(name: "NCViewerRichdocument", bundle: nil).instantiateInitialViewController() as! NCViewerRichdocument
+                    if let navigationController = viewController.navigationController,
+                       let viewController: NCViewerRichdocument = UIStoryboard(name: "NCViewerRichdocument", bundle: nil).instantiateInitialViewController() as? NCViewerRichdocument {
 
                         viewController.metadata = metadata
                         viewController.link = metadata.url
@@ -158,9 +157,9 @@ class NCViewer: NSObject {
             }
 
             // DirectEditing: Nextcloud Text - OnlyOffice
-            if editors.count > 0 && NextcloudKit.shared.isNetworkReachable() {
+            if !editors.isEmpty, NextcloudKit.shared.isNetworkReachable() {
 
-                if editor == "" {
+                if editor.isEmpty {
                     if editors.contains(NCGlobal.shared.editorText) {
                         editor = NCGlobal.shared.editorText
                     } else if editors.contains(NCGlobal.shared.editorOnlyoffice) {
@@ -170,7 +169,7 @@ class NCViewer: NSObject {
 
                 if editor == NCGlobal.shared.editorText || editor == NCGlobal.shared.editorOnlyoffice {
 
-                    if metadata.url == "" {
+                    if metadata.url.isEmpty {
 
                         let fileNamePath = CCUtility.returnFileNamePath(fromFileName: metadata.fileName, serverUrl: metadata.serverUrl, urlBase: metadata.urlBase, userId: metadata.userId, account: metadata.account)!
 
@@ -188,9 +187,8 @@ class NCViewer: NSObject {
 
                             if error == .success && account == self.appDelegate.account && url != nil {
 
-                                if let navigationController = viewController.navigationController {
-
-                                    let viewController: NCViewerNextcloudText = UIStoryboard(name: "NCViewerNextcloudText", bundle: nil).instantiateInitialViewController() as! NCViewerNextcloudText
+                                if let navigationController = viewController.navigationController,
+                                   let viewController: NCViewerNextcloudText = UIStoryboard(name: "NCViewerNextcloudText", bundle: nil).instantiateInitialViewController() as? NCViewerNextcloudText {
 
                                     viewController.metadata = metadata
                                     viewController.editor = editor
@@ -208,9 +206,8 @@ class NCViewer: NSObject {
 
                     } else {
 
-                        if let navigationController = viewController.navigationController {
-
-                            let viewController: NCViewerNextcloudText = UIStoryboard(name: "NCViewerNextcloudText", bundle: nil).instantiateInitialViewController() as! NCViewerNextcloudText
+                        if let navigationController = viewController.navigationController,
+                           let viewController: NCViewerNextcloudText = UIStoryboard(name: "NCViewerNextcloudText", bundle: nil).instantiateInitialViewController() as? NCViewerNextcloudText {
 
                             viewController.metadata = metadata
                             viewController.editor = editor
@@ -248,8 +245,8 @@ class NCViewer: NSObject {
 
 extension NCViewer: NCSelectDelegate {
     func dismissSelect(serverUrl: String?, metadata: tableMetadata?, type: String, items: [Any], indexPath: [IndexPath], overwrite: Bool, copy: Bool, move: Bool) {
-        if let serverUrl = serverUrl {
-            let metadata = items[0] as! tableMetadata
+        if let serverUrl = serverUrl,
+           let metadata = items[0] as? tableMetadata {
             if move {
                 Task {
                     let error = await NCNetworking.shared.moveMetadata(metadata, serverUrlTo: serverUrl, overwrite: overwrite)

+ 3 - 7
iOSClient/Viewer/NCViewerMedia/NCPlayer/NCPlayer.swift

@@ -28,7 +28,10 @@ import MobileVLCKit
 
 class NCPlayer: NSObject {
 
+    // swiftlint:disable force_cast
     internal let appDelegate = UIApplication.shared.delegate as! AppDelegate
+    // swiftlint:enable force_cast
+
     internal var url: URL?
     internal var player = VLCMediaPlayer()
     internal var dialogProvider: VLCDialogProvider?
@@ -246,13 +249,10 @@ extension NCPlayer: VLCMediaPlayerDelegate {
         case .stopped:
             playerToolBar?.playButtonPlay()
             print("Played mode: STOPPED")
-            break
         case .opening:
             print("Played mode: OPENING")
-            break
         case .buffering:
             print("Played mode: BUFFERING")
-            break
         case .ended:
             NCManageDatabase.shared.addVideo(metadata: self.metadata, position: 0)
             DispatchQueue.main.asyncAfter(deadline: .now() + 1) {
@@ -262,10 +262,8 @@ extension NCPlayer: VLCMediaPlayerDelegate {
             }
             playerToolBar?.playButtonPlay()
             print("Played mode: ENDED")
-            break
         case .error:
             print("Played mode: ERROR")
-            break
         case .playing:
             guard let playerToolBar = playerToolBar else { return }
             if playerToolBar.playerButtonView.isHidden {
@@ -296,11 +294,9 @@ extension NCPlayer: VLCMediaPlayerDelegate {
             playerToolBar.updateTopToolBar(videoSubTitlesIndexes: player.videoSubTitlesIndexes, audioTrackIndexes: player.audioTrackIndexes)
             NCManageDatabase.shared.addVideo(metadata: metadata, width: self.width, height: self.height, length: self.length)
             print("Played mode: PLAYING")
-            break
         case .paused:
             playerToolBar?.playButtonPlay()
             print("Played mode: PAUSED")
-            break
         default: break
         }
     }

+ 23 - 19
iOSClient/Viewer/NCViewerMedia/NCPlayer/NCPlayerToolBar.swift

@@ -370,17 +370,18 @@ extension NCPlayerToolBar {
 
                     guard let metadata = self.metadata else { return }
                     let storyboard = UIStoryboard(name: "NCSelect", bundle: nil)
-                    let navigationController = storyboard.instantiateInitialViewController() as! UINavigationController
-                    let viewController = navigationController.topViewController as! NCSelect
+                    if let navigationController = storyboard.instantiateInitialViewController() as? UINavigationController,
+                       let viewController = navigationController.topViewController as? NCSelect {
 
-                    viewController.delegate = self
-                    viewController.typeOfCommandView = .nothing
-                    viewController.includeDirectoryE2EEncryption = false
-                    viewController.enableSelectFile = true
-                    viewController.type = "subtitle"
-                    viewController.serverUrl = metadata.serverUrl
+                        viewController.delegate = self
+                        viewController.typeOfCommandView = .nothing
+                        viewController.includeDirectoryE2EEncryption = false
+                        viewController.enableSelectFile = true
+                        viewController.type = "subtitle"
+                        viewController.serverUrl = metadata.serverUrl
 
-                    self.viewerMediaPage?.present(navigationController, animated: true, completion: nil)
+                        self.viewerMediaPage?.present(navigationController, animated: true, completion: nil)
+                    }
                 }
             )
         )
@@ -435,17 +436,18 @@ extension NCPlayerToolBar {
 
                     guard let metadata = self.metadata else { return }
                     let storyboard = UIStoryboard(name: "NCSelect", bundle: nil)
-                    let navigationController = storyboard.instantiateInitialViewController() as! UINavigationController
-                    let viewController = navigationController.topViewController as! NCSelect
+                    if let navigationController = storyboard.instantiateInitialViewController() as? UINavigationController,
+                        let viewController = navigationController.topViewController as? NCSelect {
 
-                    viewController.delegate = self
-                    viewController.typeOfCommandView = .nothing
-                    viewController.includeDirectoryE2EEncryption = false
-                    viewController.enableSelectFile = true
-                    viewController.type = "audio"
-                    viewController.serverUrl = metadata.serverUrl
+                        viewController.delegate = self
+                        viewController.typeOfCommandView = .nothing
+                        viewController.includeDirectoryE2EEncryption = false
+                        viewController.enableSelectFile = true
+                        viewController.type = "audio"
+                        viewController.serverUrl = metadata.serverUrl
 
-                    self.viewerMediaPage?.present(navigationController, animated: true, completion: nil)
+                        self.viewerMediaPage?.present(navigationController, animated: true, completion: nil)
+                    }
                 }
             )
         )
@@ -497,7 +499,9 @@ extension NCPlayerToolBar: NCSelectDelegate {
         }
     }
 
+    // swiftlint:disable inclusive_language
     func addPlaybackSlave(type: String, metadata: tableMetadata) {
+    // swiftlint:enable inclusive_language
 
         let fileNameLocalPath = CCUtility.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileNameView)!
 
@@ -523,7 +527,7 @@ class NCPlayerToolBarSlider: UISlider {
 
     override func beginTracking(_ touch: UITouch, with event: UIEvent?) -> Bool {
         let percentage = CGFloat((value - minimumValue) / (maximumValue - minimumValue))
-        let thumbSizeHeight = thumbRect(forBounds: bounds, trackRect:trackRect(forBounds: bounds), value:0).size.height
+        let thumbSizeHeight = thumbRect(forBounds: bounds, trackRect: trackRect(forBounds: bounds), value: 0).size.height
         let thumbPosition = thumbSizeHeight + (percentage * (bounds.size.width - (2 * thumbSizeHeight)))
         let touchLocation = touch.location(in: self)
         return touchLocation.x <= (thumbPosition + thumbTouchSize.width) && touchLocation.x >= (thumbPosition - thumbTouchSize.width)

+ 7 - 4
iOSClient/Viewer/NCViewerMedia/NCViewerMedia.swift

@@ -48,7 +48,10 @@ 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
+
     weak var viewerMediaPage: NCViewerMediaPage?
     var playerToolBar: NCPlayerToolBar?
     var ncplayer: NCPlayer?
@@ -243,7 +246,7 @@ class NCViewerMedia: UIViewController {
                 self.imageVideoContainer.isHidden = true
             }
 
-            coordinator.animate(alongsideTransition: { context in
+            coordinator.animate(alongsideTransition: { _ in
                 // back to the original size
                 self.scrollView.zoom(to: CGRect(x: 0, y: 0, width: self.scrollView.bounds.width, height: self.scrollView.bounds.height), animated: false)
                 self.view.layoutIfNeeded()
@@ -276,7 +279,7 @@ class NCViewerMedia: UIViewController {
         self.metadata = metadata
 
         // Download image
-        if !CCUtility.fileProviderStorageExists(metadata) && metadata.isImage && metadata.session == "" {
+        if !CCUtility.fileProviderStorageExists(metadata) && metadata.isImage && metadata.session.isEmpty {
 
             if metadata.livePhoto {
                 let fileName = (metadata.fileNameView as NSString).deletingPathExtension + ".mov"
@@ -362,9 +365,9 @@ class NCViewerMedia: UIViewController {
 
         return image
     }
-    
+
     func downloadImage(withSelector selector: String = "") {
-        NCNetworking.shared.download(metadata: metadata, selector: selector, progressHandler: { progress in
+        NCNetworking.shared.download(metadata: metadata, selector: selector, progressHandler: { _ in
             self.allowPanning = false
         }) { _, _ in
             let image = self.getImageMetadata(self.metadata)

+ 12 - 7
iOSClient/Viewer/NCViewerMedia/NCViewerMediaPage.swift

@@ -36,6 +36,7 @@ class NCViewerMediaPage: UIViewController {
 
     @IBOutlet weak var progressView: UIProgressView!
 
+    // swiftlint:disable force_cast
     var pageViewController: UIPageViewController {
         return self.children[0] as! UIPageViewController
     }
@@ -43,6 +44,7 @@ class NCViewerMediaPage: UIViewController {
     var currentViewController: NCViewerMedia {
         return self.pageViewController.viewControllers![0] as! NCViewerMedia
     }
+    // swiftlint:enable force_cast
 
     private var hideStatusBar: Bool = false {
         didSet {
@@ -189,7 +191,10 @@ class NCViewerMediaPage: UIViewController {
 
     func getViewerMedia(index: Int, metadata: tableMetadata) -> NCViewerMedia {
 
+        // swiftlint:disable force_cast
         let viewerMedia = UIStoryboard(name: "NCViewerMediaPage", bundle: nil).instantiateViewController(withIdentifier: "NCViewerMedia") as! NCViewerMedia
+        // swiftlint:enable force_cast
+
         viewerMedia.index = index
         viewerMedia.metadata = metadata
         viewerMedia.viewerMediaPage = self
@@ -396,7 +401,7 @@ class NCViewerMediaPage: UIViewController {
             hud.dismiss()
         }
     }
-    
+
     @objc func renameFile(_ notification: NSNotification) {
 
         guard let userInfo = notification.userInfo as NSDictionary?,
@@ -458,7 +463,7 @@ class NCViewerMediaPage: UIViewController {
         MPRemoteCommandCenter.shared().skipForwardCommand.isEnabled = true
         skipForwardCommand = MPRemoteCommandCenter.shared().skipForwardCommand.addTarget { event in
 
-            let seconds = Int32((event as! MPSkipIntervalCommandEvent).interval)
+            let seconds = Int32((event as? MPSkipIntervalCommandEvent)?.interval ?? 0)
             ncplayer.player.jumpForward(seconds)
             return.success
         }
@@ -467,7 +472,7 @@ class NCViewerMediaPage: UIViewController {
         MPRemoteCommandCenter.shared().skipBackwardCommand.isEnabled = true
         skipBackwardCommand = MPRemoteCommandCenter.shared().skipBackwardCommand.addTarget { event in
 
-            let seconds = Int32((event as! MPSkipIntervalCommandEvent).interval)
+            let seconds = Int32((event as? MPSkipIntervalCommandEvent)?.interval ?? 0)
             ncplayer.player.jumpBackward(seconds)
             return.success
         }
@@ -526,7 +531,7 @@ extension NCViewerMediaPage: UIPageViewControllerDelegate, UIPageViewControllerD
 
     func shiftCurrentPage() {
 
-        if metadatas.count == 0 {
+        if metadatas.isEmpty {
             self.viewUnload()
             return
         }
@@ -580,9 +585,9 @@ extension NCViewerMediaPage: UIPageViewControllerDelegate, UIPageViewControllerD
 
         if completed && nextIndex != nil {
             previousViewControllers.forEach { viewController in
-                let viewerMedia = viewController as! NCViewerMedia
-                viewerMedia.ncplayer?.playerStop()
-                viewerMedia.closeDetail()
+                let viewerMedia = viewController as? NCViewerMedia
+                viewerMedia?.ncplayer?.playerStop()
+                viewerMedia?.closeDetail()
             }
             currentIndex = nextIndex!
         }

+ 3 - 0
iOSClient/Viewer/NCViewerNextcloudText/NCViewerNextcloudText.swift

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

+ 8 - 8
iOSClient/Viewer/NCViewerPDF/NCViewerPDF.swift

@@ -398,12 +398,12 @@ class NCViewerPDF: UIViewController, NCViewerPDFSearchDelegate {
 
     @objc func searchText() {
 
-        let viewerPDFSearch = UIStoryboard(name: "NCViewerPDF", bundle: nil).instantiateViewController(withIdentifier: "NCViewerPDFSearch") as! NCViewerPDFSearch
-        viewerPDFSearch.delegate = self
-        viewerPDFSearch.pdfDocument = pdfDocument
-
-        let navigaionController = UINavigationController(rootViewController: viewerPDFSearch)
-        self.present(navigaionController, animated: true)
+        if let viewerPDFSearch = UIStoryboard(name: "NCViewerPDF", bundle: nil).instantiateViewController(withIdentifier: "NCViewerPDFSearch") as? NCViewerPDFSearch {
+            viewerPDFSearch.delegate = self
+            viewerPDFSearch.pdfDocument = pdfDocument
+            let navigaionController = UINavigationController(rootViewController: viewerPDFSearch)
+            self.present(navigaionController, animated: true)
+        }
     }
 
     @objc func goToPage() {
@@ -477,12 +477,12 @@ class NCViewerPDF: UIViewController, NCViewerPDFSearchDelegate {
     @objc func gestureOpenPdfThumbnail(_ recognizer: UIScreenEdgePanGestureRecognizer) {
 
         guard let pdfDocument = pdfView.document, !pdfDocument.isLocked else { return }
-        OpenPdfThumbnail()
+        openPdfThumbnail()
     }
 
     // MARK: - OPEN / CLOSE Thumbnail
 
-    func OpenPdfThumbnail() {
+    func openPdfThumbnail() {
 
         if let tipView = self.tipView {
             tipView.dismiss()

+ 13 - 16
iOSClient/Viewer/NCViewerPDF/NCViewerPDFSearch.swift

@@ -73,28 +73,25 @@ class NCViewerPDFSearch: UITableViewController, UISearchBarDelegate, PDFDocument
 
     override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
 
-        let cell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath) as! NCViewerPDFSearchCell
+        guard let cell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath) as? NCViewerPDFSearchCell else { return UITableViewCell() }
         let pdfSelection = searchResultArray[indexPath.row] as PDFSelection
 
-        // if let pdfOutline = pdfDocument?.outlineItem(for: pdfSelection) {
-        //    cell.outlineLabel.text = pdfOutline.label
-        // }
-
         let pdfPage = pdfSelection.pages.first
         let pageNumber = pdfPage?.pageRef?.pageNumber ?? 0
         cell.pageNumberLabel.text = NSLocalizedString("_scan_document_pdf_page_", comment: "") + ": " + String(pageNumber)
 
-        let extendSelection = pdfSelection.copy() as! PDFSelection
-        extendSelection.extend(atStart: 10)
-        extendSelection.extend(atEnd: 90)
-        extendSelection.extendForLineBoundaries()
-
-        let nsRange = NSString(string: extendSelection.string!).range(of: pdfSelection.string!, options: String.CompareOptions.caseInsensitive)
-        if nsRange.location != NSNotFound {
-            let attributedSubString = NSAttributedString(string: NSString(string: extendSelection.string!).substring(with: nsRange), attributes: [NSAttributedString.Key.font: UIFont.boldSystemFont(ofSize: 17), NSAttributedString.Key.foregroundColor: UIColor.systemBlue])
-            let attributedString = NSMutableAttributedString(string: extendSelection.string!)
-            attributedString.replaceCharacters(in: nsRange, with: attributedSubString)
-            cell.searchResultTextLabel.attributedText = attributedString
+        if let extendSelection = pdfSelection.copy() as? PDFSelection {
+            extendSelection.extend(atStart: 10)
+            extendSelection.extend(atEnd: 90)
+            extendSelection.extendForLineBoundaries()
+
+            let nsRange = NSString(string: extendSelection.string!).range(of: pdfSelection.string!, options: String.CompareOptions.caseInsensitive)
+            if nsRange.location != NSNotFound {
+                let attributedSubString = NSAttributedString(string: NSString(string: extendSelection.string!).substring(with: nsRange), attributes: [NSAttributedString.Key.font: UIFont.boldSystemFont(ofSize: 17), NSAttributedString.Key.foregroundColor: UIColor.systemBlue])
+                let attributedString = NSMutableAttributedString(string: extendSelection.string!)
+                attributedString.replaceCharacters(in: nsRange, with: attributedSubString)
+                cell.searchResultTextLabel.attributedText = attributedString
+            }
         }
 
         return cell

+ 0 - 7
iOSClient/Viewer/NCViewerProviderContextMenu.swift

@@ -290,30 +290,23 @@ extension NCViewerProviderContextMenu: VLCMediaPlayerDelegate {
         switch player.state {
         case .stopped:
             print("Played mode: STOPPED")
-            break
         case .opening:
             NCActivityIndicator.shared.start(backgroundView: self.view)
             print("Played mode: OPENING")
-            break
         case .buffering:
             print("Played mode: BUFFERING")
-            break
         case .ended:
             print("Played mode: ENDED")
-            break
         case .error:
             NCActivityIndicator.shared.stop()
             let error = NKError(errorCode: NCGlobal.shared.errorInternalError, errorDescription: "_error_something_wrong_")
             NCContentPresenter.shared.showError(error: error, priority: .max)
             print("Played mode: ERROR")
-            break
         case .playing:
             NCActivityIndicator.shared.stop()
             print("Played mode: PLAYING")
-            break
         case .paused:
             print("Played mode: PAUSED")
-            break
         default: break
         }
     }

+ 17 - 12
iOSClient/Viewer/NCViewerRichdocument/NCViewerRichdocument.swift

@@ -27,7 +27,10 @@ import NextcloudKit
 
 class NCViewerRichdocument: UIViewController, WKNavigationDelegate, WKScriptMessageHandler, NCSelectDelegate {
 
+    // swiftlint:disable force_cast
     let appDelegate = UIApplication.shared.delegate as! AppDelegate
+    // swiftlint:enable force_cast
+
     var webView = WKWebView()
     var bottomConstraint: NSLayoutConstraint?
     var documentController: UIDocumentInteractionController?
@@ -161,16 +164,17 @@ class NCViewerRichdocument: UIViewController, WKNavigationDelegate, WKScriptMess
             if message.body as? String == "insertGraphic" {
 
                 let storyboard = UIStoryboard(name: "NCSelect", bundle: nil)
-                let navigationController = storyboard.instantiateInitialViewController() as! UINavigationController
-                let viewController = navigationController.topViewController as! NCSelect
+                if let navigationController = storyboard.instantiateInitialViewController() as? UINavigationController,
+                   let viewController = navigationController.topViewController as? NCSelect {
 
-                viewController.delegate = self
-                viewController.typeOfCommandView = .select
-                viewController.enableSelectFile = true
-                viewController.includeImages = true
-                viewController.type = ""
+                    viewController.delegate = self
+                    viewController.typeOfCommandView = .select
+                    viewController.enableSelectFile = true
+                    viewController.includeImages = true
+                    viewController.type = ""
 
-                self.present(navigationController, animated: true, completion: nil)
+                    self.present(navigationController, animated: true, completion: nil)
+                }
             }
 
             if message.body as? String == "share" {
@@ -188,11 +192,12 @@ class NCViewerRichdocument: UIViewController, WKNavigationDelegate, WKScriptMess
 
                         if type == "slideshow" {
 
-                            let browserWebVC = UIStoryboard(name: "NCBrowserWeb", bundle: nil).instantiateInitialViewController() as! NCBrowserWeb
-                            browserWebVC.urlBase = urlString
-                            browserWebVC.isHiddenButtonExit = false
-                            self.present(browserWebVC, animated: true)
+                            if let browserWebVC = UIStoryboard(name: "NCBrowserWeb", bundle: nil).instantiateInitialViewController() as? NCBrowserWeb {
 
+                                browserWebVC.urlBase = urlString
+                                browserWebVC.isHiddenButtonExit = false
+                                self.present(browserWebVC, animated: true)
+                            }
                             return
 
                         } else {