diff --git a/Examples/CaseStudies/SwiftUICaseStudies/02-SharedState-Onboarding.swift b/Examples/CaseStudies/SwiftUICaseStudies/02-SharedState-Onboarding.swift index 06f046d5aa66..a1f7ea5c3c82 100644 --- a/Examples/CaseStudies/SwiftUICaseStudies/02-SharedState-Onboarding.swift +++ b/Examples/CaseStudies/SwiftUICaseStudies/02-SharedState-Onboarding.swift @@ -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 { diff --git a/Examples/SyncUps/SyncUps/AppFeature.swift b/Examples/SyncUps/SyncUps/AppFeature.swift index d9d70dc37775..be884c90bf09 100644 --- a/Examples/SyncUps/SyncUps/AppFeature.swift +++ b/Examples/SyncUps/SyncUps/AppFeature.swift @@ -73,7 +73,7 @@ struct AppView: View { @Shared(.syncUps) var syncUps = [ .mock, .productMock, - .engineeringMock + .engineeringMock, ] return AppView( store: Store(initialState: AppFeature.State()) { diff --git a/Examples/SyncUps/SyncUps/SyncUpsList.swift b/Examples/SyncUps/SyncUps/SyncUpsList.swift index df9da6dd8e44..639b249aa46a 100644 --- a/Examples/SyncUps/SyncUps/SyncUpsList.swift +++ b/Examples/SyncUps/SyncUps/SyncUpsList.swift @@ -158,7 +158,7 @@ extension LabelStyle where Self == TrailingIconLabelStyle { @Shared(.syncUps) var syncUps = [ .mock, .productMock, - .engineeringMock + .engineeringMock, ] return NavigationStack { SyncUpsListView( diff --git a/Examples/SyncUps/SyncUpsTests/RecordMeetingTests.swift b/Examples/SyncUps/SyncUpsTests/RecordMeetingTests.swift index e82478dd1057..d735094122ee 100644 --- a/Examples/SyncUps/SyncUpsTests/RecordMeetingTests.swift +++ b/Examples/SyncUps/SyncUpsTests/RecordMeetingTests.swift @@ -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() } @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 diff --git a/Sources/ComposableArchitecture/Reducer/Reducers/DebugReducer.swift b/Sources/ComposableArchitecture/Reducer/Reducers/DebugReducer.swift index a8c8c66f6d09..07bdc53accd9 100644 --- a/Sources/ComposableArchitecture/Reducer/Reducers/DebugReducer.swift +++ b/Sources/ComposableArchitecture/Reducer/Reducers/DebugReducer.swift @@ -81,42 +81,42 @@ public struct _PrintChangesReducer: Reducer { self.printer = printer } -#if DEBUG - public func reduce( - into state: inout Base.State, action: Base.Action - ) -> Effect { - 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> { - 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 { + 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> { + 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 { - return self.base.reduce(into: &state, action: action) - } + @inlinable + public func reduce( + into state: inout Base.State, action: Base.Action + ) -> Effect { + return self.base.reduce(into: &state, action: action) + } #endif } diff --git a/Sources/ComposableArchitecture/SharedState/PersistenceKey/AppStorageKey.swift b/Sources/ComposableArchitecture/SharedState/PersistenceKey/AppStorageKey.swift index 6430bc5defc9..498a67793110 100644 --- a/Sources/ComposableArchitecture/SharedState/PersistenceKey/AppStorageKey.swift +++ b/Sources/ComposableArchitecture/SharedState/PersistenceKey/AppStorageKey.swift @@ -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) diff --git a/Sources/ComposableArchitecture/SharedState/References/ValueReference.swift b/Sources/ComposableArchitecture/SharedState/References/ValueReference.swift index a0167e5433c5..ab09fd749249 100644 --- a/Sources/ComposableArchitecture/SharedState/References/ValueReference.swift +++ b/Sources/ComposableArchitecture/SharedState/References/ValueReference.swift @@ -45,7 +45,7 @@ extension Shared { ) where Value == Wrapped? { self.init(wrappedValue: nil, persistenceKey, fileID: fileID, line: line) } - + @_disfavoredOverload public init( _ persistenceKey: some PersistenceKey, @@ -137,7 +137,7 @@ extension SharedReader { } self.init(wrappedValue: initialValue, persistenceKey, fileID: fileID, line: line) } - + public init( _ persistenceKey: PersistenceKeyDefault, fileID: StaticString = #fileID, diff --git a/Sources/ComposableArchitecture/SharedState/Shared.swift b/Sources/ComposableArchitecture/SharedState/Shared.swift index 94624ac2c5ed..380adc80b753 100644 --- a/Sources/ComposableArchitecture/SharedState/Shared.swift +++ b/Sources/ComposableArchitecture/SharedState/Shared.swift @@ -125,7 +125,7 @@ public struct Shared { return Shared( reference: self.reference, keyPath: self.keyPath.appending( - path: keyPath.appending(path: \.[default: DefaultSubscript(initialValue)]) + path: keyPath.appending(path: \.[default:DefaultSubscript(initialValue)]) )! ) } @@ -366,7 +366,7 @@ extension Shared { return SharedReader( reference: self.reference, keyPath: self.keyPath.appending( - path: keyPath.appending(path: \.[default: DefaultSubscript(initialValue)]) + path: keyPath.appending(path: \.[default:DefaultSubscript(initialValue)]) )! ) } diff --git a/Sources/ComposableArchitecture/SharedState/SharedReader.swift b/Sources/ComposableArchitecture/SharedState/SharedReader.swift index 54698248ab4d..5b019dee5731 100644 --- a/Sources/ComposableArchitecture/SharedState/SharedReader.swift +++ b/Sources/ComposableArchitecture/SharedState/SharedReader.swift @@ -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. @@ -74,17 +74,17 @@ public struct SharedReader { ) } -#if canImport(Combine) - // TODO: Should this be wrapped in a type we own instead of `AnyPublisher`? - public var publisher: AnyPublisher { - func open(_ reference: R) -> AnyPublisher { - 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 { + func open(_ reference: R) -> AnyPublisher { + 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 {} diff --git a/Sources/ComposableArchitecture/TestStore.swift b/Sources/ComposableArchitecture/TestStore.swift index 0ea026c25b2e..c57caf5ca81d 100644 --- a/Sources/ComposableArchitecture/TestStore.swift +++ b/Sources/ComposableArchitecture/TestStore.swift @@ -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 @@ -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, @@ -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, diff --git a/Tests/ComposableArchitectureTests/FileStorageTests.swift b/Tests/ComposableArchitectureTests/FileStorageTests.swift index 46aa2d2f76bf..111f6b83dd47 100644 --- a/Tests/ComposableArchitectureTests/FileStorageTests.swift +++ b/Tests/ComposableArchitectureTests/FileStorageTests.swift @@ -50,7 +50,7 @@ final class FileStorageTests: XCTestCase { .blob, .blobJr, .blobSr, - .blobEsq + .blobEsq, ] ) } @@ -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 {