From 0b89757eddcbd7c5cc85cb66c38b24f5a3660a5d Mon Sep 17 00:00:00 2001 From: Paul Beusterien Date: Fri, 29 Mar 2024 16:43:09 -0700 Subject: [PATCH] Update to SwiftFormat 0.53.5 --- .../FirebasePodTest/AppDelegate.swift | 1 + .../HeartbeatLogging/HeartbeatsBundle.swift | 12 +- .../Tests/Unit/HeartbeatStorageTests.swift | 1 + .../Internal/Tests/Unit/HeartbeatTests.swift | 2 +- .../Sources/FirebaseRemoteConfigSwift.swift | 1 + .../Sources/FirebaseSessions.swift | 8 +- .../Installations+InstallationsProtocol.swift | 1 + .../Tests/Unit/SessionStartEventTests.swift | 144 +++++++++--------- Mintfile | 2 +- 9 files changed, 85 insertions(+), 87 deletions(-) diff --git a/CoreOnly/Tests/FirebasePodTest/FirebasePodTest/AppDelegate.swift b/CoreOnly/Tests/FirebasePodTest/FirebasePodTest/AppDelegate.swift index 3efa934f05b..2c839d62da9 100644 --- a/CoreOnly/Tests/FirebasePodTest/FirebasePodTest/AppDelegate.swift +++ b/CoreOnly/Tests/FirebasePodTest/FirebasePodTest/AppDelegate.swift @@ -13,6 +13,7 @@ // limitations under the License. import Firebase + // Verify that the following Firebase Swift APIs can be found. import FirebaseAnalyticsSwift import FirebaseFirestoreSwift diff --git a/FirebaseCore/Internal/Sources/HeartbeatLogging/HeartbeatsBundle.swift b/FirebaseCore/Internal/Sources/HeartbeatLogging/HeartbeatsBundle.swift index a7db6a5e900..776dfb8ddbc 100644 --- a/FirebaseCore/Internal/Sources/HeartbeatLogging/HeartbeatsBundle.swift +++ b/FirebaseCore/Internal/Sources/HeartbeatLogging/HeartbeatsBundle.swift @@ -72,8 +72,8 @@ struct HeartbeatsBundle: Codable, HeartbeatsPayloadConvertible { } // Update cache with the new heartbeat's date. - heartbeat.timePeriods.forEach { - lastAddedHeartbeatDates[$0] = heartbeat.date + for timePeriod in heartbeat.timePeriods { + lastAddedHeartbeatDates[timePeriod] = heartbeat.date } } catch let error as RingBuffer.Error { @@ -98,8 +98,8 @@ struct HeartbeatsBundle: Codable, HeartbeatsPayloadConvertible { if case .success = secondPushAttempt { // Update cache with the new heartbeat's date. - diagnosticHeartbeat.timePeriods.forEach { - lastAddedHeartbeatDates[$0] = diagnosticHeartbeat.date + for timePeriod in diagnosticHeartbeat.timePeriods { + lastAddedHeartbeatDates[timePeriod] = diagnosticHeartbeat.date } } } catch { @@ -124,9 +124,9 @@ struct HeartbeatsBundle: Codable, HeartbeatsPayloadConvertible { poppedHeartbeats.append(poppedHeartbeat) } - poppedHeartbeats.reversed().forEach { + for poppedHeartbeat in poppedHeartbeats.reversed() { do { - try buffer.push($0) + try buffer.push(poppedHeartbeat) } catch { // Ignore error. } diff --git a/FirebaseCore/Internal/Tests/Unit/HeartbeatStorageTests.swift b/FirebaseCore/Internal/Tests/Unit/HeartbeatStorageTests.swift index 9f6dd0bf2d2..51d97672e70 100644 --- a/FirebaseCore/Internal/Tests/Unit/HeartbeatStorageTests.swift +++ b/FirebaseCore/Internal/Tests/Unit/HeartbeatStorageTests.swift @@ -14,6 +14,7 @@ @testable import FirebaseCoreInternal import XCTest + class HeartbeatStorageTests: XCTestCase { // MARK: - Instance Management diff --git a/FirebaseCore/Internal/Tests/Unit/HeartbeatTests.swift b/FirebaseCore/Internal/Tests/Unit/HeartbeatTests.swift index 5c2477c6809..f8933d59b85 100644 --- a/FirebaseCore/Internal/Tests/Unit/HeartbeatTests.swift +++ b/FirebaseCore/Internal/Tests/Unit/HeartbeatTests.swift @@ -21,7 +21,7 @@ class TimePeriodTests: XCTestCase { } func testTimeIntervals() throws { - TimePeriod.allCases.forEach { period in + for period in TimePeriod.allCases { XCTAssertEqual(period.timeInterval, Double(period.rawValue) * 86400) } } diff --git a/FirebaseRemoteConfigSwift/Sources/FirebaseRemoteConfigSwift.swift b/FirebaseRemoteConfigSwift/Sources/FirebaseRemoteConfigSwift.swift index 72997328e6f..2584f98566d 100644 --- a/FirebaseRemoteConfigSwift/Sources/FirebaseRemoteConfigSwift.swift +++ b/FirebaseRemoteConfigSwift/Sources/FirebaseRemoteConfigSwift.swift @@ -18,6 +18,7 @@ @_exported import enum FirebaseRemoteConfig.RemoteConfigCodableError @_exported import struct FirebaseRemoteConfig.RemoteConfigProperty + // The `@_exported` is needed to prevent breaking clients that are using // types prefixed with the `FirebaseRemoteConfigSwift` module name (e.g. // `FirebaseRemoteConfigSwift.RemoteConfigValueCodableError`). diff --git a/FirebaseSessions/Sources/FirebaseSessions.swift b/FirebaseSessions/Sources/FirebaseSessions.swift index 269cfb9061c..d6cd130102c 100644 --- a/FirebaseSessions/Sources/FirebaseSessions.swift +++ b/FirebaseSessions/Sources/FirebaseSessions.swift @@ -142,8 +142,8 @@ private enum GoogleDataTransportConfig { super.init() - SessionsDependencies.dependencies.forEach { subscriberName in - self.subscriberPromises[subscriberName] = Promise.pending() + for subscriberName in SessionsDependencies.dependencies { + subscriberPromises[subscriberName] = Promise.pending() } Logger @@ -226,10 +226,10 @@ private enum GoogleDataTransportConfig { } func addSubscriberFields(event: SessionStartEvent) { - subscribers.forEach { subscriber in + for subscriber in subscribers { event.set(subscriber: subscriber.sessionsSubscriberName, isDataCollectionEnabled: subscriber.isDataCollectionEnabled, - appInfo: self.appInfo) + appInfo: appInfo) } } diff --git a/FirebaseSessions/Sources/Installations+InstallationsProtocol.swift b/FirebaseSessions/Sources/Installations+InstallationsProtocol.swift index 17ab5569694..fcbf1231d6c 100644 --- a/FirebaseSessions/Sources/Installations+InstallationsProtocol.swift +++ b/FirebaseSessions/Sources/Installations+InstallationsProtocol.swift @@ -16,6 +16,7 @@ import Foundation @_implementationOnly import FirebaseInstallations + protocol InstallationsProtocol { var installationsWaitTimeInSecond: Int { get } diff --git a/FirebaseSessions/Tests/Unit/SessionStartEventTests.swift b/FirebaseSessions/Tests/Unit/SessionStartEventTests.swift index 94124f933a4..70713307ae1 100644 --- a/FirebaseSessions/Tests/Unit/SessionStartEventTests.swift +++ b/FirebaseSessions/Tests/Unit/SessionStartEventTests.swift @@ -159,11 +159,11 @@ class SessionStartEventTests: XCTestCase { ("something unknown", firebase_appquality_sessions_OsName_UNKNOWN_OSNAME), ] - expectations.forEach { (given: String, expected: firebase_appquality_sessions_OsName) in + for (given, expected) in expectations { appInfo.osName = given let event = SessionStartEvent( - sessionInfo: self.defaultSessionInfo, + sessionInfo: defaultSessionInfo, appInfo: appInfo, time: time ) @@ -188,17 +188,16 @@ class SessionStartEventTests: XCTestCase { ), ] - expectations.forEach { (given: DevEnvironment, - expected: firebase_appquality_sessions_LogEnvironment) in - appInfo.environment = given + for (given, expected) in expectations { + appInfo.environment = given - let event = SessionStartEvent( - sessionInfo: self.defaultSessionInfo, - appInfo: appInfo, - time: time - ) + let event = SessionStartEvent( + sessionInfo: defaultSessionInfo, + appInfo: appInfo, + time: time + ) - XCTAssertEqual(event.proto.application_info.log_environment, expected) + XCTAssertEqual(event.proto.application_info.log_environment, expected) } } @@ -304,27 +303,26 @@ class SessionStartEventTests: XCTestCase { ), ] - expectations.forEach { (given: GULNetworkType, - expected: firebase_appquality_sessions_NetworkConnectionInfo_NetworkType) in - let mockNetworkInfo = MockNetworkInfo() - mockNetworkInfo.networkType = given - appInfo.networkInfo = mockNetworkInfo + for (given, expected) in expectations { + let mockNetworkInfo = MockNetworkInfo() + mockNetworkInfo.networkType = given + appInfo.networkInfo = mockNetworkInfo - let event = SessionStartEvent( - sessionInfo: self.defaultSessionInfo, - appInfo: appInfo, - time: time - ) + let event = SessionStartEvent( + sessionInfo: defaultSessionInfo, + appInfo: appInfo, + time: time + ) - // These fields will only be filled in when the Perf SDK is installed - event.set(subscriber: .Performance, isDataCollectionEnabled: true, appInfo: appInfo) + // These fields will only be filled in when the Perf SDK is installed + event.set(subscriber: .Performance, isDataCollectionEnabled: true, appInfo: appInfo) - testProtoAndDecodedProto(sessionEvent: event) { proto in - XCTAssertEqual( - event.proto.application_info.apple_app_info.network_connection_info.network_type, - expected - ) - } + testProtoAndDecodedProto(sessionEvent: event) { proto in + XCTAssertEqual( + event.proto.application_info.apple_app_info.network_connection_info.network_type, + expected + ) + } } } @@ -385,30 +383,28 @@ class SessionStartEventTests: XCTestCase { ), ] - expectations - .forEach { (given: String, - expected: firebase_appquality_sessions_NetworkConnectionInfo_MobileSubtype) in - let mockNetworkInfo = MockNetworkInfo() - mockNetworkInfo.mobileSubtype = given - appInfo.networkInfo = mockNetworkInfo - - let event = SessionStartEvent( - sessionInfo: self.defaultSessionInfo, - appInfo: appInfo, - time: time - ) - - // These fields will only be filled in when the Perf SDK is installed - event.set(subscriber: .Performance, isDataCollectionEnabled: true, appInfo: appInfo) - - testProtoAndDecodedProto(sessionEvent: event) { proto in - XCTAssertEqual( - event.proto.application_info.apple_app_info.network_connection_info - .mobile_subtype, - expected - ) - } + for (given, expected) in expectations { + let mockNetworkInfo = MockNetworkInfo() + mockNetworkInfo.mobileSubtype = given + appInfo.networkInfo = mockNetworkInfo + + let event = SessionStartEvent( + sessionInfo: defaultSessionInfo, + appInfo: appInfo, + time: time + ) + + // These fields will only be filled in when the Perf SDK is installed + event.set(subscriber: .Performance, isDataCollectionEnabled: true, appInfo: appInfo) + + testProtoAndDecodedProto(sessionEvent: event) { proto in + XCTAssertEqual( + event.proto.application_info.apple_app_info.network_connection_info + .mobile_subtype, + expected + ) } + } } #endif // os(iOS) && !targetEnvironment(macCatalyst) @@ -477,30 +473,28 @@ class SessionStartEventTests: XCTestCase { ), ] - expectations - .forEach { (given: String, - expected: firebase_appquality_sessions_NetworkConnectionInfo_MobileSubtype) in - let mockNetworkInfo = MockNetworkInfo() - mockNetworkInfo.mobileSubtype = given - appInfo.networkInfo = mockNetworkInfo - - let event = SessionStartEvent( - sessionInfo: self.defaultSessionInfo, - appInfo: appInfo, - time: time - ) - - // These fields will only be filled in when the Perf SDK is installed - event.set(subscriber: .Performance, isDataCollectionEnabled: true, appInfo: appInfo) - - testProtoAndDecodedProto(sessionEvent: event) { proto in - XCTAssertEqual( - event.proto.application_info.apple_app_info.network_connection_info - .mobile_subtype, - expected - ) - } + for (given, expected) in expectations { + let mockNetworkInfo = MockNetworkInfo() + mockNetworkInfo.mobileSubtype = given + appInfo.networkInfo = mockNetworkInfo + + let event = SessionStartEvent( + sessionInfo: defaultSessionInfo, + appInfo: appInfo, + time: time + ) + + // These fields will only be filled in when the Perf SDK is installed + event.set(subscriber: .Performance, isDataCollectionEnabled: true, appInfo: appInfo) + + testProtoAndDecodedProto(sessionEvent: event) { proto in + XCTAssertEqual( + event.proto.application_info.apple_app_info.network_connection_info + .mobile_subtype, + expected + ) } + } } #endif // os(iOS) && !targetEnvironment(macCatalyst) } diff --git a/Mintfile b/Mintfile index 61b02575915..ce15b18d4c7 100644 --- a/Mintfile +++ b/Mintfile @@ -1 +1 @@ -nicklockwood/SwiftFormat@0.52.10 +nicklockwood/SwiftFormat@0.53.5