Skip to content

Commit

Permalink
Fix all swiftlint warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
younata committed Sep 13, 2023
1 parent 3f9773e commit 8528046
Show file tree
Hide file tree
Showing 20 changed files with 181 additions and 169 deletions.
17 changes: 10 additions & 7 deletions Sources/Nimble/DSL+AsyncAwait.swift
Original file line number Diff line number Diff line change
Expand Up @@ -117,15 +117,18 @@ private func throwableUntil(
line: UInt = #line,
action: @escaping (@escaping () -> Void) async throws -> Void) async {
let leeway = timeout.divided
let result = await performBlock(timeoutInterval: timeout, leeway: leeway, file: file, line: line) { @MainActor (done: @escaping (ErrorResult) -> Void) async throws -> Void in
do {
try await action {
done(.none)
let result = await performBlock(
timeoutInterval: timeout,
leeway: leeway,
file: file, line: line) { @MainActor (done: @escaping (ErrorResult) -> Void) async throws -> Void in
do {
try await action {
done(.none)
}
} catch let e {
done(.error(e))
}
} catch let e {
done(.error(e))
}
}

switch result {
case .incomplete: internalError("Reached .incomplete state for waitUntil(...).")
Expand Down
2 changes: 1 addition & 1 deletion Sources/Nimble/DSL+Wait.swift
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ internal func blockedRunLoopErrorMessageFor(_ fnName: String, leeway: NimbleTime
///
/// This function manages the main run loop (`NSRunLoop.mainRunLoop()`) while this function
/// is executing. Any attempts to touch the run loop may cause non-deterministic behavior.
@available(*, noasync, message: "the sync version of `waitUntil` does not work in async contexts. Use the async version with the same name as a drop-in replacement")
@available(*, noasync, message: "the sync variant of `waitUntil` does not work in async contexts. Use the async variant as a drop-in replacement")
public func waitUntil(timeout: NimbleTimeInterval = PollingDefaults.timeout, file: FileString = #file, line: UInt = #line, action: @escaping (@escaping () -> Void) -> Void) {
NMBWait.until(timeout: timeout, file: file, line: line, action: action)
}
Expand Down
6 changes: 3 additions & 3 deletions Sources/Nimble/Matchers/AsyncPredicate.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
public protocol AsyncablePredicate<T> {
associatedtype T
func satisfies(_ expression: AsyncExpression<T>) async throws -> PredicateResult
public protocol AsyncablePredicate<Value> {
associatedtype Value
func satisfies(_ expression: AsyncExpression<Value>) async throws -> PredicateResult
}

extension Predicate: AsyncablePredicate {
Expand Down
32 changes: 16 additions & 16 deletions Sources/Nimble/Matchers/BeCloseTo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -122,59 +122,59 @@ public func beCloseTo<Value: FloatingPoint, Values: Collection>(
infix operator : ComparisonPrecedence

// swiftlint:disable identifier_name
public func <Value>(lhs: SyncExpectation<Value>, rhs: Value) where Value: Collection, Value.Element: FloatingPoint {
public func <Value>(lhs: SyncExpectation<Value>, rhs: Value) where Value: Collection, Value.Element: FloatingPoint {
lhs.to(beCloseTo(rhs))
}

public func <Value>(lhs: AsyncExpectation<Value>, rhs: Value) async where Value: Collection, Value.Element: FloatingPoint {
public func <Value>(lhs: AsyncExpectation<Value>, rhs: Value) async where Value: Collection, Value.Element: FloatingPoint {
await lhs.to(beCloseTo(rhs))
}

public func <Value: FloatingPoint>(lhs: SyncExpectation<Value>, rhs: Value) {
public func <Value: FloatingPoint>(lhs: SyncExpectation<Value>, rhs: Value) {
lhs.to(beCloseTo(rhs))
}

public func <Value: FloatingPoint>(lhs: AsyncExpectation<Value>, rhs: Value) async {
public func <Value: FloatingPoint>(lhs: AsyncExpectation<Value>, rhs: Value) async {
await lhs.to(beCloseTo(rhs))
}

public func <Value: FloatingPoint>(lhs: SyncExpectation<Value>, rhs: (expected: Value, delta: Value)) {
public func <Value: FloatingPoint>(lhs: SyncExpectation<Value>, rhs: (expected: Value, delta: Value)) {
lhs.to(beCloseTo(rhs.expected, within: rhs.delta))
}

public func <Value: FloatingPoint>(lhs: AsyncExpectation<Value>, rhs: (expected: Value, delta: Value)) async {
public func <Value: FloatingPoint>(lhs: AsyncExpectation<Value>, rhs: (expected: Value, delta: Value)) async {
await lhs.to(beCloseTo(rhs.expected, within: rhs.delta))
}

public func ==<Value: FloatingPoint>(lhs: SyncExpectation<Value>, rhs: (expected: Value, delta: Value)) {
public func == <Value: FloatingPoint>(lhs: SyncExpectation<Value>, rhs: (expected: Value, delta: Value)) {
lhs.to(beCloseTo(rhs.expected, within: rhs.delta))
}

public func ==<Value: FloatingPoint>(lhs: AsyncExpectation<Value>, rhs: (expected: Value, delta: Value)) async {
public func == <Value: FloatingPoint>(lhs: AsyncExpectation<Value>, rhs: (expected: Value, delta: Value)) async {
await lhs.to(beCloseTo(rhs.expected, within: rhs.delta))
}

public func <Value: NMBDoubleConvertible>(lhs: SyncExpectation<Value>, rhs: Value) {
public func <Value: NMBDoubleConvertible>(lhs: SyncExpectation<Value>, rhs: Value) {
lhs.to(beCloseTo(rhs))
}

public func <Value: NMBDoubleConvertible>(lhs: AsyncExpectation<Value>, rhs: Value) async {
public func <Value: NMBDoubleConvertible>(lhs: AsyncExpectation<Value>, rhs: Value) async {
await lhs.to(beCloseTo(rhs))
}

public func <Value: NMBDoubleConvertible>(lhs: SyncExpectation<Value>, rhs: (expected: Value, delta: Double)) {
public func <Value: NMBDoubleConvertible>(lhs: SyncExpectation<Value>, rhs: (expected: Value, delta: Double)) {
lhs.to(beCloseTo(rhs.expected, within: rhs.delta))
}

public func <Value: NMBDoubleConvertible>(lhs: AsyncExpectation<Value>, rhs: (expected: Value, delta: Double)) async {
public func <Value: NMBDoubleConvertible>(lhs: AsyncExpectation<Value>, rhs: (expected: Value, delta: Double)) async {
await lhs.to(beCloseTo(rhs.expected, within: rhs.delta))
}

public func ==<Value: NMBDoubleConvertible>(lhs: SyncExpectation<Value>, rhs: (expected: Value, delta: Double)) {
public func == <Value: NMBDoubleConvertible>(lhs: SyncExpectation<Value>, rhs: (expected: Value, delta: Double)) {
lhs.to(beCloseTo(rhs.expected, within: rhs.delta))
}

public func ==<Value: NMBDoubleConvertible>(lhs: AsyncExpectation<Value>, rhs: (expected: Value, delta: Double)) async {
public func == <Value: NMBDoubleConvertible>(lhs: AsyncExpectation<Value>, rhs: (expected: Value, delta: Double)) async {
await lhs.to(beCloseTo(rhs.expected, within: rhs.delta))
}

Expand All @@ -185,10 +185,10 @@ precedencegroup PlusMinusOperatorPrecedence {
}

infix operator ± : PlusMinusOperatorPrecedence
public func ±<Value: FloatingPoint>(lhs: Value, rhs: Value) -> (expected: Value, delta: Value) {
public func ± <Value: FloatingPoint>(lhs: Value, rhs: Value) -> (expected: Value, delta: Value) {
return (expected: lhs, delta: rhs)
}
public func ±<Value: NMBDoubleConvertible>(lhs: Value, rhs: Double) -> (expected: Value, delta: Double) {
public func ± <Value: NMBDoubleConvertible>(lhs: Value, rhs: Double) -> (expected: Value, delta: Double) {
return (expected: lhs, delta: rhs)
}

Expand Down
8 changes: 4 additions & 4 deletions Sources/Nimble/Matchers/BeGreaterThan.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ public func beGreaterThan<T: Comparable>(_ expectedValue: T?) -> Predicate<T> {
}
}

public func ><T: Comparable>(lhs: SyncExpectation<T>, rhs: T) {
public func > <T: Comparable>(lhs: SyncExpectation<T>, rhs: T) {
lhs.to(beGreaterThan(rhs))
}

public func ><T: Comparable>(lhs: AsyncExpectation<T>, rhs: T) async {
public func > <T: Comparable>(lhs: AsyncExpectation<T>, rhs: T) async {
await lhs.to(beGreaterThan(rhs))
}

Expand All @@ -30,11 +30,11 @@ public func beGreaterThan<T: NMBComparable>(_ expectedValue: T?) -> Predicate<T>
}
}

public func ><T: NMBComparable>(lhs: SyncExpectation<T>, rhs: T?) {
public func > <T: NMBComparable>(lhs: SyncExpectation<T>, rhs: T?) {
lhs.to(beGreaterThan(rhs))
}

public func ><T: NMBComparable>(lhs: AsyncExpectation<T>, rhs: T?) async {
public func > <T: NMBComparable>(lhs: AsyncExpectation<T>, rhs: T?) async {
await lhs.to(beGreaterThan(rhs))
}

Expand Down
8 changes: 4 additions & 4 deletions Sources/Nimble/Matchers/BeGreaterThanOrEqualTo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ public func beGreaterThanOrEqualTo<T: Comparable>(_ expectedValue: T?) -> Predic
}
}

public func >=<T: Comparable>(lhs: SyncExpectation<T>, rhs: T) {
public func >= <T: Comparable>(lhs: SyncExpectation<T>, rhs: T) {
lhs.to(beGreaterThanOrEqualTo(rhs))
}

public func >=<T: Comparable>(lhs: AsyncExpectation<T>, rhs: T) async {
public func >= <T: Comparable>(lhs: AsyncExpectation<T>, rhs: T) async {
await lhs.to(beGreaterThanOrEqualTo(rhs))
}

Expand All @@ -31,11 +31,11 @@ public func beGreaterThanOrEqualTo<T: NMBComparable>(_ expectedValue: T?) -> Pre
}
}

public func >=<T: NMBComparable>(lhs: SyncExpectation<T>, rhs: T) {
public func >= <T: NMBComparable>(lhs: SyncExpectation<T>, rhs: T) {
lhs.to(beGreaterThanOrEqualTo(rhs))
}

public func >=<T: NMBComparable>(lhs: AsyncExpectation<T>, rhs: T) async {
public func >= <T: NMBComparable>(lhs: AsyncExpectation<T>, rhs: T) async {
await lhs.to(beGreaterThanOrEqualTo(rhs))
}

Expand Down
8 changes: 4 additions & 4 deletions Sources/Nimble/Matchers/BeIdenticalTo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,19 @@ public func beIdenticalTo(_ expected: AnyObject?) -> Predicate<AnyObject> {
}
}

public func ===(lhs: SyncExpectation<AnyObject>, rhs: AnyObject?) {
public func === (lhs: SyncExpectation<AnyObject>, rhs: AnyObject?) {
lhs.to(beIdenticalTo(rhs))
}

public func ===(lhs: AsyncExpectation<AnyObject>, rhs: AnyObject?) async {
public func === (lhs: AsyncExpectation<AnyObject>, rhs: AnyObject?) async {
await lhs.to(beIdenticalTo(rhs))
}

public func !==(lhs: SyncExpectation<AnyObject>, rhs: AnyObject?) {
public func !== (lhs: SyncExpectation<AnyObject>, rhs: AnyObject?) {
lhs.toNot(beIdenticalTo(rhs))
}

public func !==(lhs: AsyncExpectation<AnyObject>, rhs: AnyObject?) async {
public func !== (lhs: AsyncExpectation<AnyObject>, rhs: AnyObject?) async {
await lhs.toNot(beIdenticalTo(rhs))
}

Expand Down
8 changes: 4 additions & 4 deletions Sources/Nimble/Matchers/BeLessThan.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ public func beLessThan<T: Comparable>(_ expectedValue: T?) -> Predicate<T> {
}
}

public func <<V: Comparable>(lhs: SyncExpectation<V>, rhs: V) {
public func < <V: Comparable>(lhs: SyncExpectation<V>, rhs: V) {
lhs.to(beLessThan(rhs))
}

public func <<V: Comparable>(lhs: AsyncExpectation<V>, rhs: V) async {
public func < <V: Comparable>(lhs: AsyncExpectation<V>, rhs: V) async {
await lhs.to(beLessThan(rhs))
}

Expand All @@ -29,11 +29,11 @@ public func beLessThan<T: NMBComparable>(_ expectedValue: T?) -> Predicate<T> {
}
}

public func <<V: NMBComparable>(lhs: SyncExpectation<V>, rhs: V?) {
public func < <V: NMBComparable>(lhs: SyncExpectation<V>, rhs: V?) {
lhs.to(beLessThan(rhs))
}

public func <<V: NMBComparable>(lhs: AsyncExpectation<V>, rhs: V?) async {
public func < <V: NMBComparable>(lhs: AsyncExpectation<V>, rhs: V?) async {
await lhs.to(beLessThan(rhs))
}

Expand Down
8 changes: 4 additions & 4 deletions Sources/Nimble/Matchers/BeLessThanOrEqual.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ public func beLessThanOrEqualTo<T: Comparable>(_ expectedValue: T?) -> Predicate
}
}

public func <=<T: Comparable>(lhs: SyncExpectation<T>, rhs: T) {
public func <= <T: Comparable>(lhs: SyncExpectation<T>, rhs: T) {
lhs.to(beLessThanOrEqualTo(rhs))
}

public func <=<T: Comparable>(lhs: AsyncExpectation<T>, rhs: T) async {
public func <= <T: Comparable>(lhs: AsyncExpectation<T>, rhs: T) async {
await lhs.to(beLessThanOrEqualTo(rhs))
}

Expand All @@ -29,11 +29,11 @@ public func beLessThanOrEqualTo<T: NMBComparable>(_ expectedValue: T?) -> Predic
}
}

public func <=<T: NMBComparable>(lhs: SyncExpectation<T>, rhs: T) {
public func <= <T: NMBComparable>(lhs: SyncExpectation<T>, rhs: T) {
lhs.to(beLessThanOrEqualTo(rhs))
}

public func <=<T: NMBComparable>(lhs: AsyncExpectation<T>, rhs: T) async {
public func <= <T: NMBComparable>(lhs: AsyncExpectation<T>, rhs: T) async {
await lhs.to(beLessThanOrEqualTo(rhs))
}

Expand Down
8 changes: 4 additions & 4 deletions Sources/Nimble/Matchers/BeVoid.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@ public func beVoid() -> Predicate<()> {
}
}

public func ==(lhs: SyncExpectation<()>, rhs: ()) {
public func == (lhs: SyncExpectation<()>, rhs: ()) {
lhs.to(beVoid())
}

public func ==(lhs: AsyncExpectation<()>, rhs: ()) async {
public func == (lhs: AsyncExpectation<()>, rhs: ()) async {
await lhs.to(beVoid())
}

public func !=(lhs: SyncExpectation<()>, rhs: ()) {
public func != (lhs: SyncExpectation<()>, rhs: ()) {
lhs.toNot(beVoid())
}

public func !=(lhs: AsyncExpectation<()>, rhs: ()) async {
public func != (lhs: AsyncExpectation<()>, rhs: ()) async {
await lhs.toNot(beVoid())
}
Loading

0 comments on commit 8528046

Please sign in to comment.