Skip to content

Commit

Permalink
Update SwiftLint
Browse files Browse the repository at this point in the history
  • Loading branch information
ppraveentr committed Oct 25, 2024
1 parent 84f9e40 commit 5ec3a95
Show file tree
Hide file tree
Showing 16 changed files with 27 additions and 35 deletions.
9 changes: 2 additions & 7 deletions Sources/AppTheming/AppearanceManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down Expand Up @@ -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)
Expand All @@ -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 }
Expand Down
6 changes: 3 additions & 3 deletions Sources/AppTheming/ThemesManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}

Expand Down Expand Up @@ -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)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions Sources/CoreUtility/AppBundle/BundleURLScheme.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/CoreUtility/Extensions/UIView+Utiltiy.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/CoreUtility/Generic/FlattenIterator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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!)
Expand Down
2 changes: 1 addition & 1 deletion Sources/MobileTheming/ThemesManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
//

#if canImport(MobileTheming)
//import CoreUtility
// import CoreUtility
#endif
import Foundation
import SwiftUI
Expand Down
6 changes: 3 additions & 3 deletions Sources/NetworkLayer/Cache/UserCacheManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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<AnyObject, UIImage>()
public fileprivate(set) var imageCache = NSCache<AnyObject, UIImage>()

public func setupUserSession() {
// Setup local cache
Expand Down
5 changes: 2 additions & 3 deletions Sources/NetworkLayer/NetworkLayer/NetworkMananger.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
}
}
Expand Down
5 changes: 2 additions & 3 deletions Sources/NetworkLayer/NetworkLayer/ServiceClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
6 changes: 3 additions & 3 deletions Tests/CoreComponentsTests/ViewControllerProtocolTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Tests/CoreUtilityTests/ConfigurableCellTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import CoreUtility
#endif
import XCTest

fileprivate final class MockViewCellWithoutNib: UIView {
private final class MockViewCellWithoutNib: UIView {
}

final class ConfigurableCellTests: XCTestCase {
Expand Down
2 changes: 1 addition & 1 deletion Tests/NetworkLayerTests/CollectionViewProtocolTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#endif
import XCTest

fileprivate final class MockCollectionViewController: UIViewController, CollectionViewControllerProtocol {
private final class MockCollectionViewController: UIViewController, CollectionViewControllerProtocol {
// Mock: object implementation for testing
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down

0 comments on commit 5ec3a95

Please sign in to comment.