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

Fix all swiftlint warnings #1085

Merged
merged 2 commits into from
Sep 14, 2023
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
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