diff --git a/Sources/ConfidenceProvider/Apply/FlagApplierWithRetries.swift b/Sources/ConfidenceProvider/Apply/FlagApplierWithRetries.swift index 55b3ddb6..1dc6d0df 100644 --- a/Sources/ConfidenceProvider/Apply/FlagApplierWithRetries.swift +++ b/Sources/ConfidenceProvider/Apply/FlagApplierWithRetries.swift @@ -55,9 +55,8 @@ final class FlagApplierWithRetries: FlagApplier { private func triggerBatch() async { async let cacheData = await cacheDataInteractor.cache await cacheData.resolveEvents.forEach { resolveEvent in - let appliesToSend = resolveEvent.events.filter { entry in - return entry.status == .created - }.chunk(size: 20) + let appliesToSend = resolveEvent.events.filter { $0.status == .created } + .chunk(size: 20) guard appliesToSend.isEmpty == false else { return diff --git a/Sources/ConfidenceProvider/Cache/CacheDataActor.swift b/Sources/ConfidenceProvider/Cache/CacheDataActor.swift index 427c6d9f..3210a854 100644 --- a/Sources/ConfidenceProvider/Cache/CacheDataActor.swift +++ b/Sources/ConfidenceProvider/Cache/CacheDataActor.swift @@ -23,5 +23,4 @@ protocol CacheDataActor: Actor { /// Sets Resolve Apply Event `status` property. func setEventStatus(resolveToken: String, status: ApplyEventStatus) -> CacheData - } diff --git a/Sources/ConfidenceProvider/Cache/Models/CacheData.swift b/Sources/ConfidenceProvider/Cache/Models/CacheData.swift index e911925c..00ed9e34 100644 --- a/Sources/ConfidenceProvider/Cache/Models/CacheData.swift +++ b/Sources/ConfidenceProvider/Cache/Models/CacheData.swift @@ -36,7 +36,8 @@ struct CacheData: Codable { mutating func setEventStatus(resolveToken: String, name: String, status: ApplyEventStatus = .sent) { let flagEventIndexes = flagEventIndex(resolveToken: resolveToken, name: name) guard let resolveIndex = flagEventIndexes.resolveEventIndex, - let flagIndex = flagEventIndexes.flagEventIndex else { + let flagIndex = flagEventIndexes.flagEventIndex + else { return } @@ -116,7 +117,8 @@ struct CacheData: Codable { func flagEvent(resolveToken: String, name: String) -> FlagApply? { guard let resolveTokenIndex = resolveEventIndex(resolveToken: resolveToken), - let flagEventIndex = applyEventIndex(resolveToken: resolveToken, name: name) else { + let flagEventIndex = applyEventIndex(resolveToken: resolveToken, name: name) + else { return nil } diff --git a/Sources/ConfidenceProvider/ConfidenceFeatureProvider.swift b/Sources/ConfidenceProvider/ConfidenceFeatureProvider.swift index 102a9c42..dd1df564 100644 --- a/Sources/ConfidenceProvider/ConfidenceFeatureProvider.swift +++ b/Sources/ConfidenceProvider/ConfidenceFeatureProvider.swift @@ -471,11 +471,13 @@ extension ConfidenceFeatureProvider { /// Creates the `ConfidenceFeatureProvider` according to the settings specified in the builder. public func build() -> ConfidenceFeatureProvider { - let flagApplier = flagApplier ?? FlagApplierWithRetries( - httpClient: NetworkClient(region: options.region), - storage: DefaultStorage(filePath: "applier.flags.cache"), - options: options - ) + let flagApplier = + flagApplier + ?? FlagApplierWithRetries( + httpClient: NetworkClient(region: options.region), + storage: DefaultStorage(filePath: "applier.flags.cache"), + options: options + ) let client = RemoteConfidenceClient( options: options, @@ -506,3 +508,6 @@ extension DispatchQueue: DispatchQueueType { async(group: nil, qos: .unspecified, flags: [], execute: work) } } + +// swiftlint:enable type_body_length +// swiftlint:enable file_length diff --git a/Sources/ConfidenceProvider/Http/NetworkClient.swift b/Sources/ConfidenceProvider/Http/NetworkClient.swift index aeb12b75..c6feaf90 100644 --- a/Sources/ConfidenceProvider/Http/NetworkClient.swift +++ b/Sources/ConfidenceProvider/Http/NetworkClient.swift @@ -23,14 +23,14 @@ final class NetworkClient: HttpClient { retry: Retry = .none ) { self.session = - session - ?? { - let configuration = URLSessionConfiguration.default - configuration.timeoutIntervalForRequest = timeout - configuration.httpAdditionalHeaders = defaultHeaders + session + ?? { + let configuration = URLSessionConfiguration.default + configuration.timeoutIntervalForRequest = timeout + configuration.httpAdditionalHeaders = defaultHeaders - return URLSession(configuration: configuration) - }() + return URLSession(configuration: configuration) + }() self.headers = defaultHeaders self.retry = retry @@ -57,7 +57,7 @@ final class NetworkClient: HttpClient { do { let httpClientResult: HttpClientResponse = - try self.buildResponse(response: response, data: data) + try self.buildResponse(response: response, data: data) completion(.success(httpClientResult)) } catch { completion(.failure(error)) diff --git a/Sources/ConfidenceProvider/Utils/Array+Chunks.swift b/Sources/ConfidenceProvider/Utils/Array+Chunks.swift index fd0e9f64..91d440dd 100644 --- a/Sources/ConfidenceProvider/Utils/Array+Chunks.swift +++ b/Sources/ConfidenceProvider/Utils/Array+Chunks.swift @@ -3,7 +3,7 @@ import Foundation extension Array { func chunk(size: Int) -> [[Element]] { return stride(from: 0, to: count, by: size).map { - Array(self[$0 ..< Swift.min($0 + size, count)]) + Array(self[$0..