refactor: update swiftlint to 39.1

This commit is contained in:
Vlad 2021-01-11 23:26:23 +03:00
parent 7ffac03d73
commit 5afbc2ffa5
106 changed files with 318 additions and 322 deletions

View File

@ -2296,7 +2296,7 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0830;
LastUpgradeCheck = 1020;
LastUpgradeCheck = 1230;
ORGANIZATIONNAME = "Touch Instinct";
TargetAttributes = {
67186B271EB248F100CFAFFB = {
@ -3224,6 +3224,7 @@
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
@ -3283,6 +3284,7 @@
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1020"
LastUpgradeVersion = "1230"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
@ -27,6 +27,15 @@
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "67186B271EB248F100CFAFFB"
BuildableName = "LeadKit.framework"
BlueprintName = "LeadKit iOS"
ReferencedContainer = "container:LeadKit.xcodeproj">
</BuildableReference>
</MacroExpansion>
<Testables>
<TestableReference
skipped = "NO">
@ -39,17 +48,6 @@
</BuildableReference>
</TestableReference>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "67186B271EB248F100CFAFFB"
BuildableName = "LeadKit.framework"
BlueprintName = "LeadKit iOS"
ReferencedContainer = "container:LeadKit.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
@ -70,8 +68,6 @@
ReferencedContainer = "container:LeadKit.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1020"
LastUpgradeVersion = "1230"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
@ -27,6 +27,15 @@
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "6782BB9F1EB31D590086E0B8"
BuildableName = "LeadKit.framework"
BlueprintName = "LeadKit tvOS"
ReferencedContainer = "container:LeadKit.xcodeproj">
</BuildableReference>
</MacroExpansion>
<Testables>
<TestableReference
skipped = "NO">
@ -39,17 +48,6 @@
</BuildableReference>
</TestableReference>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "6782BB9F1EB31D590086E0B8"
BuildableName = "LeadKit.framework"
BlueprintName = "LeadKit tvOS"
ReferencedContainer = "container:LeadKit.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
@ -70,8 +68,6 @@
ReferencedContainer = "container:LeadKit.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"

View File

@ -26,11 +26,11 @@ import UIKit
open class BaseCollectionContentController<ViewModel>: BaseScrollContentController<ViewModel, CollectionViewWrapperView> {
override open func createView() -> CollectionViewWrapperView {
return CollectionViewWrapperView(layout: UICollectionViewFlowLayout())
CollectionViewWrapperView(layout: UICollectionViewFlowLayout())
}
/// Contained UICollectionView instance.
public var collectionView: UICollectionView {
return customView.collectionView
customView.collectionView
}
}

View File

@ -49,6 +49,6 @@ open class BaseCustomViewController<ViewModel, View: UIView>: BaseConfigurableCo
///
/// - Returns: Initialized custom view.
open func createView() -> View {
return View()
View()
}
}

View File

@ -25,6 +25,6 @@ open class BaseOrientationController: UIViewController {
}
open override var preferredInterfaceOrientationForPresentation: UIInterfaceOrientation {
return forcedInterfaceOrientation ?? super.preferredInterfaceOrientationForPresentation
forcedInterfaceOrientation ?? super.preferredInterfaceOrientationForPresentation
}
}

View File

@ -49,13 +49,13 @@ open class BaseScrollContentController<ViewModel, View: ScrollViewHolderView>: B
/// Contained UIScrollView instance.
public var scrollView: UIScrollView {
return customView.scrollView
customView.scrollView
}
/// Default insets used for contained scroll view.
public var defaultInsets: UIEdgeInsets {
get {
return defaultInsetsRelay.value
defaultInsetsRelay.value
}
set {
defaultInsetsRelay.accept(newValue)

View File

@ -32,11 +32,11 @@ open class BaseTableContentController<ViewModel>: BaseScrollContentController<Vi
///
/// - Returns: Initialized TableDirector.
open func createTableDirector() -> TableDirector {
return TableDirector(tableView: tableView)
TableDirector(tableView: tableView)
}
override open func createView() -> TableViewWrapperView {
return TableViewWrapperView(tableViewStyle: .plain)
TableViewWrapperView(tableViewStyle: .plain)
}
override open func configureAppearance() {
@ -47,6 +47,6 @@ open class BaseTableContentController<ViewModel>: BaseScrollContentController<Vi
/// Contained UITableView instance.
public var tableView: UITableView {
return customView.tableView
customView.tableView
}
}

View File

@ -42,17 +42,17 @@ public class FixedPageCursor<Cursor: CursorType>: CursorType, RxDataSource {
}
public var exhausted: Bool {
return cursor.exhausted && cursor.count == count
cursor.exhausted && cursor.count == count
}
public private(set) var count: Int = 0
public subscript(index: Int) -> Cursor.Element {
return cursor[index]
cursor[index]
}
public func loadNextBatch() -> Single<[Cursor.Element]> {
return Single.deferred {
Single.deferred {
if self.exhausted {
return .error(CursorError.exhausted)
}

View File

@ -29,7 +29,7 @@ public extension CursorType {
/// - Parameter transform: closure to transform elements
/// - Returns: new MapCursor instance
func flatMap<T>(transform: @escaping MapCursor<Self, T>.Transform) -> MapCursor<Self, T> {
return MapCursor(cursor: self, transform: transform)
MapCursor(cursor: self, transform: transform)
}
/// Creates ResettableMapCursor with current cursor
@ -39,7 +39,7 @@ public extension CursorType {
func flatMap<T>(transform: @escaping ResettableMapCursor<Self, T>.Transform)
-> ResettableMapCursor<Self, T> where Self: ResettableCursorType {
return ResettableMapCursor(cursor: self, transform: transform)
ResettableMapCursor(cursor: self, transform: transform)
}
}
@ -67,19 +67,19 @@ public class MapCursor<Cursor: CursorType, T>: CursorType, RxDataSource {
}
public var exhausted: Bool {
return cursor.exhausted
cursor.exhausted
}
public var count: Int {
return elements.count
elements.count
}
public subscript(index: Int) -> T {
return elements[index]
elements[index]
}
public func loadNextBatch() -> Single<[T]> {
return cursor.loadNextBatch().map { newItems in
cursor.loadNextBatch().map { newItems in
let transformedNewItems = newItems.compactMap(self.transform)
self.elements += transformedNewItems

View File

@ -37,7 +37,7 @@ public final class SingleLoadCursorConfiguration<Element>: TotalCountCursorConfi
}
public func resultSingle() -> Single<ResultType> {
return loadingSingle
loadingSingle
}
public init(resetFrom other: SingleLoadCursorConfiguration) {
@ -67,15 +67,15 @@ public class SingleLoadCursor<Element>: ResettableCursorType {
public private(set) var exhausted = false
public var count: Int {
return content.count
content.count
}
public subscript(index: Int) -> Element {
return content[index]
content[index]
}
public func loadNextBatch() -> Single<[Element]> {
return Single.deferred {
Single.deferred {
if self.exhausted {
return .error(CursorError.exhausted)
}

View File

@ -45,11 +45,11 @@ public class StaticCursor<Element>: ResettableRxDataSourceCursor {
public private(set) var count = 0
public subscript(index: Int) -> Element {
return content[index]
content[index]
}
public func loadNextBatch() -> Single<[Element]> {
return Single.deferred {
Single.deferred {
if self.exhausted {
return .error(CursorError.exhausted)
}

View File

@ -35,15 +35,15 @@ open class TotalCountCursor<CursorConfiguration: TotalCountCursorConfiguration>:
public private(set) var totalCount: Int = .max
public var exhausted: Bool {
return count >= totalCount
count >= totalCount
}
public var count: Int {
return elements.count
elements.count
}
public subscript(index: Int) -> Element {
return elements[index]
elements[index]
}
public init(configuration: CursorConfiguration) {
@ -55,11 +55,11 @@ open class TotalCountCursor<CursorConfiguration: TotalCountCursorConfiguration>:
}
open func processResultFromConfigurationSingle() -> Single<CursorConfiguration.ResultType> {
return configuration.resultSingle()
configuration.resultSingle()
}
public func loadNextBatch() -> Single<[Element]> {
return processResultFromConfigurationSingle()
processResultFromConfigurationSingle()
.do(onSuccess: { [weak self] listingResult in
self?.totalCount = listingResult.totalCount
self?.elements = (self?.elements ?? []) + listingResult.results

View File

@ -63,28 +63,28 @@ open class GeneralDataLoadingViewModel<ResultType>: BaseViewModel, GeneralDataLo
/// Returns observable that emits current loading state.
open var loadingStateObservable: Observable<LoadingState> {
return loadingStateRelay.asObservable()
loadingStateRelay.asObservable()
}
/// Returns driver that emits current loading state.
open var loadingStateDriver: Driver<LoadingState> {
return loadingStateRelay.asDriver()
loadingStateRelay.asDriver()
}
/// By default returns true if loading state == .result.
open var hasContent: Bool {
return currentLoadingState.hasResult
currentLoadingState.hasResult
}
/// Returns current result if it exists.
public var currentResult: ResultType? {
return currentLoadingState.result
currentLoadingState.result
}
/// Current state of loading process.
private(set) public var currentLoadingState: LoadingState {
get {
return loadingStateRelay.value
loadingStateRelay.value
}
set {
loadingStateRelay.accept(newValue)

View File

@ -22,9 +22,11 @@
import RxSwift
public typealias RxPaginationDataLoadingModel<Cursor: ResettableRxDataSourceCursor> =
RxDataLoadingModel<PaginationDataLoadingState<Cursor>>
/// Data loading model for PaginationDataLoadingState with ResettableRxDataSourceCursor as data source.
public final class PaginationDataLoadingModel<Cursor: ResettableRxDataSourceCursor>:
RxDataLoadingModel<PaginationDataLoadingState<Cursor>> {
public final class PaginationDataLoadingModel<Cursor: ResettableRxDataSourceCursor>: RxPaginationDataLoadingModel<Cursor> {
private enum LoadType {

View File

@ -43,7 +43,7 @@ final public class PaginationWrapper<Cursor: ResettableRxDataSourceCursor, Deleg
/// so the handler can be triggered before reaching end. Defaults to 0.0;
public var infiniteScrollTriggerOffset: CGFloat {
get {
return wrappedView.scrollView.infiniteScrollTriggerOffset
wrappedView.scrollView.infiniteScrollTriggerOffset
}
set {
wrappedView.scrollView.infiniteScrollTriggerOffset = newValue
@ -327,7 +327,7 @@ final public class PaginationWrapper<Cursor: ResettableRxDataSourceCursor, Deleg
private extension PaginationWrapper {
private var stateChanged: Binder<LoadingState> {
return Binder(self) { base, value in
Binder(self) { base, value in
switch value {
case .initial:
base.onInitialState()
@ -354,7 +354,7 @@ private extension PaginationWrapper {
}
var scrollOffsetChanged: Binder<CGPoint> {
return Binder(self) { base, value in
Binder(self) { base, value in
base.currentPlaceholderViewTopConstraint?.constant = -value.y
}
}

View File

@ -39,7 +39,7 @@ open class RxNetworkOperationModel<LoadingStateType: NetworkOperationState>: Net
private let errorHandler: ErrorHandler
open var stateDriver: Driver<LoadingStateType> {
return stateRelay.asDriver()
stateRelay.asDriver()
}
/// Model initializer with data source and custom error handler.
@ -91,7 +91,7 @@ open class RxNetworkOperationModel<LoadingStateType: NetworkOperationState>: Net
var state: LoadingStateType {
get {
return stateRelay.value
stateRelay.value
}
set {
stateRelay.accept(newValue)

View File

@ -114,11 +114,11 @@ where ViewModel: BaseSearchViewModel<Item, ItemViewModel> {
}
open var searchBarPlaceholder: String {
return ""
""
}
open var searchBarColor: UIColor {
return .gray
.gray
}
open var statusBarView: UIView {
@ -133,7 +133,7 @@ where ViewModel: BaseSearchViewModel<Item, ItemViewModel> {
}
open var statusBarColor: UIColor {
return .black
.black
}
open func updateContent(with viewModels: [ItemViewModel]) {
@ -146,16 +146,16 @@ where ViewModel: BaseSearchViewModel<Item, ItemViewModel> {
}
open var resetResults: Observable<SearchResultsViewControllerState> {
return searchController.rx.willPresent
searchController.rx.willPresent
.map { SearchResultsViewControllerState.initial }
}
open var searchResults: Observable<SearchResultsViewControllerState> {
return viewModel.searchResultsDriver
viewModel.searchResultsDriver
.asObservable()
.withUnretained(self)
.map { owner, viewModels -> SearchResultsViewControllerState in
owner.stateForUpdate(with: viewModels) ?? .rowsContent(rows: [])
owner.stateForUpdate(with: viewModels)
}
}

View File

@ -35,7 +35,7 @@ open class BaseSearchViewModel<Item, ItemViewModel>: GeneralDataLoadingViewModel
}
open var itemsViewModelsDriver: Driver<[ItemViewModel]> {
return loadingResultObservable
loadingResultObservable
.withUnretained(self)
.map { owner, items in
owner.viewModels(from: items)
@ -46,11 +46,11 @@ open class BaseSearchViewModel<Item, ItemViewModel>: GeneralDataLoadingViewModel
}
open var searchDebounceInterval: RxTimeInterval {
return .seconds(1)
.seconds(1)
}
open var searchResultsDriver: Driver<[ItemViewModel]> {
return searchTextRelay.debounce(searchDebounceInterval, scheduler: MainScheduler.instance)
searchTextRelay.debounce(searchDebounceInterval, scheduler: MainScheduler.instance)
.withLatestFrom(loadingResultObservable) { ($0, $1) }
.flatMapLatest { [weak self] searchText, items -> Observable<ItemsList> in
self?.search(by: searchText, from: items).asObservable() ?? .empty()
@ -73,29 +73,29 @@ open class BaseSearchViewModel<Item, ItemViewModel>: GeneralDataLoadingViewModel
}
open func bind(searchText: Observable<String>) -> Disposable {
return searchText.bind(to: searchTextRelay)
searchText.bind(to: searchTextRelay)
}
private func viewModels(from items: ItemsList) -> [ItemViewModel] {
return items.map { self.viewModel(from: $0) }
items.map { self.viewModel(from: $0) }
}
open var loadingResultObservable: Observable<ResultType> {
return loadingStateDriver
loadingStateDriver
.asObservable()
.map { $0.result }
.flatMap { Observable.from(optional: $0) }
}
open var loadingErrorObservable: Observable<Error> {
return loadingStateDriver
loadingStateDriver
.asObservable()
.map { $0.error }
.flatMap { Observable.from(optional: $0) }
}
open var firstLoadingResultObservable: Single<ResultType> {
return loadingResultObservable
loadingResultObservable
.take(1)
.asSingle()
}

View File

@ -39,7 +39,7 @@ open class NetworkService {
/// Driver that emits true when active requests count != 0 and false otherwise.
public var isActivityIndicatorVisibleDriver: Driver<Bool> {
return requestCountRelay.asDriver().map { $0 != 0 }.distinctUntilChanged()
requestCountRelay.asDriver().map { $0 != 0 }.distinctUntilChanged()
}
/// - Parameter sessionManager: Alamofire.SessionManager to use for requests
@ -63,12 +63,12 @@ open class NetworkService {
public func rxObservableRequest<T: ObservableMappable>(with parameters: ApiRequestParameters,
additionalValidStatusCodes: Set<Int> = [],
decoder: JSONDecoder = JSONDecoder())
-> Observable<SessionManager.ModelResponse<T>> {
-> Observable<SessionManager.ModelResponse<T>> {
return sessionManager.rx.responseObservableModel(requestParameters: parameters,
additionalValidStatusCodes: additionalValidStatusCodes,
decoder: decoder)
.counterTracking(for: self)
sessionManager.rx.responseObservableModel(requestParameters: parameters,
additionalValidStatusCodes: additionalValidStatusCodes,
decoder: decoder)
.counterTracking(for: self)
}
/// Perform reactive request to get mapped ImmutableMappable model and http response
@ -81,12 +81,12 @@ open class NetworkService {
public func rxRequest<T: Decodable>(with parameters: ApiRequestParameters,
additionalValidStatusCodes: Set<Int> = [],
decoder: JSONDecoder = JSONDecoder())
-> Observable<SessionManager.ModelResponse<T>> {
-> Observable<SessionManager.ModelResponse<T>> {
return sessionManager.rx.responseModel(requestParameters: parameters,
additionalValidStatusCodes: additionalValidStatusCodes,
decoder: decoder)
.counterTracking(for: self)
sessionManager.rx.responseModel(requestParameters: parameters,
additionalValidStatusCodes: additionalValidStatusCodes,
decoder: decoder)
.counterTracking(for: self)
}
/// Perform reactive request to get data and http response
@ -96,11 +96,11 @@ open class NetworkService {
/// - additionalValidStatusCodes: set of additional valid status codes
/// - Returns: Observable of tuple containing (HTTPURLResponse, Data)
public func rxDataRequest(with parameters: ApiRequestParameters, additionalValidStatusCodes: Set<Int> = [])
-> Observable<SessionManager.DataResponse> {
-> Observable<SessionManager.DataResponse> {
return sessionManager.rx.responseData(requestParameters: parameters,
additionalValidStatusCodes: additionalValidStatusCodes)
.counterTracking(for: self)
sessionManager.rx.responseData(requestParameters: parameters,
additionalValidStatusCodes: additionalValidStatusCodes)
.counterTracking(for: self)
}
/// Perform reactive request to upload data and get Observable model and http response
@ -113,12 +113,12 @@ open class NetworkService {
public func rxUploadRequest<T: Decodable>(with parameters: ApiUploadRequestParameters,
additionalValidStatusCodes: Set<Int> = [],
decoder: JSONDecoder = JSONDecoder())
-> Observable<SessionManager.ModelResponse<T>> {
-> Observable<SessionManager.ModelResponse<T>> {
return sessionManager.rx.uploadResponseModel(requestParameters: parameters,
additionalValidStatusCodes: additionalValidStatusCodes,
decoder: decoder)
.counterTracking(for: self)
sessionManager.rx.uploadResponseModel(requestParameters: parameters,
additionalValidStatusCodes: additionalValidStatusCodes,
decoder: decoder)
.counterTracking(for: self)
}
}
@ -145,7 +145,7 @@ public extension Observable {
/// - Parameter networkService: NetworkService to operate on it
/// - Returns: The source sequence with the side-effecting behavior applied.
func counterTracking(for networkService: NetworkService) -> Observable<Observable.Element> {
return `do`(onSubscribe: {
`do`(onSubscribe: {
networkService.increaseRequestCounter()
}, onDispose: {
networkService.decreaseRequestCounter()

View File

@ -62,16 +62,16 @@ public extension BasePlaceholderViewModel {
/// Returns true if description is not nil.
var hasDescription: Bool {
return description != nil
description != nil
}
/// Returns true buttonTitle is not nil.
var hasButton: Bool {
return buttonTitle != nil
buttonTitle != nil
}
/// Returns true if centerImage is not nil.
var hasCenterImage: Bool {
return centerImage != nil
centerImage != nil
}
}

View File

@ -55,7 +55,7 @@ open class BasePlaceholderView: ButtonHolderView, InitializableView {
///
/// - Returns: UIButton (sub)class.
open func createButton() -> UIButton {
return UIButton()
UIButton()
}
// MARK: - InitializableView

View File

@ -48,7 +48,7 @@ open class CustomizableButton: UIButton {
}
func backgroundColor(for state: UIControl.State) -> UIColor? {
return backgroundColors[state]
backgroundColors[state]
}
private func updateBackgroundColor() {

View File

@ -45,7 +45,7 @@ public struct CustomizableButtonState: OptionSet {
// MARK: - Properties
public var isLoading: Bool {
return contains(.loading)
contains(.loading)
}
}
@ -99,15 +99,15 @@ open class CustomizableButtonView: UIView, InitializableView, ConfigurableView {
// MARK: - Computed Properties
public var tapObservable: Observable<Void> {
return button.rx.tap.asObservable()
button.rx.tap.asObservable()
}
override open var forFirstBaselineLayout: UIView {
return button.forFirstBaselineLayout
button.forFirstBaselineLayout
}
override open var forLastBaselineLayout: UIView {
return button.forLastBaselineLayout
button.forLastBaselineLayout
}
override open func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
@ -255,7 +255,7 @@ open class CustomizableButtonView: UIView, InitializableView, ConfigurableView {
}
private var stateBinder: Binder<CustomizableButtonState> {
return Binder(self) { base, value in
Binder(self) { base, value in
base.configureButton(withState: value)
base.onStateChange(value)
}

View File

@ -39,15 +39,15 @@ open class CustomizableButtonViewModel {
}
open var stateDriver: Driver<CustomizableButtonState> {
return stateRelay.asDriver()
stateRelay.asDriver()
}
func bind(tapObservable: Observable<Void>) -> Disposable {
return tapObservable.bind(to: tapRelay)
tapObservable.bind(to: tapRelay)
}
public var tapDriver: Driver<Void> {
return tapRelay.asDriver()
tapRelay.asDriver()
}
public func updateState(with newState: CustomizableButtonState) {

View File

@ -48,6 +48,6 @@ public final class EmptyCellRow: TableRow<EmptyCell> {
/// Used for set custom height to each cell, not for each cell type
override public var defaultHeight: CGFloat? {
return rowHeight
rowHeight
}
}

View File

@ -93,11 +93,11 @@ open class LabelTableViewCell: SeparatorCell, InitializableView, ConfigurableCel
// MARK: - Private
private var labelInsets: UIEdgeInsets {
return viewModel?.labelInsets ?? .zero
viewModel?.labelInsets ?? .zero
}
private var contentInsets: UIEdgeInsets {
return viewModel?.contentInsets ?? .zero
viewModel?.contentInsets ?? .zero
}
// MARK: - Subclass methods to override

View File

@ -25,7 +25,7 @@ import UIKit
public final class SpinnerView: UIView, Animatable, LoadingIndicator {
private var animating: Bool {
return imageView?.layer.animation(forKey: CABasicAnimation.rotationKeyPath) != nil
imageView?.layer.animation(forKey: CABasicAnimation.rotationKeyPath) != nil
}
private var startTime = CFTimeInterval(0)

View File

@ -57,7 +57,7 @@ public final class DataModelFieldBinding<T> {
/// - Parameter textDriver: Driver that emits new text values.
/// - Returns: Disposable object that can be used to unsubscribe the observer from the behaviour relay.
public func mergeStringToModel(from textDriver: Driver<String?>) -> Disposable {
return textDriver.map { [modelRelay, mergeFieldClosure] in
textDriver.map { [modelRelay, mergeFieldClosure] in
mergeFieldClosure(modelRelay.value, $0)
}
.drive(modelRelay)
@ -65,7 +65,7 @@ public final class DataModelFieldBinding<T> {
/// A Driver that will emit current field value.
public var fieldDriver: Driver<String?> {
return modelDriver.map(getFieldClosure)
modelDriver.map(getFieldClosure)
}
}
@ -111,11 +111,11 @@ public extension BehaviorRelay {
/// - Returns: DataModelFieldBinding instance.
func fieldBinding(getFieldClosure: @escaping DataModelFieldBinding<Element>.GetFieldClosure,
mergeFieldClosure: @escaping DataModelFieldBinding<Element>.MergeFieldClosure)
-> DataModelFieldBinding<Element> {
-> DataModelFieldBinding<Element> {
return DataModelFieldBinding(modelRelay: self,
getFieldClosure: getFieldClosure,
mergeFieldClosure: mergeFieldClosure)
DataModelFieldBinding(modelRelay: self,
getFieldClosure: getFieldClosure,
mergeFieldClosure: mergeFieldClosure)
}
}
@ -125,6 +125,6 @@ public extension BehaviorRelay where Element == String? {
///
/// - Returns: DataModelFieldBinding instance.
func fieldBinding() -> DataModelFieldBinding<Element> {
return DataModelFieldBinding(modelRelay: self)
DataModelFieldBinding(modelRelay: self)
}
}

View File

@ -44,7 +44,7 @@ open class TextFieldViewModel < ViewEvents: TextFieldViewEvents,
/// View events driver that will emit view events structure
/// when view will bind itself to the view model.
public var viewEventsDriver: Driver<ViewEvents> {
return viewEventsRelay
viewEventsRelay
.asDriver()
.flatMap { viewEvents -> Driver<ViewEvents> in
guard let viewEvents = viewEvents else {
@ -77,7 +77,7 @@ public extension TextFieldViewModel {
/// - Parameter closure: Closure that takes a view events parameter and returns Disposable.
/// - Returns: Disposable object that can be used to unsubscribe the observer from the binding.
func mapViewEvents(_ closure: @escaping MapViewEventClosure) -> Disposable {
return mapViewEvents { [closure($0)] }
mapViewEvents { [closure($0)] }
}
typealias MapViewEventsClosure = (ViewEvents) -> [Disposable]
@ -87,7 +87,7 @@ public extension TextFieldViewModel {
/// - Parameter closure: Closure that takes a view events parameter and returns [Disposable].
/// - Returns: Disposable object that can be used to unsubscribe the observer from the binding.
func mapViewEvents(_ closure: @escaping MapViewEventsClosure) -> Disposable {
return viewEventsDriver
viewEventsDriver
.map { [weak self] in
guard let strongSelf = self else {
return

View File

@ -28,7 +28,7 @@ open class XibView: UIView {
/// Nib name used to instantiate inner view
/// - NOTE: Be very carefully when you're intending to change this line
open var innerViewNibName: String {
return typeName(of: type(of: self))
typeName(of: type(of: self))
}
public convenience init() {

View File

@ -41,28 +41,28 @@ extension GeneralDataLoadingState: DataLoadingState {
public typealias DataSourceType = DS
public static var initialState: GeneralDataLoadingState<DS> {
return .initial
.initial
}
public static var emptyState: GeneralDataLoadingState<DS> {
return .empty
.empty
}
public static func initialLoadingState(after: GeneralDataLoadingState<DS>) -> GeneralDataLoadingState<DS> {
return .loading
.loading
}
public static func resultState(result: DS.ResultType,
from: DS,
after: GeneralDataLoadingState<DS>) -> GeneralDataLoadingState<DS> {
return .result(newResult: result, from: from)
.result(newResult: result, from: from)
}
public static func errorState(error: Error,
after: GeneralDataLoadingState<DS>) -> GeneralDataLoadingState<DS> {
return .error(error: error)
.error(error: error)
}
public var isInitialState: Bool {

View File

@ -45,28 +45,28 @@ extension PaginationDataLoadingState: DataLoadingState {
public typealias DataSourceType = DS
public static var initialState: PaginationDataLoadingState<DS> {
return .initial
.initial
}
public static var emptyState: PaginationDataLoadingState<DS> {
return .empty
.empty
}
public static func initialLoadingState(after: PaginationDataLoadingState<DS>) -> PaginationDataLoadingState<DS> {
return .initialLoading(after: after)
.initialLoading(after: after)
}
public static func resultState(result: DS.ResultType,
from: DataSourceType,
after: PaginationDataLoadingState<DS>) -> PaginationDataLoadingState<DS> {
return .results(newItems: result, from: from, after: after)
.results(newItems: result, from: from, after: after)
}
public static func errorState(error: Error,
after: PaginationDataLoadingState<DS>) -> PaginationDataLoadingState<DS> {
return .error(error: error, after: after)
.error(error: error, after: after)
}
public var isInitialState: Bool {

View File

@ -36,7 +36,7 @@ public extension Reactive where Base: DataRequest {
func apiResponse<T: Decodable>(mappingQueue: DispatchQueue = .global(), decoder: JSONDecoder)
-> Observable<SessionManager.ModelResponse<T>> {
return response(onQueue: mappingQueue)
response(onQueue: mappingQueue)
.tryMapResult { response, data in
(response, try decoder.decode(T.self, from: data))
}
@ -50,7 +50,7 @@ public extension Reactive where Base: DataRequest {
func observableApiResponse<T: ObservableMappable>(mappingQueue: DispatchQueue = .global(), decoder: JSONDecoder)
-> Observable<SessionManager.ModelResponse<T>> {
return response(onQueue: mappingQueue)
response(onQueue: mappingQueue)
.tryMapObservableResult { response, value in
let json = try JSONSerialization.jsonObject(with: value, options: [])
return T.create(from: json, with: decoder)
@ -64,13 +64,13 @@ public extension Reactive where Base: DataRequest {
/// - Parameter mappingQueue: The dispatch queue to use for mapping
/// - Returns: Observable with HTTP URL Response and data
func dataApiResponse(mappingQueue: DispatchQueue) -> Observable<SessionManager.DataResponse> {
return response(onQueue: mappingQueue)
response(onQueue: mappingQueue)
.map { $0 as SessionManager.DataResponse }
.catchAsRequestError(with: self.base)
}
private func response(onQueue queue: DispatchQueue) -> Observable<(HTTPURLResponse, Data)> {
return responseResult(queue: queue, responseSerializer: DataResponseSerializer())
responseResult(queue: queue, responseSerializer: DataResponseSerializer())
}
}
@ -81,7 +81,7 @@ public extension ObservableType where Element == DataRequest {
/// - Parameter statusCodes: set of status codes to validate
/// - Returns: Observable on self
func validate(statusCodes: Set<Int>) -> Observable<Element> {
return map { $0.validate(statusCode: statusCodes) }
map { $0.validate(statusCode: statusCodes) }
.catchAsRequestError()
}
}
@ -89,7 +89,7 @@ public extension ObservableType where Element == DataRequest {
private extension ObservableType where Element == ServerResponse {
func tryMapResult<R>(_ transform: @escaping (Element) throws -> R) -> Observable<R> {
return map {
map {
do {
return try transform($0)
} catch {
@ -99,10 +99,10 @@ private extension ObservableType where Element == ServerResponse {
}
func tryMapObservableResult<R>(_ transform: @escaping (Element) throws -> Observable<R>) -> Observable<R> {
return flatMap { response, result -> Observable<R> in
flatMap { response, result -> Observable<R> in
do {
return try transform((response, result))
.catchError {
.catch {
throw RequestError.mapping(error: $0, response: result)
}
} catch {
@ -115,7 +115,7 @@ private extension ObservableType where Element == ServerResponse {
private extension ObservableType {
func catchAsRequestError(with request: DataRequest? = nil) -> Observable<Element> {
return catchError { error in
self.catch { error in
let resultError: RequestError
let response = request?.data

View File

@ -53,7 +53,7 @@ public extension Reactive where Base: SessionManager {
headers: HTTPHeaders? = nil)
-> Observable<DataRequest> {
return Observable.deferred {
Observable.deferred {
guard method != .get else {
assertionFailure("Unable to pass array in get request")
@ -74,7 +74,7 @@ public extension Reactive where Base: SessionManager {
/// - additionalValidStatusCodes: set of additional valid status codes
/// - Returns: Observable with request
func apiRequest(requestParameters: ApiRequestParameters, additionalValidStatusCodes: Set<Int>) -> Observable<DataRequest> {
return .deferred {
.deferred {
var url = try requestParameters.url.asURL()
if let queryItems = requestParameters.queryItems {
@ -133,7 +133,7 @@ public extension Reactive where Base: SessionManager {
decoder: JSONDecoder)
-> Observable<SessionManager.ModelResponse<T>> {
return apiRequest(requestParameters: requestParameters, additionalValidStatusCodes: additionalValidStatusCodes)
apiRequest(requestParameters: requestParameters, additionalValidStatusCodes: additionalValidStatusCodes)
.flatMap {
$0.rx.apiResponse(mappingQueue: self.base.mappingQueue, decoder: decoder)
}
@ -151,7 +151,7 @@ public extension Reactive where Base: SessionManager {
decoder: JSONDecoder)
-> Observable<SessionManager.ModelResponse<T>> {
return apiRequest(requestParameters: requestParameters, additionalValidStatusCodes: additionalValidStatusCodes)
apiRequest(requestParameters: requestParameters, additionalValidStatusCodes: additionalValidStatusCodes)
.flatMap {
$0.rx.observableApiResponse(mappingQueue: self.base.mappingQueue, decoder: decoder)
}
@ -166,7 +166,7 @@ public extension Reactive where Base: SessionManager {
func responseData(requestParameters: ApiRequestParameters, additionalValidStatusCodes: Set<Int>)
-> Observable<SessionManager.DataResponse> {
return apiRequest(requestParameters: requestParameters, additionalValidStatusCodes: additionalValidStatusCodes)
apiRequest(requestParameters: requestParameters, additionalValidStatusCodes: additionalValidStatusCodes)
.flatMap {
$0.rx.dataApiResponse(mappingQueue: self.base.mappingQueue)
}
@ -184,7 +184,7 @@ public extension Reactive where Base: SessionManager {
decoder: JSONDecoder)
-> Observable<SessionManager.ModelResponse<T>> {
return Observable.deferred {
Observable.deferred {
let urlRequest = try URLRequest(url: requestParameters.url, method: .post, headers: requestParameters.headers)
let data = try requestParameters.formData.encode()

View File

@ -69,6 +69,6 @@ public extension Array {
// Subscript for safe access to element by index
subscript(safe index: Index) -> Element? {
return (index < count && index >= 0) ? self[index] : nil
(index < count && index >= 0) ? self[index] : nil
}
}

View File

@ -26,11 +26,11 @@ public extension Array where Element: TableKitViewModel {
/// Creates [Row] array from TableKitViewModels.
var tableRows: [Row] {
return map { $0.tableRow }
map { $0.tableRow }
}
/// Creates TableSection with empty, zero height header and footer.
var onlyRowsSection: TableSection {
return TableSection(onlyRows: tableRows)
TableSection(onlyRows: tableRows)
}
}

View File

@ -26,7 +26,7 @@ public extension Array where Element == SeparatorRowBox {
/// Create rows from SeparatorRowBox array
var rows: [Row] {
return map { $0.row }
map { $0.row }
}
/// Configure separators from SeparatorRowBox array

View File

@ -25,10 +25,10 @@ extension Array: TotalCountCursorListingResult {
public typealias ElementType = Element
public var results: [Element] {
return self
self
}
public var totalCount: Int {
return count
count
}
}

View File

@ -39,7 +39,7 @@ public extension Encodable {
/// Method that converts encodable model to URLQueryItems array
/// - Returns: URLQueryItems array
func asUrlQueryItems() throws -> [URLQueryItem] {
return try toJSON().map {
try toJSON().map {
if ($1 is [String: Any] || $1 is [Any]),
let jsonData = try? JSONSerialization.data(withJSONObject: $1, options: []),
let jsonString = String(data: jsonData, encoding: .utf8) {

View File

@ -28,13 +28,13 @@ public extension Comparable {
/// - parameter bounds: Lower and uppper bounds tuple
/// - returns: Current value if it fits range, otherwise lower if value is too small or upper if value is too big
func `in`(bounds: (lower: Self, upper: Self)) -> Self {
return min(max(bounds.lower, self), bounds.upper)
min(max(bounds.lower, self), bounds.upper)
}
/// Use this function to restrict comparable with lower and upper values
/// - parameter range: ClosedRange representing bounds
/// - returns: Current value if it fits range, otherwise lower if value is too small or upper if value is too big
func `in`(range: ClosedRange<Self>) -> Self {
return `in`(bounds: (lower: range.lowerBound, upper: range.upperBound))
`in`(bounds: (lower: range.lowerBound, upper: range.upperBound))
}
}

View File

@ -25,6 +25,6 @@ import RxSwift
public extension RxDataSource where Self: CursorType {
func resultSingle() -> Single<[Element]> {
return loadNextBatch()
loadNextBatch()
}
}

View File

@ -25,14 +25,14 @@ import Foundation
public extension CursorType {
subscript(range: CountableRange<Int>) -> [Self.Element] {
return range.map { self[$0] }
range.map { self[$0] }
}
subscript(range: CountableClosedRange<Int>) -> [Self.Element] {
return range.map { self[$0] }
range.map { self[$0] }
}
var loadedElements: [Self.Element] {
return self[0..<count]
self[0..<count]
}
}

View File

@ -28,8 +28,8 @@ public extension TotalCountCursorListingResult {
/// - Parameter transform: closure to transform results
/// - Returns: new DefaultTotalCountCursorListingResult instance
func asDefaultListingResult<E>(transform: ((ElementType) -> E)) -> DefaultTotalCountCursorListingResult<E> {
return DefaultTotalCountCursorListingResult(results: results.map(transform),
totalCount: totalCount)
DefaultTotalCountCursorListingResult(results: results.map(transform),
totalCount: totalCount)
}
/// Method that creates DefaultTotalCountCursorListingResult
@ -37,7 +37,7 @@ public extension TotalCountCursorListingResult {
///
/// - Returns: new DefaultTotalCountCursorListingResult instance
func asDefaultListingResult() -> DefaultTotalCountCursorListingResult<ElementType> {
return DefaultTotalCountCursorListingResult(results: results,
totalCount: totalCount)
DefaultTotalCountCursorListingResult(results: results,
totalCount: totalCount)
}
}

View File

@ -28,13 +28,13 @@ public extension GeneralDataLoadingController {
// MARK: - DisposeBagHolder default implementation
var disposeBag: DisposeBag {
return viewModel.disposeBag
viewModel.disposeBag
}
// MARK: - StatefulViewController default implementation
func hasContent() -> Bool {
return viewModel.hasContent
viewModel.hasContent
}
// MARK: - GeneralDataLoadingController default implementation

View File

@ -27,7 +27,7 @@ import RxCocoa
internal extension GeneralDataLoadingHandler where Self: AnyObject {
var stateChangeBinder: Binder<GeneralDataLoadingState<Single<ResultType>>> {
return Binder(self) { base, value in
Binder(self) { base, value in
switch value {
case .loading:
base.onLoadingState()

View File

@ -34,7 +34,7 @@ public extension GeneralDataLoadingViewModel {
/// Emit elements of ResultType from state observable.
var resultObservable: Observable<ResultType> {
return loadingStateObservable.flatMap { state -> Observable<ResultType> in
loadingStateObservable.flatMap { state -> Observable<ResultType> in
switch state {
case .result(let newResult, _):
return .just(newResult)
@ -47,7 +47,7 @@ public extension GeneralDataLoadingViewModel {
/// Emit elements of ResultType from state driver.
var resultDriver: Driver<ResultType> {
return loadingStateDriver.flatMap { state -> Driver<ResultType> in
loadingStateDriver.flatMap { state -> Driver<ResultType> in
switch state {
case .result(let newResult, _):
return .just(newResult)

View File

@ -25,15 +25,15 @@ import UIKit
public extension PaginationWrapperUIDelegate {
func emptyPlaceholder() -> UIView? {
return TextPlaceholderView(title: .empty)
TextPlaceholderView(title: .empty)
}
func customInitialLoadingErrorHandling(for error: Error) -> Bool {
return false
false
}
func errorPlaceholder(for error: Error) -> UIView? {
return TextPlaceholderView(title: .error)
TextPlaceholderView(title: .error)
}
func initialLoadingIndicator() -> AnyLoadingIndicator? {
@ -58,7 +58,7 @@ public extension PaginationWrapperUIDelegate {
}
func footerRetryViewHeight() -> CGFloat {
return 44
44
}
func footerRetryViewWillAppear() {

View File

@ -26,7 +26,7 @@ extension UITableView: PaginationWrappable {
public var footerView: UIView? {
get {
return tableFooterView
tableFooterView
}
set {
tableFooterView = newValue

View File

@ -28,7 +28,7 @@ extension Observable: RxDataSource {
public typealias ResultType = Element
public func resultSingle() -> Single<ResultType> {
return asSingle()
asSingle()
}
}
@ -41,6 +41,6 @@ extension Single: RxDataSource {
public typealias ResultType = Element
public func resultSingle() -> Single<ResultType> {
return asObservable().asSingle()
asObservable().asSingle()
}
}

View File

@ -28,7 +28,7 @@ public extension DateFormattingService {
format: DateFormatType,
defaultDate: DateInRegion = Date().inDefaultRegion()) -> DateInRegion {
return date(from: string, format: format, parsedIn: nil) ?? defaultDate
date(from: string, format: format, parsedIn: nil) ?? defaultDate
}
func date(from string: String,
@ -53,7 +53,7 @@ public extension DateFormattingService {
}
func string(from date: DateRepresentable, format: DateFormatType) -> String {
return format.dateToStringFormat.toString(date)
format.dateToStringFormat.toString(date)
}
func string(from date: DateRepresentable, format: DateFormatType, formattedIn: Region?) -> String {
@ -79,7 +79,7 @@ public extension DateFormattingService where Self: Singleton {
format: DateFormatType,
defaultDate: DateInRegion = Date().inDefaultRegion()) -> DateInRegion {
return shared.date(from: string, format: format, defaultDate: defaultDate)
shared.date(from: string, format: format, defaultDate: defaultDate)
}
/// Method parses date from string in given format with current region.
@ -90,7 +90,7 @@ public extension DateFormattingService where Self: Singleton {
/// - parsedIn: A region that should be used for date parsing. In case of nil defaultRegion will be used.
/// - Returns: Date parsed from given string or default date if parsing did fail.
static func date(from string: String, format: DateFormatType, parsedIn: Region?) -> DateInRegion? {
return shared.date(from: string, format: format, parsedIn: parsedIn)
shared.date(from: string, format: format, parsedIn: parsedIn)
}
/// Method parses date from string in one of the given formats with current region.
@ -101,7 +101,7 @@ public extension DateFormattingService where Self: Singleton {
/// - parsedIn: A region that should be used for date parsing. In case of nil defaultRegion will be used.
/// - Returns: Date parsed from given string or default date if parsing did fail.
static func date(from string: String, formats: [DateFormatType], parsedIn: Region?) -> DateInRegion? {
return shared.date(from: string, formats: formats, parsedIn: parsedIn)
shared.date(from: string, formats: formats, parsedIn: parsedIn)
}
/// Method format date in given format.
@ -111,7 +111,7 @@ public extension DateFormattingService where Self: Singleton {
/// - format: Format that should be used for date formatting.
/// - Returns: String that contains formatted date or nil if formatting did fail.
static func string(from date: DateRepresentable, format: DateFormatType) -> String {
return shared.string(from: date, format: format)
shared.string(from: date, format: format)
}
/// Method format date in given format for specific region.
@ -122,6 +122,6 @@ public extension DateFormattingService where Self: Singleton {
/// - formattedIn: A region that should be used for date formatting. In case of nil defaultRegion will be used.
/// - Returns: String that contains formatted date or nil if formatting did fail.
static func string(from date: DateRepresentable, format: DateFormatType, formattedIn: Region?) -> String {
return shared.string(from: date, format: format, formattedIn: formattedIn)
shared.string(from: date, format: format, formattedIn: formattedIn)
}
}

View File

@ -26,11 +26,11 @@ public extension Decimal {
/// Conver Decimal to Double value
var doubleValue: Double {
return NSDecimalNumber(decimal: self).doubleValue
NSDecimalNumber(decimal: self).doubleValue
}
/// Conver Decimal to Int value
var intValue: Int {
return NSDecimalNumber(decimal: self).intValue
NSDecimalNumber(decimal: self).intValue
}
}

View File

@ -41,11 +41,11 @@ public extension CGContext {
static func create(forCGImage cgImage: CGImage,
fallbackColorSpace: CGColorSpace = CGColorSpaceCreateDeviceRGB()) -> CGContext? {
return create(width: cgImage.width,
height: cgImage.height,
bitmapInfo: cgImage.bitmapInfo,
colorSpace: cgImage.colorSpace ?? fallbackColorSpace,
bitsPerComponent: cgImage.bitsPerComponent)
create(width: cgImage.width,
height: cgImage.height,
bitmapInfo: cgImage.bitmapInfo,
colorSpace: cgImage.colorSpace ?? fallbackColorSpace,
bitsPerComponent: cgImage.bitsPerComponent)
}
/// Creates a bitmap graphics context.
@ -65,12 +65,12 @@ public extension CGContext {
colorSpace: CGColorSpace = CGColorSpaceCreateDeviceRGB(),
bitsPerComponent: Int = 8) -> CGContext? {
return CGContext(data: nil,
width: width,
height: height,
bitsPerComponent: bitsPerComponent,
bytesPerRow: 0,
space: colorSpace,
bitmapInfo: bitmapInfo.rawValue)
CGContext(data: nil,
width: width,
height: height,
bitsPerComponent: bitsPerComponent,
bytesPerRow: 0,
space: colorSpace,
bitmapInfo: bitmapInfo.rawValue)
}
}

View File

@ -25,6 +25,6 @@ import CoreGraphics.CGGeometry
public extension CGSize {
var ceiledContextSize: CGContextSize {
return (width: Int(ceil(width)), height: Int(ceil(height)))
(width: Int(ceil(width)), height: Int(ceil(height)))
}
}

View File

@ -55,7 +55,7 @@ public extension UIImage {
/// - Parameter color: Color to fill template image.
/// - Returns: A new UIImage rendered with given color or original image if something goes wrong.
func renderTemplate(withColor color: UIColor) -> UIImage {
return withCGImage { image in
withCGImage { image in
let operation = TemplateDrawingOperation(image: image,
imageSize: size,
color: color.cgColor)
@ -77,7 +77,7 @@ public extension UIImage {
color: UIColor,
extendSize: Bool = false) -> UIImage {
return withCGImage { image in
withCGImage { image in
let roundOperation = RoundDrawingOperation(image: image,
imageSize: size,
radius: cornerRadius)
@ -101,7 +101,7 @@ public extension UIImage {
///
/// - Returns: A new circled image or original image if something goes wrong.
func roundCornersToCircle() -> UIImage {
return withCGImage { image in
withCGImage { image in
let radius = CGFloat(min(size.width, size.height) / 2)
let operation = RoundDrawingOperation(image: image,
@ -123,7 +123,7 @@ public extension UIImage {
borderColor: UIColor,
extendSize: Bool = false) -> UIImage {
return withCGImage { image in
withCGImage { image in
let radius = CGFloat(min(size.width, size.height) / 2)
let roundOperation = RoundDrawingOperation(image: image,
@ -157,7 +157,7 @@ public extension UIImage {
contentMode: ResizeMode = .scaleToFill,
cropToImageBounds: Bool = false) -> UIImage {
return withCGImage { image in
withCGImage { image in
let operation = ResizeDrawingOperation(image: image,
imageSize: size,
preferredNewSize: newSize,
@ -172,7 +172,7 @@ public extension UIImage {
///
/// - Returns: A copy of the given image, adding an alpha channel if it doesn't already have one.
func applyAlpha() -> UIImage {
return withCGImage { image in
withCGImage { image in
guard !image.hasAlpha else {
return self
}
@ -190,7 +190,7 @@ public extension UIImage {
/// - Parameter padding: The padding amount.
/// - Returns: A new padded image or original image if something goes wrong.
func applyPadding(_ padding: CGFloat) -> UIImage {
return withCGImage { image in
withCGImage { image in
let operation = PaddingDrawingOperation(image: image, imageSize: size, padding: padding)
return operation.imageFromNewRenderer(scale: scale).redraw()
@ -204,7 +204,7 @@ public extension UIImage {
/// - clockwise: Should rotate image clockwise.
/// - Returns: A new rotated image or original image if something goes wrong.
func rotate(degrees: CGFloat, clockwise: Bool = true) -> UIImage {
return withCGImage { image in
withCGImage { image in
let radians = degrees.degreesToRadians()
let operation = RotateDrawingOperation(image: image,
@ -218,7 +218,7 @@ public extension UIImage {
/// Workaround to fix flipped image rendering (by Y)
private func redraw() -> UIImage {
return withCGImage { image in
withCGImage { image in
let operation = ImageDrawingOperation(image: image, newSize: size)
return operation.imageFromNewRenderer(scale: scale)

View File

@ -25,7 +25,7 @@ import RxSwift
public extension Error {
var requestError: RequestError? {
return self as? RequestError
self as? RequestError
}
/// Method that tries to serialize response from a mapping request error to a model
@ -52,7 +52,7 @@ public extension ObservableType {
/// - Returns: Observable on caller
func handleMappingError<T: Decodable>(with decoder: JSONDecoder = JSONDecoder(),
handler: @escaping ParameterClosure<T>) -> Observable<Element> {
return self.do(onError: { error in
self.do(onError: { error in
guard let errorModel = try error.handleMappingError(with: decoder) as T? else {
return
}
@ -72,7 +72,7 @@ public extension PrimitiveSequence where Trait == SingleTrait {
/// - Returns: Single on caller
func handleMappingError<T: Decodable>(with decoder: JSONDecoder = JSONDecoder(),
handler: @escaping ParameterClosure<T>) -> PrimitiveSequence<Trait, Element> {
return self.do(onError: { error in
self.do(onError: { error in
guard let errorModel = try error.handleMappingError(with: decoder) as T? else {
return
}
@ -92,7 +92,7 @@ public extension PrimitiveSequence where Trait == CompletableTrait, Element == N
/// - Returns: Completable
func handleMappingError<T: Decodable>(with decoder: JSONDecoder = JSONDecoder(),
handler: @escaping ParameterClosure<T>) -> Completable {
return self.do(onError: { error in
self.do(onError: { error in
guard let errorModel = try error.handleMappingError(with: decoder) as T? else {
return
}

View File

@ -26,13 +26,13 @@ public extension FloatingPoint {
///
/// - Returns: radians
func degreesToRadians() -> Self {
return self * .pi / 180
self * .pi / 180
}
/// Converts radians to degrees
///
/// - Returns: degrees
func radiansToDegrees() -> Self {
return self * 180 / .pi
self * 180 / .pi
}
}

View File

@ -38,7 +38,7 @@ public extension UserDefaults {
/// - Returns: The object with specified type associated with the specified key, or passed default value
/// if there is no such value for specified key or if error occurred during mapping.
func object<T: Decodable>(forKey key: String, defaultValue: T, decoder: JSONDecoder = JSONDecoder()) -> T {
return (try? object(forKey: key, decoder: decoder)) ?? defaultValue
(try? object(forKey: key, decoder: decoder)) ?? defaultValue
}
/// Set or remove the value of the specified default key in the standard application domain.
@ -58,7 +58,7 @@ public extension UserDefaults {
subscript<T: Codable>(key: String) -> T? {
get {
return try? object(forKey: key)
try? object(forKey: key)
}
set {
try? set(object: newValue, forKey: key)
@ -75,7 +75,7 @@ public extension Reactive where Base: UserDefaults {
/// - decoder: JSON decoder to decode stored data.
/// - Returns: Single of specified model type.
func object<T: Decodable>(forKey key: String, decoder: JSONDecoder = JSONDecoder()) -> Single<T> {
return .deferredJust { try self.base.object(forKey: key, decoder: decoder) }
.deferredJust { try self.base.object(forKey: key, decoder: decoder) }
}
/// Reactive version of object<T>(forKey:defaultValue:decoder:) -> T.
@ -87,7 +87,7 @@ public extension Reactive where Base: UserDefaults {
/// - decoder: JSON decoder to decode stored data.
/// - Returns: Single of specified model type.
func object<T: Decodable>(forKey key: String, defaultValue: T, decoder: JSONDecoder = JSONDecoder()) -> Single<T> {
return .deferredJust { self.base.object(forKey: key, defaultValue: defaultValue, decoder: decoder) }
.deferredJust { self.base.object(forKey: key, defaultValue: defaultValue, decoder: decoder) }
}
/// Reactive version of set<T>(object:forKey:encoder:).
@ -98,7 +98,7 @@ public extension Reactive where Base: UserDefaults {
/// - encoder: JSON encoder to encode to encode passed object.
/// - Returns: Completable.
func set<T: Encodable>(object: T?, forKey key: String, encoder: JSONEncoder = JSONEncoder()) -> Completable {
return .deferredJust {
.deferredJust {
try self.base.set(object: object, forKey: key, encoder: encoder)
}
}

View File

@ -33,7 +33,7 @@ public extension NSAttributedString {
/// Mutable copy of attributed string.
var mutable: NSMutableAttributedString {
return NSMutableAttributedString(attributedString: self)
NSMutableAttributedString(attributedString: self)
}
}
@ -51,6 +51,6 @@ public extension NSMutableAttributedString {
/// Immutable copy of attributed string.
var immutable: NSAttributedString {
return NSAttributedString(attributedString: self)
NSAttributedString(attributedString: self)
}
}

View File

@ -25,41 +25,41 @@ import Foundation
extension NSNumber: NSNumberConvertible {
public func asNSNumber() -> NSNumber {
return self
self
}
}
extension Decimal: NSNumberConvertible {
public func asNSNumber() -> NSNumber {
return NSDecimalNumber(decimal: self)
NSDecimalNumber(decimal: self)
}
}
extension Int: NSNumberConvertible {
public func asNSNumber() -> NSNumber {
return NSNumber(value: self)
NSNumber(value: self)
}
}
extension Int64: NSNumberConvertible {
public func asNSNumber() -> NSNumber {
return NSNumber(value: self)
NSNumber(value: self)
}
}
extension Double: NSNumberConvertible {
public func asNSNumber() -> NSNumber {
return NSNumber(value: self)
NSNumber(value: self)
}
}
extension Float: NSNumberConvertible {
public func asNSNumber() -> NSNumber {
return NSNumber(value: self)
NSNumber(value: self)
}
}

View File

@ -26,7 +26,7 @@ public extension NumberFormattingService {
/// Computed static property. Use only once for `formatters` field implementation!
static var computedFormatters: [NumberFormatType: NumberFormatter] {
return Dictionary(uniqueKeysWithValues: NumberFormatType.allCases.map { ($0, $0.numberFormatter) })
Dictionary(uniqueKeysWithValues: NumberFormatType.allCases.map { ($0, $0.numberFormatter) })
}
func numberFormatter(for format: NumberFormatType) -> NumberFormatter {
@ -38,21 +38,21 @@ public extension NumberFormattingService {
}
func string(from number: NSNumberConvertible, format: NumberFormatType, defaultString: String = "") -> String {
return numberFormatter(for: format).string(from: number.asNSNumber()) ?? defaultString
numberFormatter(for: format).string(from: number.asNSNumber()) ?? defaultString
}
func number(from string: String, format: NumberFormatType) -> NSNumber? {
return numberFormatter(for: format).number(from: string)
numberFormatter(for: format).number(from: string)
}
}
public extension NumberFormattingService where Self: Singleton {
static func string(from number: NSNumberConvertible, format: NumberFormatType, defaultString: String = "") -> String {
return shared.string(from: number, format: format, defaultString: defaultString)
shared.string(from: number, format: format, defaultString: defaultString)
}
static func number(from string: String, format: NumberFormatType) -> NSNumber? {
return shared.number(from: string, format: format)
shared.number(from: string, format: format)
}
}

View File

@ -30,7 +30,7 @@ public extension ObservableType {
/// that subscribes to the resulting sequence.
/// - Returns: An observable sequence whose observers trigger an invocation of the given element factory function.
static func deferredJust(_ elementFactory: @escaping () throws -> Element) -> Observable<Element> {
return .create { observer in
.create { observer in
do {
observer.onNext(try elementFactory())
observer.onCompleted()

View File

@ -29,20 +29,20 @@ public extension ObservableType {
/// - Parameter value: A new element.
/// - Returns: An observable sequence whose elements are equals to passed value.
func replace<T>(with value: T) -> Observable<T> {
return map { _ in value } // swiftlint:disable:this unused_map_parameter
map { _ in value } // swiftlint:disable:this unused_map_parameter
}
/// Replaces all emitted elements with Void.
///
/// - Returns: An observable sequence whose elements are equals to Void.
func asVoid() -> Observable<Void> {
return replace(with: Void())
replace(with: Void())
}
/// Cast all emitted elements to optional type.
///
/// - Returns: An observable sequence whose elements are equals to optional type of element.
func asOptional() -> Observable<Element?> {
return map { $0 }
map { $0 }
}
}

View File

@ -30,7 +30,7 @@ public extension PrimitiveSequence where Trait == CompletableTrait {
/// that subscribes to the resulting sequence.
/// - Returns: A single whose observers trigger an invocation of the given element factory function.
static func deferredJust(_ workUnit: @escaping ThrowableVoidBlock) -> Completable {
return .create { observer in
.create { observer in
do {
try workUnit()
observer(.completed)

View File

@ -30,7 +30,7 @@ public extension Single {
/// that subscribes to the resulting sequence.
/// - Returns: A single whose observers trigger an invocation of the given element factory function.
static func deferredJust(_ elementFactory: @escaping () throws -> Element) -> Single<Element> {
return .create { observer in
.create { observer in
do {
observer(.success(try elementFactory()))
} catch {

View File

@ -29,20 +29,20 @@ public extension PrimitiveSequence where Trait == SingleTrait {
/// - Parameter value: A new element.
/// - Returns: An primitive sequence whose element is equal to passed value.
func replace<T>(with value: T) -> PrimitiveSequence<Trait, T> {
return map { _ in value } // swiftlint:disable:this unused_map_parameter
map { _ in value } // swiftlint:disable:this unused_map_parameter
}
/// Replaces emitted element with Void.
///
/// - Returns: An primitive sequence whose element is equal to Void.
func asVoid() -> PrimitiveSequence<Trait, Void> {
return replace(with: Void())
replace(with: Void())
}
/// Cast emitted element to optional type.
///
/// - Returns: An primitive sequence whose element is equals to optional type of element.
func asOptional() -> PrimitiveSequence<Trait, Element?> {
return map { $0 }
map { $0 }
}
}

View File

@ -29,20 +29,20 @@ public extension SharedSequence {
/// - Parameter value: A new element.
/// - Returns: An observable sequence whose elements are equals to passed value.
func replace<T>(with value: T) -> SharedSequence<SharingStrategy, T> {
return map { _ in value } // swiftlint:disable:this unused_map_parameter
map { _ in value } // swiftlint:disable:this unused_map_parameter
}
/// Replaces all emitted elements with Void.
///
/// - Returns: An observable sequence whose elements are equals to Void.
func asVoid() -> SharedSequence<SharingStrategy, Void> {
return replace(with: Void())
replace(with: Void())
}
/// Cast all emitted elements to optional type.
///
/// - Returns: An observable sequence whose elements are equals to optional type of element.
func asOptional() -> SharedSequence<SharingStrategy, Element?> {
return map { $0 }
map { $0 }
}
}

View File

@ -30,6 +30,6 @@ public extension String {
- returns: nil if string empty, self otherwise
*/
var nilIfEmpty: String? {
return isEmpty ? nil : self
isEmpty ? nil : self
}
}

View File

@ -30,6 +30,6 @@ public extension String {
- returns: localized string
*/
func localized() -> String {
return NSLocalizedString(self, comment: "")
NSLocalizedString(self, comment: "")
}
}

View File

@ -96,7 +96,7 @@ public extension TableDirector {
*/
@discardableResult
func replace(withSection section: TableSection) -> Self {
return replace(withSections: [section])
replace(withSections: [section])
}
/**
@ -108,7 +108,7 @@ public extension TableDirector {
*/
@discardableResult
func replace(withRows rows: [Row]) -> Self {
return replace(withSection: TableSection(rows: rows))
replace(withSection: TableSection(rows: rows))
}
/// Clear table view and reload it within empty section

View File

@ -47,6 +47,6 @@ public extension TableRow where CellType: SeparatorCell {
/// TableRow typed as SeparatorRowBox
var separatorRowBox: SeparatorRowBox {
return SeparatorRowBox(row: self)
SeparatorRowBox(row: self)
}
}

View File

@ -29,6 +29,6 @@ public extension TableKitViewModel {
/// Returns TableRow initialized with current view model.
var tableRow: RowType {
return RowType(item: self)
RowType(item: self)
}
}

View File

@ -25,6 +25,6 @@ import UIKit.UIScrollView
public extension ScrollViewHolder where Self: CollectionViewHolder {
var scrollView: UIScrollView {
return collectionView
collectionView
}
}

View File

@ -25,6 +25,6 @@ import UIKit.UIScrollView
public extension ScrollViewHolder where Self: TableViewHolder {
var scrollView: UIScrollView {
return tableView
tableView
}
}

View File

@ -26,7 +26,7 @@ extension UIButton: ViewTextConfigurable {
public var textFont: UIFont? {
get {
return titleLabel?.font
titleLabel?.font
}
set {
titleLabel?.font = newValue
@ -35,7 +35,7 @@ extension UIButton: ViewTextConfigurable {
public var titleColor: UIColor? {
get {
return currentTitleColor
currentTitleColor
}
set {
setTitleColor(newValue, for: [])
@ -44,7 +44,7 @@ extension UIButton: ViewTextConfigurable {
public var textAlignment: NSTextAlignment {
get {
return contentHorizontalAlignment.textAlignment
contentHorizontalAlignment.textAlignment
}
set {
contentHorizontalAlignment = .init(textAlignment: newValue)
@ -53,7 +53,7 @@ extension UIButton: ViewTextConfigurable {
public var text: String? {
get {
return currentTitle
currentTitle
}
set {
setTitle(newValue, for: [])
@ -62,7 +62,7 @@ extension UIButton: ViewTextConfigurable {
public var attributedText: NSAttributedString? {
get {
return currentAttributedTitle
currentAttributedTitle
}
set {
setAttributedTitle(newValue, for: [])

View File

@ -30,7 +30,7 @@ public extension UIImageView {
/// Rotates image view by 180 degrees via transform property with animation.
var expandRotationBinder: Binder<Bool> {
return Binder(self) { view, isExpanded in
Binder(self) { view, isExpanded in
let angle = isExpanded ? CGFloat.pi / 2 : -CGFloat.pi / 2

View File

@ -26,7 +26,7 @@ extension UILabel: ViewTextConfigurable {
public var textFont: UIFont? {
get {
return font
font
}
set {
font = newValue
@ -35,7 +35,7 @@ extension UILabel: ViewTextConfigurable {
public var titleColor: UIColor? {
get {
return textColor
textColor
}
set {
textColor = newValue

View File

@ -28,7 +28,7 @@ public extension Reactive where Base: UIScrollView {
/// Binder instance that updates contentInset bottom value.
/// If it doesn't work, observe it on MainScheduler.asyncInstance.
var bottomInsetBinder: Binder<CGFloat> {
return Binder(base) { base, value in
Binder(base) { base, value in
base.contentInset.bottom = value
base.scrollIndicatorInsets.bottom = value
}

View File

@ -25,6 +25,6 @@ import UIKit.UIScrollView
extension UIScrollView: ScrollViewHolder {
public var scrollView: UIScrollView {
return self
self
}
}

View File

@ -25,6 +25,6 @@ import UIKit.UITableView
extension UITableView: TableViewHolder {
public var tableView: UITableView {
return self
self
}
}

View File

@ -26,7 +26,7 @@ extension UITextField: ViewTextConfigurable {
public var textFont: UIFont? {
get {
return font
font
}
set {
font = newValue
@ -35,7 +35,7 @@ extension UITextField: ViewTextConfigurable {
public var titleColor: UIColor? {
get {
return textColor
textColor
}
set {
textColor = newValue

View File

@ -31,7 +31,7 @@ public extension UIView {
/// If you specify nil, this method looks for the nib file in the main bundle.
/// - Returns: UIView or UIView subclass instance
static func loadFromNib<T>(bundle: Bundle? = nil) -> T where T: UIView {
return loadFromNib(named: T.xibName, bundle: bundle)
loadFromNib(named: T.xibName, bundle: bundle)
}
/// Method which loads UIView (or subclass) instance from nib using given nib name parameter

View File

@ -25,6 +25,6 @@ import UIKit
public extension LoadingIndicator where Self: UIView {
var view: Self {
return self
self
}
}

View File

@ -25,6 +25,6 @@ import UIKit
extension UIView: XibNameProtocol {
open class var xibName: String {
return typeName(of: self)
typeName(of: self)
}
}

View File

@ -25,6 +25,6 @@ import UIKit
extension UIViewController: XibNameProtocol {
open class var xibName: String {
return typeName(of: self)
typeName(of: self)
}
}

View File

@ -36,7 +36,7 @@ public extension ContentLoadingViewModel where PlaceholderType == Void {
/// Creates ContentLoadingViewModel with placeholder.
static var placeholder: ContentLoadingViewModel<ContentType, PlaceholderType> {
return .placeholder(())
.placeholder(())
}
}
@ -47,6 +47,6 @@ public extension ContentLoadingViewModel where PlaceholderType == [Void] {
/// - Parameter numberOfItems: Number of placeholders to create.
/// - Returns: ContentLoadingViewModel with placeholder.
static func placeholders(numberOfItems: Int) -> ContentLoadingViewModel<ContentType, PlaceholderType> {
return .placeholder(Array(repeating: (), count: numberOfItems))
.placeholder(Array(repeating: (), count: numberOfItems))
}
}

View File

@ -51,6 +51,6 @@ public extension PlaceholderConfigurable {
/// - Parameter contentViewModel: Content of ContentLoadingViewModel.
/// - Returns: ContentLoadingViewModel with content.
static func content(with contentViewModel: ContentViewModelType) -> ContentLoadingViewModelType {
return .content(contentViewModel)
.content(contentViewModel)
}
}

View File

@ -26,12 +26,12 @@ public extension CellSeparatorType {
/// Determine if bottom separator is hidden.
var bottomIsHidden: Bool {
return bottomConfiguration == nil
bottomConfiguration == nil
}
/// Determine if top separator is hidden.
var topIsHidden: Bool {
return topConfiguration == nil
topConfiguration == nil
}
/// Returns top configuration if type is top or full.

View File

@ -26,6 +26,6 @@ public extension SeparatorConfiguration {
/// Total height of separator top inset + height + bottom inset.
var totalHeight: CGFloat {
return height + insets.top + insets.bottom
height + insets.top + insets.bottom
}
}

View File

@ -67,9 +67,9 @@ public extension ViewText {
func size(maxWidth: CGFloat = CGFloat.greatestFiniteMagnitude,
maxHeight: CGFloat = CGFloat.greatestFiniteMagnitude) -> CGSize {
return attributedString.boundingRect(with: CGSize(width: maxWidth, height: maxHeight),
options: [.usesLineFragmentOrigin, .usesFontLeading],
context: nil).size
attributedString.boundingRect(with: CGSize(width: maxWidth, height: maxHeight),
options: [.usesLineFragmentOrigin, .usesFontLeading],
context: nil).size
}
/// Configures given ViewTextConfigurable instance.

View File

@ -27,5 +27,5 @@ import Foundation
/// - Parameter type: an class type
/// - Returns: string representation of class type
public func typeName<T>(of type: T.Type) -> String {
return String(describing: type)
String(describing: type)
}

View File

@ -35,6 +35,6 @@ public protocol AlertRepresentable {
public extension AlertRepresentable {
/// By default actionTitles contains single action title
var actionTitles: [String] {
return [actionTitle]
[actionTitle]
}
}

View File

@ -43,6 +43,6 @@ public protocol DrawingOperation {
extension DrawingOperation {
var opaque: Bool {
return false
false
}
}

View File

@ -30,7 +30,7 @@ public protocol LoadingIndicatorHolder: class {
public extension LoadingIndicatorHolder where Self: UIView {
var indicatorOwner: UIView {
return self
self
}
}

View File

@ -37,6 +37,6 @@ public extension ResettableType {
///
/// - Returns: resseted instance of self
func reset() -> Self {
return Self(resetFrom: self)
Self(resetFrom: self)
}
}

View File

@ -65,7 +65,7 @@ public extension SupportCompatible {
/// Support extensions.
static var support: Support<Self>.Type {
get {
return Support<Self>.self
Support<Self>.self
}
set { // swiftlint:disable:this unused_setter_value
// this enables using Support to "mutate" base type
@ -75,7 +75,7 @@ public extension SupportCompatible {
/// Support extensions.
var support: Support<Self> {
get {
return Support(self)
Support(self)
}
set { // swiftlint:disable:this unused_setter_value
// this enables using Support to "mutate" base object

View File

@ -30,7 +30,7 @@ public final class AnyPaginationWrappable: PaginationWrappable {
public var footerView: UIView? {
get {
return footerViewGetter()
footerViewGetter()
}
set {
footerViewSetter(newValue)
@ -39,7 +39,7 @@ public final class AnyPaginationWrappable: PaginationWrappable {
public var backgroundView: UIView? {
get {
return backgroundViewGetter()
backgroundViewGetter()
}
set {
backgroundViewSetter(newValue)

View File

@ -33,7 +33,7 @@ struct CALayerDrawingOperation: DrawingOperation {
}
public var contextSize: CGContextSize {
return size.ceiledContextSize
size.ceiledContextSize
}
public func apply(in context: CGContext) {

View File

@ -44,7 +44,7 @@ struct ImageDrawingOperation: DrawingOperation {
}
public var contextSize: CGContextSize {
return newSize.ceiledContextSize
newSize.ceiledContextSize
}
public func apply(in context: CGContext) {

View File

@ -42,7 +42,7 @@ struct RotateDrawingOperation: DrawingOperation {
}
public var contextSize: CGContextSize {
return translateRect.size.ceiledContextSize
translateRect.size.ceiledContextSize
}
public func apply(in context: CGContext) {

Some files were not shown because too many files have changed in this diff Show More