Skip to content

Commit

Permalink
Merge pull request #33 from erwald/fix-swiftlint-violations
Browse files Browse the repository at this point in the history
Fix swiftlint violations
  • Loading branch information
mdiep authored Jul 19, 2017
2 parents 332f39d + e352924 commit 9253284
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 22 deletions.
4 changes: 4 additions & 0 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
disabled_rules:
- large_tuple
excluded:
- Carthage
6 changes: 3 additions & 3 deletions ReactiveObjCBridge/ObjectiveCBridging.swift
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ private func _bridgedSignalProducer<Value>(from signal: RACSignal<Value>, file:
observer.send(value: obj)
}

let failed: (_ error: Swift.Error?) -> () = { error in
let failed: (_ error: Swift.Error?) -> Void = { error in
observer.send(error: AnyError(error ?? defaultNSError("Nil RACSignal error", file: file, line: line)))
}

Expand Down Expand Up @@ -259,7 +259,7 @@ extension SignalProducerProtocol where Value: OptionalProtocol, Value.Wrapped: A
break
}
}

return RACDisposable {
selfDisposable.dispose()
}
Expand Down Expand Up @@ -318,7 +318,7 @@ extension SignalProtocol where Value: OptionalProtocol, Value.Wrapped: AnyObject
break
}
}

return RACDisposable {
selfDisposable?.dispose()
}
Expand Down
34 changes: 17 additions & 17 deletions ReactiveObjCBridgeTests/ObjectiveCBridgingSpec.swift
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class ObjectiveCBridgingSpec: QuickSpec {
expect((producer.single())?.value) == 2
}

it("should forward errors") {
it("should forward errors") {
let error = TestError.default

let racSignal = RACSignal<AnyObject>.error(error)
Expand Down Expand Up @@ -133,30 +133,30 @@ class ObjectiveCBridgingSpec: QuickSpec {
observer.send(error: expectedError)
expect(error) == expectedError
}

it("should maintain userInfo on NSError") {
let (signal, observer) = Signal<AnyObject, NSError>.pipe()
let racSignal = signal.toRACSignal()

var error: String?

racSignal.subscribeError {
error = $0?.localizedDescription
return
}

observer.send(error: testNSError)

expect(error) == userInfo[key]
}

it("should bridge next events with value Optional<Any>.none to nil in Objective-C") {
let (signal, observer) = Signal<Optional<AnyObject>, NSError>.pipe()
let racSignal = signal.toRACSignal().replay().materialize()

observer.send(value: nil)
observer.sendCompleted()

let event = racSignal.first()
expect(event?.value).to(beNil())
}
Expand Down Expand Up @@ -187,20 +187,20 @@ class ObjectiveCBridgingSpec: QuickSpec {
let event = racSignal.first()
expect(event?.error as? NSError) == TestError.error1 as NSError
}

it("should maintain userInfo on NSError") {
let producer = SignalProducer<AnyObject, NSError>(error: testNSError)
let racSignal = producer.toRACSignal().materialize()

let event = racSignal.first()
let userInfoValue = event?.error?.localizedDescription
expect(userInfoValue) == userInfo[key]
}

it("should bridge next events with value Optional<AnyObject>.none to nil in Objective-C") {
let producer = SignalProducer<Optional<AnyObject>, NSError>(value: nil)
let racSignal = producer.toRACSignal().materialize()

let event = racSignal.first()
expect(event?.value).to(beNil())
}
Expand Down Expand Up @@ -281,7 +281,7 @@ class ObjectiveCBridgingSpec: QuickSpec {

var command: RACCommand<NSNumber, NSString>!
var enabled = false

beforeEach {
results = []
enabledProperty = MutableProperty(true)
Expand Down Expand Up @@ -331,7 +331,7 @@ class ObjectiveCBridgingSpec: QuickSpec {
var action: Action<Optional<AnyObject>, Optional<AnyObject>, TestError>!
var command: RACCommand<AnyObject, AnyObject>!

action = Action() { input in
action = Action { input in
return SignalProducer(value: input)
}

Expand All @@ -350,7 +350,7 @@ class ObjectiveCBridgingSpec: QuickSpec {
var action: Action<NSString, Optional<AnyObject>, TestError>!
var command: RACCommand<NSString, AnyObject>!

action = Action() { input in
action = Action { _ in
return SignalProducer(value: Optional<AnyObject>.none)
}

Expand Down Expand Up @@ -378,7 +378,7 @@ class ObjectiveCBridgingSpec: QuickSpec {
.replay()
.materialize()

action = Action() { input in
action = Action { input in
inputSubject.sendNext(input)
return SignalProducer(value: "result")
}
Expand All @@ -392,15 +392,15 @@ class ObjectiveCBridgingSpec: QuickSpec {
expect(event.value).to(beNil())
}
}

describe("RACSubscriber.sendNext") {
it("should have an argument of type Optional.none represented as `nil`") {
let racSignal = RACSignal<AnyObject>.createSignal { subscriber in
subscriber.sendNext(Optional<AnyObject>.none)
subscriber.sendCompleted()
return nil
}

let event = try! racSignal.materialize().asynchronousFirstOrDefault(nil, success: nil)
let value = event.value
expect(value).to(beNil())
Expand Down
2 changes: 0 additions & 2 deletions ReactiveObjCBridgeTests/TestError.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ extension AnyError: Equatable {
}
}


internal extension SignalProducerProtocol {
/// Halts if an error is emitted in the receiver signal.
/// This is useful in tests to be able to just use `startWithNext`
Expand All @@ -47,4 +46,3 @@ internal extension SignalProtocol {
}
}
}

0 comments on commit 9253284

Please sign in to comment.