Skip to content

Commit

Permalink
Update to SwiftFormat 0.53.5
Browse files Browse the repository at this point in the history
  • Loading branch information
paulb777 committed Mar 29, 2024
1 parent 3cc143b commit 0b89757
Show file tree
Hide file tree
Showing 9 changed files with 85 additions and 87 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
// limitations under the License.

import Firebase

// Verify that the following Firebase Swift APIs can be found.
import FirebaseAnalyticsSwift
import FirebaseFirestoreSwift
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Heartbeat>.Error {
Expand All @@ -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 {
Expand All @@ -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.
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

@testable import FirebaseCoreInternal
import XCTest

class HeartbeatStorageTests: XCTestCase {
// MARK: - Instance Management

Expand Down
2 changes: 1 addition & 1 deletion FirebaseCore/Internal/Tests/Unit/HeartbeatTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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`).
Expand Down
8 changes: 4 additions & 4 deletions FirebaseSessions/Sources/FirebaseSessions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,8 @@ private enum GoogleDataTransportConfig {

super.init()

SessionsDependencies.dependencies.forEach { subscriberName in
self.subscriberPromises[subscriberName] = Promise<Void>.pending()
for subscriberName in SessionsDependencies.dependencies {
subscriberPromises[subscriberName] = Promise<Void>.pending()
}

Logger
Expand Down Expand Up @@ -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)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import Foundation

@_implementationOnly import FirebaseInstallations

protocol InstallationsProtocol {
var installationsWaitTimeInSecond: Int { get }

Expand Down
144 changes: 69 additions & 75 deletions FirebaseSessions/Tests/Unit/SessionStartEventTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand All @@ -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)
}
}

Expand Down Expand Up @@ -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
)
}
}
}

Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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)
}
2 changes: 1 addition & 1 deletion Mintfile
Original file line number Diff line number Diff line change
@@ -1 +1 @@
nicklockwood/SwiftFormat@0.52.10
nicklockwood/SwiftFormat@0.53.5

0 comments on commit 0b89757

Please sign in to comment.