Skip to content

Commit

Permalink
Run swift-format
Browse files Browse the repository at this point in the history
  • Loading branch information
mbrandonw authored and github-actions[bot] committed Apr 29, 2024
1 parent e121b91 commit 8624a8e
Show file tree
Hide file tree
Showing 11 changed files with 73 additions and 72 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -496,8 +496,8 @@ private struct SummaryStep: View {
}
}

fileprivate extension Set {
subscript(contains element: Element) -> Bool {
extension Set {
fileprivate subscript(contains element: Element) -> Bool {
get { contains(element) }
set {
if newValue {
Expand Down
2 changes: 1 addition & 1 deletion Examples/SyncUps/SyncUps/AppFeature.swift
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ struct AppView: View {
@Shared(.syncUps) var syncUps = [
.mock,
.productMock,
.engineeringMock
.engineeringMock,
]
return AppView(
store: Store(initialState: AppFeature.State()) {
Expand Down
2 changes: 1 addition & 1 deletion Examples/SyncUps/SyncUps/SyncUpsList.swift
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ extension LabelStyle where Self == TrailingIconLabelStyle {
@Shared(.syncUps) var syncUps = [
.mock,
.productMock,
.engineeringMock
.engineeringMock,
]
return NavigationStack {
SyncUpsListView(
Expand Down
16 changes: 8 additions & 8 deletions Examples/SyncUps/SyncUpsTests/RecordMeetingTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ final class RecordMeetingTests: XCTestCase {
RecordMeeting()
} withDependencies: {
$0.continuousClock = clock
$0.date.now = Date(timeIntervalSince1970: 1234567890)
$0.date.now = Date(timeIntervalSince1970: 1_234_567_890)
$0.dismiss = DismissEffect {
dismissed.fulfill()
}
Expand Down Expand Up @@ -79,7 +79,7 @@ final class RecordMeetingTests: XCTestCase {
$0.syncUp.meetings.insert(
Meeting(
id: Meeting.ID(UUID(0)),
date: Date(timeIntervalSince1970: 1234567890),
date: Date(timeIntervalSince1970: 1_234_567_890),
transcript: ""
),
at: 0
Expand Down Expand Up @@ -117,7 +117,7 @@ final class RecordMeetingTests: XCTestCase {
RecordMeeting()
} withDependencies: {
$0.continuousClock = clock
$0.date.now = Date(timeIntervalSince1970: 1234567890)
$0.date.now = Date(timeIntervalSince1970: 1_234_567_890)
$0.dismiss = DismissEffect { dismissed.fulfill() }
$0.speechClient.authorizationStatus = { .authorized }
$0.speechClient.startTask = { @Sendable _ in
Expand Down Expand Up @@ -168,7 +168,7 @@ final class RecordMeetingTests: XCTestCase {
RecordMeeting()
} withDependencies: {
$0.continuousClock = clock
$0.date.now = Date(timeIntervalSince1970: 1234567890)
$0.date.now = Date(timeIntervalSince1970: 1_234_567_890)
$0.dismiss = DismissEffect { dismissed.fulfill() }
$0.speechClient.authorizationStatus = { .denied }
$0.uuid = .incrementing
Expand All @@ -190,7 +190,7 @@ final class RecordMeetingTests: XCTestCase {
$0.syncUp.meetings.insert(
Meeting(
id: Meeting.ID(UUID(0)),
date: Date(timeIntervalSince1970: 1234567890),
date: Date(timeIntervalSince1970: 1_234_567_890),
transcript: ""
),
at: 0
Expand Down Expand Up @@ -257,7 +257,7 @@ final class RecordMeetingTests: XCTestCase {
RecordMeeting()
} withDependencies: {
$0.continuousClock = clock
$0.date.now = Date(timeIntervalSince1970: 1234567890)
$0.date.now = Date(timeIntervalSince1970: 1_234_567_890)
$0.dismiss = DismissEffect { dismissed.fulfill() }
$0.speechClient.authorizationStatus = { .denied }
$0.uuid = .incrementing
Expand All @@ -284,7 +284,7 @@ final class RecordMeetingTests: XCTestCase {
$0.syncUp.meetings.insert(
Meeting(
id: Meeting.ID(UUID(0)),
date: Date(timeIntervalSince1970: 1234567890),
date: Date(timeIntervalSince1970: 1_234_567_890),
transcript: ""
),
at: 0
Expand Down Expand Up @@ -321,7 +321,7 @@ final class RecordMeetingTests: XCTestCase {
RecordMeeting()
} withDependencies: {
$0.continuousClock = clock
$0.date.now = Date(timeIntervalSince1970: 1234567890)
$0.date.now = Date(timeIntervalSince1970: 1_234_567_890)
$0.dismiss = DismissEffect { dismissed.fulfill() }
$0.speechClient.authorizationStatus = { .authorized }
$0.speechClient.startTask = { @Sendable _ in
Expand Down
58 changes: 29 additions & 29 deletions Sources/ComposableArchitecture/Reducer/Reducers/DebugReducer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -81,42 +81,42 @@ public struct _PrintChangesReducer<Base: Reducer>: Reducer {
self.printer = printer
}

#if DEBUG
public func reduce(
into state: inout Base.State, action: Base.Action
) -> Effect<Base.Action> {
if let printer = self.printer {
return withSharedChangeTracking { changeTracker in
let oldState = state
let effects = self.base.reduce(into: &state, action: action)
return withEscapedDependencies { continuation in
effects.merge(
with: .publisher { [newState = state, queue = printer.queue] in
Deferred<Empty<Action, Never>> {
queue.async {
continuation.yield {
changeTracker.assert {
printer.printChange(
receivedAction: action, oldState: oldState, newState: newState
)
#if DEBUG
public func reduce(
into state: inout Base.State, action: Base.Action
) -> Effect<Base.Action> {
if let printer = self.printer {
return withSharedChangeTracking { changeTracker in
let oldState = state
let effects = self.base.reduce(into: &state, action: action)
return withEscapedDependencies { continuation in
effects.merge(
with: .publisher { [newState = state, queue = printer.queue] in
Deferred<Empty<Action, Never>> {
queue.async {
continuation.yield {
changeTracker.assert {
printer.printChange(
receivedAction: action, oldState: oldState, newState: newState
)
}
}
}
return Empty()
}
return Empty()
}
}
)
)
}
}
}
return self.base.reduce(into: &state, action: action)
}
return self.base.reduce(into: &state, action: action)
}
#else
@inlinable
public func reduce(
into state: inout Base.State, action: Base.Action
) -> Effect<Base.Action> {
return self.base.reduce(into: &state, action: action)
}
@inlinable
public func reduce(
into state: inout Base.State, action: Base.Action
) -> Effect<Base.Action> {
return self.base.reduce(into: &state, action: action)
}
#endif
}
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ where Value.RawValue == Base.Value {
) -> Value? {
base.loadValue(from: store, at: key, default: defaultValue?.rawValue)
.flatMap(Value.init(rawValue:))
?? defaultValue
?? defaultValue
}
func saveValue(_ newValue: Value, to store: UserDefaults, at key: String) {
base.saveValue(newValue.rawValue, to: store, at: key)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ extension Shared {
) where Value == Wrapped? {
self.init(wrappedValue: nil, persistenceKey, fileID: fileID, line: line)
}

@_disfavoredOverload
public init(
_ persistenceKey: some PersistenceKey<Value>,
Expand Down Expand Up @@ -137,7 +137,7 @@ extension SharedReader {
}
self.init(wrappedValue: initialValue, persistenceKey, fileID: fileID, line: line)
}

public init<Key: PersistenceReaderKey>(
_ persistenceKey: PersistenceKeyDefault<Key>,
fileID: StaticString = #fileID,
Expand Down
4 changes: 2 additions & 2 deletions Sources/ComposableArchitecture/SharedState/Shared.swift
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public struct Shared<Value> {
return Shared<Member>(
reference: self.reference,
keyPath: self.keyPath.appending(
path: keyPath.appending(path: \.[default: DefaultSubscript(initialValue)])
path: keyPath.appending(path: \.[default:DefaultSubscript(initialValue)])
)!
)
}
Expand Down Expand Up @@ -366,7 +366,7 @@ extension Shared {
return SharedReader<Member>(
reference: self.reference,
keyPath: self.keyPath.appending(
path: keyPath.appending(path: \.[default: DefaultSubscript(initialValue)])
path: keyPath.appending(path: \.[default:DefaultSubscript(initialValue)])
)!
)
}
Expand Down
22 changes: 11 additions & 11 deletions Sources/ComposableArchitecture/SharedState/SharedReader.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#if canImport(Combine)
import Combine
import Combine
#endif

/// A property wrapper type that shares a value with multiple parts of an application.
Expand Down Expand Up @@ -74,17 +74,17 @@ public struct SharedReader<Value> {
)
}

#if canImport(Combine)
// TODO: Should this be wrapped in a type we own instead of `AnyPublisher`?
public var publisher: AnyPublisher<Value, Never> {
func open<R: Reference>(_ reference: R) -> AnyPublisher<Value, Never> {
return reference.publisher
.compactMap { $0[keyPath: self.keyPath] as? Value }
.eraseToAnyPublisher()
#if canImport(Combine)
// TODO: Should this be wrapped in a type we own instead of `AnyPublisher`?
public var publisher: AnyPublisher<Value, Never> {
func open<R: Reference>(_ reference: R) -> AnyPublisher<Value, Never> {
return reference.publisher
.compactMap { $0[keyPath: self.keyPath] as? Value }
.eraseToAnyPublisher()
}
return open(self.reference)
}
return open(self.reference)
}
#endif
#endif
}

extension SharedReader: @unchecked Sendable where Value: Sendable {}
Expand Down
27 changes: 14 additions & 13 deletions Sources/ComposableArchitecture/TestStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1080,13 +1080,13 @@ extension TestStore where State: Equatable {
let difference = self.withExhaustivity(.on) {
diff(expected, actual, format: .proportional)
.map { "\($0.indent(by: 4))\n\n(Expected: −, Actual: +)" }
?? """
Expected:
\(String(describing: expected).indent(by: 2))
?? """
Expected:
\(String(describing: expected).indent(by: 2))
Actual:
\(String(describing: actual).indent(by: 2))
"""
Actual:
\(String(describing: actual).indent(by: 2))
"""
}
let messageHeading =
!preamble.isEmpty
Expand Down Expand Up @@ -1148,13 +1148,13 @@ extension TestStore where State: Equatable, Action: Equatable {
TaskResultDebugging.$emitRuntimeWarnings.withValue(false) {
diff(expectedAction, receivedAction, format: .proportional)
.map { "\($0.indent(by: 4))\n\n(Expected: −, Received: +)" }
?? """
Expected:
\(String(describing: expectedAction).indent(by: 2))
?? """
Expected:
\(String(describing: expectedAction).indent(by: 2))
Received:
\(String(describing: receivedAction).indent(by: 2))
"""
Received:
\(String(describing: receivedAction).indent(by: 2))
"""
}
},
updateStateToExpectedResult,
Expand Down Expand Up @@ -2568,7 +2568,8 @@ extension TestStore {
@available(
*,
unavailable,
message: "Provide a key path to the case you expect to receive (like 'store.receive(\\.tap)'), or conform 'Action' to 'Equatable' to assert against it directly."
message:
"Provide a key path to the case you expect to receive (like 'store.receive(\\.tap)'), or conform 'Action' to 'Equatable' to assert against it directly."
)
public func receive(
_ expectedAction: Action,
Expand Down
4 changes: 2 additions & 2 deletions Tests/ComposableArchitectureTests/FileStorageTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ final class FileStorageTests: XCTestCase {
.blob,
.blobJr,
.blobSr,
.blobEsq
.blobEsq,
]
)
}
Expand Down Expand Up @@ -82,7 +82,7 @@ final class FileStorageTests: XCTestCase {

func testWillTerminate() throws {
guard let willTerminateNotificationName else { return }

let fileSystem = LockIsolated<[URL: Data]>([:])
let testScheduler = DispatchQueue.test
try withDependencies {
Expand Down

0 comments on commit 8624a8e

Please sign in to comment.