Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Swiftlint #128

Merged
merged 6 commits into from
Dec 12, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
included:
- Source
- Tests
disabled_rules:
- line_length
- trailing_comma
identifier_name:
min_length: 1
opt_in_rules:
- file_header
type_name:
excluded: T
function_body_length: 100
type_body_length: 500
cyclomatic_complexity:
warning: 15
error: 25
file_header:
required_pattern: |
\/\/
\/\/ .*?\.swift
\/\/ RxSwiftExt
\/\/
\/\/ Created by .*? on \d{1,2}\/\d{1,2}\/(\d{2}|\d{4})\.
\/\/ Copyright © \d{4} RxSwift Community\. All rights reserved\.
\/\/
6 changes: 5 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,16 @@ os: osx
language: objective-c
osx_image: xcode9

install:
- brew update > /dev/null
- brew upgrade swiftlint

before_script:
- swiftlint
- carthage version
- carthage bootstrap

script:
- set -o pipefail && xcodebuild test -scheme RxSwiftExt-macOS -workspace RxSwiftExt.xcworkspace -sdk macosx -destination "arch=x86_64" | xcpretty -c
- set -o pipefail && xcodebuild test -scheme RxSwiftExt-iOS -workspace RxSwiftExt.xcworkspace -sdk iphonesimulator -destination "name=iPhone X" | xcpretty -c
- set -o pipefail && xcodebuild test -scheme RxSwiftExt-tvOS -workspace RxSwiftExt.xcworkspace -sdk appletvsimulator -destination "name=Apple TV 1080p" | xcpretty -c

304 changes: 152 additions & 152 deletions RxSwiftExt.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Source/RxCocoa/distinct+RxCocoa.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// RxSwiftExt
//
// Created by Rafael Ferreira on 3/8/17.
// Copyright © 2017 RxSwiftCommunity. All rights reserved.
// Copyright © 2017 RxSwift Community. All rights reserved.
//

import RxCocoa
Expand Down
4 changes: 2 additions & 2 deletions Source/RxCocoa/mapTo+RxCocoa.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//
// mapTo+RxCocoa.swift
// RxSwiftExtDemo
// RxSwiftExt
//
// Created by Rafael Ferreira on 3/7/17.
// Copyright © 2017 RxSwift Community. All rights reserved.
Expand All @@ -19,7 +19,7 @@ extension SharedSequenceConvertibleType {
public func mapTo<R>(_ value: R) -> SharedSequence<SharingStrategy, R> {
return map { _ in value }
}

public func map<R>(to value: R) -> SharedSequence<SharingStrategy, R> {
return map { _ in value }
}
Expand Down
2 changes: 1 addition & 1 deletion Source/RxCocoa/not+RxCocoa.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// RxSwiftExt
//
// Created by Rafael Ferreira on 3/7/17.
// Copyright © 2017 RxSwiftCommunity. All rights reserved.
// Copyright © 2017 RxSwift Community. All rights reserved.
//

import RxCocoa
Expand Down
40 changes: 17 additions & 23 deletions Source/RxSwift/ObservableType+Weak.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//
// ObservableType+Weak.swift
// RxSwiftExtDemo
// RxSwiftExt
//
// Created by Ian Keen on 17/04/2016.
// Copyright © 2016 RxSwift Community. All rights reserved.
Expand All @@ -22,26 +22,25 @@ extension ObservableType {
method?(obj)(value)
}
}

fileprivate func weakify<A: AnyObject>(_ obj: A, method: ((A) -> () -> Void)?) -> (() -> Void) {
return { [weak obj] in
guard let obj = obj else { return }
method?(obj)()
}
}

/**
Subscribes an event handler to an observable sequence.

- parameter weak: Weakly referenced object containing the target function.
- parameter on: Function to invoke on `weak` for each event in the observable sequence.
- returns: Subscription object used to unsubscribe from the observable sequence.
*/

public func subscribe<A: AnyObject>(weak obj: A, _ on: @escaping (A) -> (RxSwift.Event<Self.E>) -> Void) -> Disposable {
return self.subscribe(weakify(obj, method: on))
}

/**
Subscribes an element handler, an error handler, a completion handler and disposed handler to an observable sequence.

Expand All @@ -53,23 +52,21 @@ extension ObservableType {
gracefully completed, errored, or if the generation is cancelled by disposing subscription)
- returns: Subscription object used to unsubscribe from the observable sequence.
*/

public func subscribe<A: AnyObject>(
weak obj: A,
onNext: ((A) -> (Self.E) -> Void)? = nil,
onError: ((A) -> (Error) -> Void)? = nil,
onCompleted: ((A) -> () -> Void)? = nil,
onDisposed: ((A) -> () -> Void)? = nil) -> Disposable {
weak obj: A,
onNext: ((A) -> (Self.E) -> Void)? = nil,
onError: ((A) -> (Error) -> Void)? = nil,
onCompleted: ((A) -> () -> Void)? = nil,
onDisposed: ((A) -> () -> Void)? = nil)
-> Disposable {
let disposable: Disposable

if let disposed = onDisposed {
disposable = Disposables.create(with: weakify(obj, method: disposed))
}
else {
} else {
disposable = Disposables.create()
}

let observer = AnyObserver { [weak obj] (e: RxSwift.Event<Self.E>) in
guard let obj = obj else { return }
switch e {
Expand All @@ -83,42 +80,39 @@ extension ObservableType {
disposable.dispose()
}
}

return Disposables.create(self.asObservable().subscribe(observer), disposable)
}

/**
Subscribes an element handler to an observable sequence.

- parameter weak: Weakly referenced object containing the target function.
- parameter onNext: Function to invoke on `weak` for each element in the observable sequence.
- returns: Subscription object used to unsubscribe from the observable sequence.
*/

public func subscribeNext<A: AnyObject>(weak obj: A, _ onNext: @escaping (A) -> (Self.E) -> Void) -> Disposable {
return self.subscribe(onNext: weakify(obj, method: onNext))
}

/**
Subscribes an error handler to an observable sequence.

- parameter weak: Weakly referenced object containing the target function.
- parameter onError: Function to invoke on `weak` upon errored termination of the observable sequence.
- returns: Subscription object used to unsubscribe from the observable sequence.
*/

public func subscribeError<A: AnyObject>(weak obj: A, _ onError: @escaping (A) -> (Error) -> Void) -> Disposable {
return self.subscribe(onError: weakify(obj, method: onError))
}

/**
Subscribes a completion handler to an observable sequence.

- parameter weak: Weakly referenced object containing the target function.
- parameter onCompleted: Function to invoke on `weak` graceful termination of the observable sequence.
- returns: Subscription object used to unsubscribe from the observable sequence.
*/

public func subscribeCompleted<A: AnyObject>(weak obj: A, _ onCompleted: @escaping (A) -> () -> Void) -> Disposable {
return self.subscribe(onCompleted: weakify(obj, method: onCompleted))
}
Expand Down
5 changes: 3 additions & 2 deletions Source/RxSwift/and.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
// and.swift
// RxSwiftExt
//
// Created by Florent Pillet on 26/11/17
// Copyright © 2017 RxSwiftCommunity. All rights reserved.
// Created by Florent Pillet on 26/11/17.
// Copyright © 2017 RxSwift Community. All rights reserved.
//

import Foundation
import RxSwift

Expand Down
2 changes: 1 addition & 1 deletion Source/RxSwift/apply.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// RxSwiftExt
//
// Created by Andy Chou on 2/22/17.
// Copyright © 2017 RxSwiftCommunity. All rights reserved.
// Copyright © 2017 RxSwift Community. All rights reserved.
//

import Foundation
Expand Down
Loading