From fb3dc417a4e8e82bf9435e0e98149ca1cf417222 Mon Sep 17 00:00:00 2001 From: Ivan Smolin Date: Tue, 7 Mar 2017 16:32:01 +0500 Subject: [PATCH] podfile.lock update and linter rules update --- LeadKit/.swiftlint.yml | 21 +++++++++++++++---- .../Classes/Cursors/FixedPageCursor.swift | 2 +- .../LeadKit/Classes/Cursors/MapCursor.swift | 2 +- .../Classes/Cursors/StaticCursor.swift | 2 +- .../Classes/Logging/LogFormatter.swift | 1 - .../Classes/Services/NetworkService.swift | 2 +- .../CGContext/CGContext+Initializers.swift | 2 +- .../Extensions/CGImage/CGImage+Alpha.swift | 2 +- .../Extensions/CGImage/CGImage+Creation.swift | 2 +- .../Extensions/CGImage/CGImage+Crop.swift | 2 +- .../Extensions/CGImage/CGImage+Template.swift | 2 +- .../CGImage/CGImage+Transform.swift | 10 ++++----- .../CursorType/CursorType+Slice.swift | 4 ++-- .../IndexPath+ImmutableIndexPath.swift | 4 ++-- .../Observable/Observable+DeferredJust.swift | 2 +- .../Sequence/Sequence+ConcurrentMap.swift | 2 +- .../StoryboardProtocol+Extensions.swift | 2 +- .../String/String+SizeCalculation.swift | 4 ++-- .../UICollectionView+CellRegistration.swift | 2 +- .../UIDevice/UIDevice+Extensions.swift | 2 +- ...Storyboard+InstantiateViewController.swift | 11 +++++++--- .../UIView/UIView+DefaultNibName.swift | 2 +- .../UIView/UIView+LoadFromNib.swift | 15 ++++++++----- .../Extensions/UIView/UIView+Rotation.swift | 2 +- ...ntroller+DefaultStoryboardIdentifier.swift | 2 +- .../UserDefaults+MappableDataTypes.swift | 2 +- .../Protocols/ConfigurableController.swift | 2 +- LeadKit/LeadKit/Protocols/CursorType.swift | 2 +- .../EstimatedViewHeightProtocol.swift | 2 +- .../Protocols/ReuseIdentifierProtocol.swift | 2 +- .../Protocols/StoryboardProtocol.swift | 4 ++-- .../Protocols/ViewHeightProtocol.swift | 2 +- .../MappableUserDefaultsTests.swift | 8 +++---- LeadKit/LeadKitTests/Models/Post.swift | 4 ++-- LeadKit/Podfile.lock | 8 +++---- 35 files changed, 81 insertions(+), 59 deletions(-) diff --git a/LeadKit/.swiftlint.yml b/LeadKit/.swiftlint.yml index f099c37b..307a6eac 100644 --- a/LeadKit/.swiftlint.yml +++ b/LeadKit/.swiftlint.yml @@ -1,8 +1,21 @@ disabled_rules: - - force_cast - - trailing_whitespace + - variable_name excluded: - Carthage - Pods - - RxAlamofire -line_length: 128 \ No newline at end of file +line_length: 128 +type_body_length: + - 500 # warning + - 700 # error +file_length: + warning: 500 + error: 1200 +warning_threshold: 1 + +custom_rules: + uiwebview_disabled: + included: ".*.swift" + name: "UIWebView Usage Disabled" + regex: "(UIWebView)" + message: "Do not use UIWebView. Use WKWebView Instead. https://developer.apple.com/reference/uikit/uiwebview" + severity: error \ No newline at end of file diff --git a/LeadKit/LeadKit/Classes/Cursors/FixedPageCursor.swift b/LeadKit/LeadKit/Classes/Cursors/FixedPageCursor.swift index a771d303..ca64e3de 100644 --- a/LeadKit/LeadKit/Classes/Cursors/FixedPageCursor.swift +++ b/LeadKit/LeadKit/Classes/Cursors/FixedPageCursor.swift @@ -70,5 +70,5 @@ public class FixedPageCursor: CursorType where Cursor.LoadRe .flatMap { _ in self.loadNextBatch() } } } - + } diff --git a/LeadKit/LeadKit/Classes/Cursors/MapCursor.swift b/LeadKit/LeadKit/Classes/Cursors/MapCursor.swift index 9b029dc5..4a994c0c 100644 --- a/LeadKit/LeadKit/Classes/Cursors/MapCursor.swift +++ b/LeadKit/LeadKit/Classes/Cursors/MapCursor.swift @@ -79,5 +79,5 @@ public class MapCursor: CursorType where Cursor.LoadResul return startIndex..: CursorType { return Observable.just(0.. { var loadedElements: [Self.Element] { return self[0.. { @@ -43,5 +43,5 @@ public extension CursorType where LoadResultType == CountableClosedRange { var loadedElements: [Self.Element] { return self[0...count - 1] } - + } diff --git a/LeadKit/LeadKit/Extensions/IndexPath/IndexPath+ImmutableIndexPath.swift b/LeadKit/LeadKit/Extensions/IndexPath/IndexPath+ImmutableIndexPath.swift index 50d10276..8ac3ed5f 100644 --- a/LeadKit/LeadKit/Extensions/IndexPath/IndexPath+ImmutableIndexPath.swift +++ b/LeadKit/LeadKit/Extensions/IndexPath/IndexPath+ImmutableIndexPath.swift @@ -30,8 +30,8 @@ extension IndexPath { if Mirror(reflecting: self).subjectType == IndexPath.self { // check for UIMutableIndexPath return self } - + return IndexPath(item: item, section: section) } - + } diff --git a/LeadKit/LeadKit/Extensions/Observable/Observable+DeferredJust.swift b/LeadKit/LeadKit/Extensions/Observable/Observable+DeferredJust.swift index f13394d0..bad94a18 100644 --- a/LeadKit/LeadKit/Extensions/Observable/Observable+DeferredJust.swift +++ b/LeadKit/LeadKit/Extensions/Observable/Observable+DeferredJust.swift @@ -41,5 +41,5 @@ public extension Observable { return Disposables.create() } } - + } diff --git a/LeadKit/LeadKit/Extensions/Sequence/Sequence+ConcurrentMap.swift b/LeadKit/LeadKit/Extensions/Sequence/Sequence+ConcurrentMap.swift index a8319339..6d41ed36 100644 --- a/LeadKit/LeadKit/Extensions/Sequence/Sequence+ConcurrentMap.swift +++ b/LeadKit/LeadKit/Extensions/Sequence/Sequence+ConcurrentMap.swift @@ -61,5 +61,5 @@ public extension Sequence { .toArray() .map { $0.sorted { $0.0.idx < $0.1.idx }.flatMap { $0.results } } } - + } diff --git a/LeadKit/LeadKit/Extensions/StoryboardProtocol/StoryboardProtocol+Extensions.swift b/LeadKit/LeadKit/Extensions/StoryboardProtocol/StoryboardProtocol+Extensions.swift index 9ad94d40..523e664d 100644 --- a/LeadKit/LeadKit/Extensions/StoryboardProtocol/StoryboardProtocol+Extensions.swift +++ b/LeadKit/LeadKit/Extensions/StoryboardProtocol/StoryboardProtocol+Extensions.swift @@ -43,5 +43,5 @@ ViewControllerIdentifier: RawRepresentable, ViewControllerIdentifier.RawValue == public static func instantiateViewController(_ viewController: ViewControllerIdentifier) -> UIViewController { return uiStoryboard.instantiateViewController(withIdentifier: viewController.rawValue) } - + } diff --git a/LeadKit/LeadKit/Extensions/String/String+SizeCalculation.swift b/LeadKit/LeadKit/Extensions/String/String+SizeCalculation.swift index 7e2e629e..5e197d88 100644 --- a/LeadKit/LeadKit/Extensions/String/String+SizeCalculation.swift +++ b/LeadKit/LeadKit/Extensions/String/String+SizeCalculation.swift @@ -75,8 +75,8 @@ public extension String { context: nil).size let fontLineHeight = (attributes?[NSFontAttributeName] as? UIFont)?.lineHeight - + return StringSizeCalculationResult(size: size, fontLineHeight: fontLineHeight) } - + } diff --git a/LeadKit/LeadKit/Extensions/UICollectionView/UICollectionView+CellRegistration.swift b/LeadKit/LeadKit/Extensions/UICollectionView/UICollectionView+CellRegistration.swift index 391d52cb..47b3b4dd 100644 --- a/LeadKit/LeadKit/Extensions/UICollectionView/UICollectionView+CellRegistration.swift +++ b/LeadKit/LeadKit/Extensions/UICollectionView/UICollectionView+CellRegistration.swift @@ -53,7 +53,7 @@ public extension UICollectionView { public func registerNib(forCellClass cellClass: T.Type, forUserInterfaceIdiom interfaceIdiom: UIUserInterfaceIdiom) where T: ReuseIdentifierProtocol, T: UICollectionViewCell, T: NibNameProtocol { - + let nib = UINib(nibName: T.nibName(forConfiguration: interfaceIdiom)) register(nib, forCellWithReuseIdentifier: T.reuseIdentifier) } diff --git a/LeadKit/LeadKit/Extensions/UIDevice/UIDevice+Extensions.swift b/LeadKit/LeadKit/Extensions/UIDevice/UIDevice+Extensions.swift index 36b2379e..15e762ef 100644 --- a/LeadKit/LeadKit/Extensions/UIDevice/UIDevice+Extensions.swift +++ b/LeadKit/LeadKit/Extensions/UIDevice/UIDevice+Extensions.swift @@ -28,5 +28,5 @@ public extension UIDevice { public static var isSimulator: Bool { return ProcessInfo.processInfo.environment["SIMULATOR_DEVICE_NAME"] != nil } - + } diff --git a/LeadKit/LeadKit/Extensions/UIStoryboard/UIStoryboard+InstantiateViewController.swift b/LeadKit/LeadKit/Extensions/UIStoryboard/UIStoryboard+InstantiateViewController.swift index 52be7efb..f3c95728 100644 --- a/LeadKit/LeadKit/Extensions/UIStoryboard/UIStoryboard+InstantiateViewController.swift +++ b/LeadKit/LeadKit/Extensions/UIStoryboard/UIStoryboard+InstantiateViewController.swift @@ -29,9 +29,14 @@ extension UIStoryboard { - returns: UIViewController subclass instance */ - + public func instantiateViewController() -> T where T: UIViewController, T: StoryboardIdentifierProtocol { - return self.instantiateViewController(withIdentifier: T.storyboardIdentifier) as! T + guard let viewController = self.instantiateViewController(withIdentifier: T.storyboardIdentifier) as? T else { + + fatalError("Can't instantiate view controller with type \(T.self)") + } + + return viewController } - + } diff --git a/LeadKit/LeadKit/Extensions/UIView/UIView+DefaultNibName.swift b/LeadKit/LeadKit/Extensions/UIView/UIView+DefaultNibName.swift index 9371d85e..11a7c61f 100644 --- a/LeadKit/LeadKit/Extensions/UIView/UIView+DefaultNibName.swift +++ b/LeadKit/LeadKit/Extensions/UIView/UIView+DefaultNibName.swift @@ -32,5 +32,5 @@ extension UIView: StaticNibNameProtocol { open class var nibName: String { return className(of: self) } - + } diff --git a/LeadKit/LeadKit/Extensions/UIView/UIView+LoadFromNib.swift b/LeadKit/LeadKit/Extensions/UIView/UIView+LoadFromNib.swift index f31f32ab..fcfed6c5 100644 --- a/LeadKit/LeadKit/Extensions/UIView/UIView+LoadFromNib.swift +++ b/LeadKit/LeadKit/Extensions/UIView/UIView+LoadFromNib.swift @@ -36,12 +36,12 @@ public extension UIView { - returns: UIView subclass instance */ - + public static func loadFromNib (forUserInterfaceIdiom interfaceIdiom: UIUserInterfaceIdiom) -> T where T: NibNameProtocol, T: UIView { return loadFromNib(named: T.nibName(forConfiguration: interfaceIdiom)) } - + /** method which return UIView subclass instance loaded from nib using nib name provided by StaticNibNameProtocol implementation @@ -51,7 +51,7 @@ public extension UIView { public static func loadFromNib() -> T where T: StaticNibNameProtocol, T: UIView { return loadFromNib(named: T.nibName) } - + /** method which loads UIView (or subclass) instance from nib using given nib name parameter @@ -60,7 +60,12 @@ public extension UIView { - returns: UIView subclass instance */ public static func loadFromNib(named nibName: String) -> T { - return UINib(nibName: nibName).instantiate(withOwner: nil, options: nil).first as! T + guard let nibView = UINib(nibName: nibName).instantiate(withOwner: nil, options: nil).first as? T else { + fatalError("Can't nstantiate nib view with type \(T.self)") + } + + return nibView + } - + } diff --git a/LeadKit/LeadKit/Extensions/UIView/UIView+Rotation.swift b/LeadKit/LeadKit/Extensions/UIView/UIView+Rotation.swift index a404101b..a1c9c283 100644 --- a/LeadKit/LeadKit/Extensions/UIView/UIView+Rotation.swift +++ b/LeadKit/LeadKit/Extensions/UIView/UIView+Rotation.swift @@ -47,5 +47,5 @@ extension UIView { public func stopZRotation() { layer.removeAnimation(forKey: UIView.rotationKeyPath) } - + } diff --git a/LeadKit/LeadKit/Extensions/UIViewController/UIViewController+DefaultStoryboardIdentifier.swift b/LeadKit/LeadKit/Extensions/UIViewController/UIViewController+DefaultStoryboardIdentifier.swift index 0d8ad90f..5bcc3d57 100644 --- a/LeadKit/LeadKit/Extensions/UIViewController/UIViewController+DefaultStoryboardIdentifier.swift +++ b/LeadKit/LeadKit/Extensions/UIViewController/UIViewController+DefaultStoryboardIdentifier.swift @@ -32,5 +32,5 @@ extension UIViewController: StoryboardIdentifierProtocol { open class var storyboardIdentifier: String { return className(of: self) } - + } diff --git a/LeadKit/LeadKit/Extensions/UserDefaults/UserDefaults+MappableDataTypes.swift b/LeadKit/LeadKit/Extensions/UserDefaults/UserDefaults+MappableDataTypes.swift index 27b0d472..e2a92879 100644 --- a/LeadKit/LeadKit/Extensions/UserDefaults/UserDefaults+MappableDataTypes.swift +++ b/LeadKit/LeadKit/Extensions/UserDefaults/UserDefaults+MappableDataTypes.swift @@ -33,7 +33,7 @@ public enum UserDefaultsError: Error { case noSuchValue(key: String) case unableToMap(mappingError: Error) - + } fileprivate typealias JSONObject = [String: Any] diff --git a/LeadKit/LeadKit/Protocols/ConfigurableController.swift b/LeadKit/LeadKit/Protocols/ConfigurableController.swift index be6885a3..f7389523 100644 --- a/LeadKit/LeadKit/Protocols/ConfigurableController.swift +++ b/LeadKit/LeadKit/Protocols/ConfigurableController.swift @@ -72,5 +72,5 @@ extension ConfigurableController where Self: UIViewController { localize() bindViews() } - + } diff --git a/LeadKit/LeadKit/Protocols/CursorType.swift b/LeadKit/LeadKit/Protocols/CursorType.swift index 92665cf0..554ebfc8 100644 --- a/LeadKit/LeadKit/Protocols/CursorType.swift +++ b/LeadKit/LeadKit/Protocols/CursorType.swift @@ -41,5 +41,5 @@ public protocol CursorType { /// /// - Returns: Observable of LoadResultType func loadNextBatch() -> Observable - + } diff --git a/LeadKit/LeadKit/Protocols/EstimatedViewHeightProtocol.swift b/LeadKit/LeadKit/Protocols/EstimatedViewHeightProtocol.swift index 066bd054..a09dda1e 100644 --- a/LeadKit/LeadKit/Protocols/EstimatedViewHeightProtocol.swift +++ b/LeadKit/LeadKit/Protocols/EstimatedViewHeightProtocol.swift @@ -27,7 +27,7 @@ import Foundation */ public protocol EstimatedViewHeightProtocol { associatedtype ViewModelType - + /** method which returns estimated view height for specific view model diff --git a/LeadKit/LeadKit/Protocols/ReuseIdentifierProtocol.swift b/LeadKit/LeadKit/Protocols/ReuseIdentifierProtocol.swift index dddc7287..7e11eee9 100644 --- a/LeadKit/LeadKit/Protocols/ReuseIdentifierProtocol.swift +++ b/LeadKit/LeadKit/Protocols/ReuseIdentifierProtocol.swift @@ -27,7 +27,7 @@ import Foundation */ public protocol AbstractReuseIdentifierProtocol { associatedtype IdentifierType - + /** - returns: reuse identifier with protocol associated type */ diff --git a/LeadKit/LeadKit/Protocols/StoryboardProtocol.swift b/LeadKit/LeadKit/Protocols/StoryboardProtocol.swift index 3fe4507c..a7f3e754 100644 --- a/LeadKit/LeadKit/Protocols/StoryboardProtocol.swift +++ b/LeadKit/LeadKit/Protocols/StoryboardProtocol.swift @@ -48,7 +48,7 @@ public protocol StoryboardProtocol { - returns: UIViewController instance */ static func instantiateViewController(_: ViewControllerIdentifier) -> UIViewController - + } public extension StoryboardProtocol { @@ -60,5 +60,5 @@ public extension StoryboardProtocol { } return controller } - + } diff --git a/LeadKit/LeadKit/Protocols/ViewHeightProtocol.swift b/LeadKit/LeadKit/Protocols/ViewHeightProtocol.swift index ab645249..3c29c7bc 100644 --- a/LeadKit/LeadKit/Protocols/ViewHeightProtocol.swift +++ b/LeadKit/LeadKit/Protocols/ViewHeightProtocol.swift @@ -27,7 +27,7 @@ import Foundation */ public protocol ViewHeightProtocol { associatedtype ViewModelType - + /** method which returns view height for specific view model diff --git a/LeadKit/LeadKitTests/MappableUserDefaultsTests.swift b/LeadKit/LeadKitTests/MappableUserDefaultsTests.swift index f4a65d61..f44a84c4 100644 --- a/LeadKit/LeadKitTests/MappableUserDefaultsTests.swift +++ b/LeadKit/LeadKitTests/MappableUserDefaultsTests.swift @@ -29,18 +29,18 @@ class MappableUserDefaultsTests: XCTestCase { static let postsKey = "posts" let disposeBag = DisposeBag() - + override func setUp() { super.setUp() } - + override func tearDown() { userDefaults.set(nil, forKey: MappableUserDefaultsTests.postKey) userDefaults.set(nil, forKey: MappableUserDefaultsTests.postsKey) super.tearDown() } - + func testPostSave() { userDefaults.set(model: post, forKey: MappableUserDefaultsTests.postKey) @@ -90,5 +90,5 @@ class MappableUserDefaultsTests: XCTestCase { }) .addDisposableTo(disposeBag) } - + } diff --git a/LeadKit/LeadKitTests/Models/Post.swift b/LeadKit/LeadKitTests/Models/Post.swift index d2528717..263b7abd 100644 --- a/LeadKit/LeadKitTests/Models/Post.swift +++ b/LeadKit/LeadKitTests/Models/Post.swift @@ -49,7 +49,7 @@ struct Post: ImmutableMappable { title >>> map["title"] body >>> map["body"] } - + } extension Post: Equatable { @@ -60,5 +60,5 @@ extension Post: Equatable { lhs.title == rhs.title && lhs.body == rhs.body } - + } diff --git a/LeadKit/Podfile.lock b/LeadKit/Podfile.lock index 143a6c52..08d7051a 100644 --- a/LeadKit/Podfile.lock +++ b/LeadKit/Podfile.lock @@ -1,5 +1,5 @@ PODS: - - Alamofire (4.3.0) + - Alamofire (4.4.0) - CocoaLumberjack/Core (3.0.0) - CocoaLumberjack/Default (3.0.0): - CocoaLumberjack/Core @@ -7,7 +7,7 @@ PODS: - CocoaLumberjack/Default - CocoaLumberjack/Swift (3.0.0): - CocoaLumberjack/Extensions - - ObjectMapper (2.2.3) + - ObjectMapper (2.2.5) - RxAlamofire (3.0.0): - RxAlamofire/Core (= 3.0.0) - RxAlamofire/Core (3.0.0): @@ -27,9 +27,9 @@ DEPENDENCIES: - Toast-Swift (~> 2.0.0) SPEC CHECKSUMS: - Alamofire: 856a113053a7bc9cbe5d6367a555d773fc5cfef7 + Alamofire: dc44b1600b800eb63da6a19039a0083d62a6a62d CocoaLumberjack: c823149bccc5519a9447aeb433be7b1212a7d6a5 - ObjectMapper: d3b3de11267f5d971f390eb8d63dd509116a4329 + ObjectMapper: fb30f71e08470d1e5a20b199fafe1246281db898 RxAlamofire: 0b1fa48f545fffe7f7a28af2086bcaa3b5946cc9 RxCocoa: ccdf43101a70407097a29082f648ba1676075b30 RxSwift: 46574f70d416b7923c237195939cc488a7fbf3a0