From 5ec3a958eef05965a689e09038219f460d531419 Mon Sep 17 00:00:00 2001 From: Praveen P Date: Fri, 25 Oct 2024 00:01:44 -0400 Subject: [PATCH] Update SwiftLint --- Sources/AppTheming/AppearanceManager.swift | 9 ++------- Sources/AppTheming/ThemesManager.swift | 6 +++--- .../Contollers/UIViewController+Extension.swift | 2 +- Sources/CoreUtility/AppBundle/BundleURLScheme.swift | 3 +-- Sources/CoreUtility/Extensions/UIView+Utiltiy.swift | 2 +- Sources/CoreUtility/Generic/FlattenIterator.swift | 2 +- Sources/MobileTheming/ThemesManager.swift | 2 +- Sources/NetworkLayer/Cache/UserCacheManager.swift | 6 +++--- Sources/NetworkLayer/NetworkLayer/NetworkMananger.swift | 5 ++--- Sources/NetworkLayer/NetworkLayer/ServiceClient.swift | 5 ++--- .../ScrollViewControllerProtocolTests.swift | 2 +- .../TableViewControllerProtocolTests.swift | 6 +++--- .../ViewControllerProtocolTests.swift | 6 +++--- Tests/CoreUtilityTests/ConfigurableCellTests.swift | 2 +- .../NetworkLayerTests/CollectionViewProtocolTests.swift | 2 +- .../WebViewControllerProtocolTests.swift | 2 +- 16 files changed, 27 insertions(+), 35 deletions(-) diff --git a/Sources/AppTheming/AppearanceManager.swift b/Sources/AppTheming/AppearanceManager.swift index 3349260..946472b 100644 --- a/Sources/AppTheming/AppearanceManager.swift +++ b/Sources/AppTheming/AppearanceManager.swift @@ -53,7 +53,7 @@ extension UIView: AppearanceManagerProtocol { @discardableResult @objc public class func setUpAppearance(theme: ThemeModel, containerClass: [UIAppearanceContainer.Type]?) -> UIAppearance { - let appearance = (containerClass == nil) ? self.appearance() : self.appearance(whenContainedInInstancesOf: containerClass!) + let appearance = (containerClass == nil) ? self.appearance() : self.appearance(whenContainedInInstancesOf: containerClass!) if let tintColor = theme[ThemeType.Key.tintColor] { appearance.tintColor = ThemesManager.getColor(tintColor as? String) } @@ -81,11 +81,6 @@ extension UIView: AppearanceManagerProtocol { } extension UISegmentedControl { - override public class func setUpAppearance(theme: ThemeModel, containerClass: [UIAppearanceContainer.Type]?) -> UIAppearance { - super.setUpAppearance(theme: theme, containerClass: containerClass) -// let appearance = (containerClass == nil) ? self.appearance() : self.appearance(whenContainedInInstancesOf: containerClass!) -// return appearance - } public class func setBackgroundImage(imageType: String, image: UIImage) { let image = image.withRenderingMode(.alwaysTemplate) @@ -104,7 +99,7 @@ extension UINavigationBar { // swiftlint:disable cyclomatic_complexity override public class func setUpAppearance(theme: ThemeModel, containerClass: [UIAppearanceContainer.Type]?) -> UIAppearance { super.setUpAppearance(theme: theme, containerClass: containerClass) - let appearance = (containerClass == nil) ? self.appearance() : self.appearance(whenContainedInInstancesOf: containerClass!) + let appearance = (containerClass == nil) ? self.appearance() : self.appearance(whenContainedInInstancesOf: containerClass!) for type in ThemeType.Key.allCases { guard let value = theme[type.rawValue] else { continue } diff --git a/Sources/AppTheming/ThemesManager.swift b/Sources/AppTheming/ThemesManager.swift index 1d6a70e..02e2f2b 100644 --- a/Sources/AppTheming/ThemesManager.swift +++ b/Sources/AppTheming/ThemesManager.swift @@ -114,7 +114,7 @@ open class ThemesManager { public static func getColor(_ colorName: String?) -> UIColor? { guard let colorName = colorName else { return nil } // Check if its image coded string - if (colorName.hasPrefix("@")), let image = ThemesManager.getImage(colorName) { + if colorName.hasPrefix("@"), let image = ThemesManager.getImage(colorName) { return image.getColor() } // Get hex color @@ -296,7 +296,7 @@ extension ThemesManager { // Component - validity fileprivate static func isThemeComponentValid(_ component: String) -> Bool { // Get all the components of spefic type - guard self.themeComponent?[component] as? ThemeModel != nil else { return false } + guard self.themeComponent?[component] is ThemeModel else { return false } return true } @@ -375,7 +375,7 @@ extension ThemesManager { data.removeValue(forKey: arg.key) let dataVersion = NSString(string: key).floatValue if dataVersion <= deviceVersion, let val = arg.value as? ThemeModel, - (baseModel == nil || (baseModel!.1 < dataVersion)) { + baseModel == nil || (baseModel!.1 < dataVersion) { baseModel = (val, dataVersion) } } diff --git a/Sources/CoreComponents/Contollers/UIViewController+Extension.swift b/Sources/CoreComponents/Contollers/UIViewController+Extension.swift index 8ea0138..1e459c6 100644 --- a/Sources/CoreComponents/Contollers/UIViewController+Extension.swift +++ b/Sources/CoreComponents/Contollers/UIViewController+Extension.swift @@ -14,7 +14,7 @@ extension UIViewController { var isBaseViewAdded: Bool { // If baseView is not added, then retun false - return (self.baseView?.superview != self.view && self.view != self.baseView) + (self.baseView?.superview != self.view && self.view != self.baseView) } // MARK: Utility diff --git a/Sources/CoreUtility/AppBundle/BundleURLScheme.swift b/Sources/CoreUtility/AppBundle/BundleURLScheme.swift index 92917bc..36d3b0c 100644 --- a/Sources/CoreUtility/AppBundle/BundleURLScheme.swift +++ b/Sources/CoreUtility/AppBundle/BundleURLScheme.swift @@ -20,8 +20,7 @@ open class BundleURLScheme { for urlType in bundleURLTypes { if let urlSchemes = (urlType as? NSDictionary)?.value(forKey: "CFBundleURLSchemes") as? NSArray, - urlSchemes.contains(scheme) - { + urlSchemes.contains(scheme) { return true } } diff --git a/Sources/CoreUtility/Extensions/UIView+Utiltiy.swift b/Sources/CoreUtility/Extensions/UIView+Utiltiy.swift index a864793..8f9e16c 100644 --- a/Sources/CoreUtility/Extensions/UIView+Utiltiy.swift +++ b/Sources/CoreUtility/Extensions/UIView+Utiltiy.swift @@ -42,7 +42,7 @@ public extension UIView { if val is T { return val as? T } - else if !val.subviews.isEmpty, let subType: T? = val.findInSubView() { + else if !val.subviews.isEmpty, let subType: T? = val.findInSubView() { return subType } } diff --git a/Sources/CoreUtility/Generic/FlattenIterator.swift b/Sources/CoreUtility/Generic/FlattenIterator.swift index 6423821..e1a20e1 100644 --- a/Sources/CoreUtility/Generic/FlattenIterator.swift +++ b/Sources/CoreUtility/Generic/FlattenIterator.swift @@ -49,7 +49,7 @@ public extension FlattenIterator { } // Array else if var dicArray = self as? [Any?] { - dicArray = dicArray.filter({ $0 != nil }) + dicArray = dicArray.filter { $0 != nil } self = dicArray.map { val -> Any in var value = val return stripSubElements(&value!) diff --git a/Sources/MobileTheming/ThemesManager.swift b/Sources/MobileTheming/ThemesManager.swift index 521fb72..d059a8d 100644 --- a/Sources/MobileTheming/ThemesManager.swift +++ b/Sources/MobileTheming/ThemesManager.swift @@ -6,7 +6,7 @@ // #if canImport(MobileTheming) -//import CoreUtility +// import CoreUtility #endif import Foundation import SwiftUI diff --git a/Sources/NetworkLayer/Cache/UserCacheManager.swift b/Sources/NetworkLayer/Cache/UserCacheManager.swift index 70bbf2b..208cd72 100644 --- a/Sources/NetworkLayer/Cache/UserCacheManager.swift +++ b/Sources/NetworkLayer/Cache/UserCacheManager.swift @@ -71,11 +71,11 @@ public class UserCacheManager: UserCacheProtocol { }() // Application level cache, reset when app relaunches - public fileprivate (set) var appCache = JSON() + public fileprivate(set) var appCache = JSON() // session cache, clears when user logout - public fileprivate (set) var userCache: JSON? + public fileprivate(set) var userCache: JSON? // Image cache, clears when user logout - public fileprivate (set) var imageCache = NSCache() + public fileprivate(set) var imageCache = NSCache() public func setupUserSession() { // Setup local cache diff --git a/Sources/NetworkLayer/NetworkLayer/NetworkMananger.swift b/Sources/NetworkLayer/NetworkLayer/NetworkMananger.swift index 66ed8e8..5fd2865 100644 --- a/Sources/NetworkLayer/NetworkLayer/NetworkMananger.swift +++ b/Sources/NetworkLayer/NetworkLayer/NetworkMananger.swift @@ -40,7 +40,7 @@ public class NetworkMananger { // Stub data bundle, used by ServiceClient static var mockBundle: Bundle? - public static var mockBundleResource: URL? = nil { + public static var mockBundleResource: URL? { didSet { if let bundle = mockBundleResource { mockBundle = Bundle(url: bundle) @@ -140,8 +140,7 @@ extension NetworkMananger { if let resourcePath = Bundle.main.path(forResource: self.serviceBindingRulesName, ofType: nil), let content: JSON = NSMutableDictionary(contentsOfFile: resourcePath) as? JSON, - JSONSerialization.isValidJSONObject(content) - { + JSONSerialization.isValidJSONObject(content) { self.sharedInstance.serviceRuels += content } } diff --git a/Sources/NetworkLayer/NetworkLayer/ServiceClient.swift b/Sources/NetworkLayer/NetworkLayer/ServiceClient.swift index 35f535d..ae60545 100644 --- a/Sources/NetworkLayer/NetworkLayer/ServiceClient.swift +++ b/Sources/NetworkLayer/NetworkLayer/ServiceClient.swift @@ -324,7 +324,7 @@ extension ServiceClient { } } - let handler: URLSessionCompletionBlock = { (data: Data?, response: URLResponse?, error: Error?) -> Void in + let handler: URLSessionCompletionBlock = { (data: Data?, response: URLResponse?, error: Error?) in let request = self.serviceRequest // Log Resposne logError(request, error) @@ -373,8 +373,7 @@ extension ServiceClient { ftLog(self.serviceName, ": is data stubbed.") if let path: String = NetworkMananger.mockBundle?.path(forResource: self.serviceName, ofType: "json"), - let data = try? path.dataAtPath() - { + let data = try? path.dataAtPath() { let model = self.processResponseData(data: data) DispatchQueue.main.asyncAfter(deadline: .now() + .milliseconds(2)) { completionHandler?(ServiceStatus.success(self, (model != nil) ? 200 : 500)) diff --git a/Tests/CoreComponentsTests/ScrollViewControllerProtocolTests.swift b/Tests/CoreComponentsTests/ScrollViewControllerProtocolTests.swift index 01f5af4..a313b3a 100644 --- a/Tests/CoreComponentsTests/ScrollViewControllerProtocolTests.swift +++ b/Tests/CoreComponentsTests/ScrollViewControllerProtocolTests.swift @@ -13,7 +13,7 @@ import CoreUtility import UIKit import XCTest -fileprivate final class MockScrollViewController: UIViewController, ScrollViewControllerProtocol { +private final class MockScrollViewController: UIViewController, ScrollViewControllerProtocol { // Optional Protocol implementation: intentionally empty } diff --git a/Tests/CoreComponentsTests/TableViewControllerProtocolTests.swift b/Tests/CoreComponentsTests/TableViewControllerProtocolTests.swift index 6b1ab17..2262283 100644 --- a/Tests/CoreComponentsTests/TableViewControllerProtocolTests.swift +++ b/Tests/CoreComponentsTests/TableViewControllerProtocolTests.swift @@ -12,15 +12,15 @@ import CoreUtility #endif import XCTest -fileprivate final class MockTableViewHeader: UIView { +private final class MockTableViewHeader: UIView { // Temp class extending Protocol for testing } -fileprivate final class MockTableViewController: UIViewController, TableViewControllerProtocol { +private final class MockTableViewController: UIViewController, TableViewControllerProtocol { // Temp class extending Protocol for testing } -fileprivate final class MockCustomTableViewController: UIViewController, TableViewControllerProtocol { +private final class MockCustomTableViewController: UIViewController, TableViewControllerProtocol { var tableStyle: UITableView.Style = .grouped var tableViewEdgeOffsets: UIEdgeInsets = .init(40, 40, 40, 40) } diff --git a/Tests/CoreComponentsTests/ViewControllerProtocolTests.swift b/Tests/CoreComponentsTests/ViewControllerProtocolTests.swift index f2c0b92..83bb113 100644 --- a/Tests/CoreComponentsTests/ViewControllerProtocolTests.swift +++ b/Tests/CoreComponentsTests/ViewControllerProtocolTests.swift @@ -28,9 +28,9 @@ extension MockModelStack: Equatable { } private final class MockViewContoller: UIViewController { - private (set) var isKeyboardWillShowCalled = false - private (set) var isKeyboardDidHideCalled = false - private (set) var isAlertViewPresented = false + private(set) var isKeyboardWillShowCalled = false + private(set) var isKeyboardDidHideCalled = false + private(set) var isAlertViewPresented = false override func keyboardWillShow(_ notification: Notification?) { isKeyboardWillShowCalled = true diff --git a/Tests/CoreUtilityTests/ConfigurableCellTests.swift b/Tests/CoreUtilityTests/ConfigurableCellTests.swift index 14f8efa..8260647 100644 --- a/Tests/CoreUtilityTests/ConfigurableCellTests.swift +++ b/Tests/CoreUtilityTests/ConfigurableCellTests.swift @@ -11,7 +11,7 @@ import CoreUtility #endif import XCTest -fileprivate final class MockViewCellWithoutNib: UIView { +private final class MockViewCellWithoutNib: UIView { } final class ConfigurableCellTests: XCTestCase { diff --git a/Tests/NetworkLayerTests/CollectionViewProtocolTests.swift b/Tests/NetworkLayerTests/CollectionViewProtocolTests.swift index 231d035..abee3a5 100644 --- a/Tests/NetworkLayerTests/CollectionViewProtocolTests.swift +++ b/Tests/NetworkLayerTests/CollectionViewProtocolTests.swift @@ -13,7 +13,7 @@ #endif import XCTest -fileprivate final class MockCollectionViewController: UIViewController, CollectionViewControllerProtocol { +private final class MockCollectionViewController: UIViewController, CollectionViewControllerProtocol { // Mock: object implementation for testing } diff --git a/Tests/NetworkLayerTests/WebViewControllerProtocolTests.swift b/Tests/NetworkLayerTests/WebViewControllerProtocolTests.swift index c445ab2..aa1d41e 100644 --- a/Tests/NetworkLayerTests/WebViewControllerProtocolTests.swift +++ b/Tests/NetworkLayerTests/WebViewControllerProtocolTests.swift @@ -14,7 +14,7 @@ import WebKit import XCTest -fileprivate final class MockKWebViewController: UIViewController, WebViewControllerProtocol { +private final class MockKWebViewController: UIViewController, WebViewControllerProtocol { // Mock: object implementation for testing }