Skip to content

Commit df29538

Browse files
committed
Resolve lint errors and run swift format
Signed-off-by: jescriba <[email protected]>
1 parent e2d33ad commit df29538

File tree

4 files changed

+51
-32
lines changed

4 files changed

+51
-32
lines changed

Sources/OpenFeature/Provider/MultiProvider/FirstMatchStrategy.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
/// and returns the first result. Skips providers that indicate they had no value due to flag not found.
33
/// If any provider returns an error result other than flag not found, the error is returned.
44
final public class FirstMatchStrategy: Strategy {
5-
65
public init() {}
76

87
public func evaluate<T>(

Sources/OpenFeature/Provider/MultiProvider/MultiProvider.swift

Lines changed: 35 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import Foundation
33

44
/// A provider that combines multiple providers into a single provider.
55
public class MultiProvider: FeatureProvider {
6-
76
public var hooks: [any Hook] {
87
[]
98
}
@@ -52,50 +51,65 @@ public class MultiProvider: FeatureProvider {
5251
-> ProviderEvaluation<Bool>
5352
{
5453
return try strategy.evaluate(
55-
providers: providers, key: key, defaultValue: defaultValue, evaluationContext: context,
56-
flagEvaluation: { provider in
57-
return provider.getBooleanEvaluation(key:defaultValue:context:)
58-
})
54+
providers: providers,
55+
key: key,
56+
defaultValue: defaultValue,
57+
evaluationContext: context
58+
) { provider in
59+
return provider.getBooleanEvaluation(key:defaultValue:context:)
60+
}
5961
}
6062

6163
public func getStringEvaluation(key: String, defaultValue: String, context: EvaluationContext?) throws
6264
-> ProviderEvaluation<String>
6365
{
6466
return try strategy.evaluate(
65-
providers: providers, key: key, defaultValue: defaultValue, evaluationContext: context,
66-
flagEvaluation: { provider in
67-
return provider.getStringEvaluation(key:defaultValue:context:)
68-
})
67+
providers: providers,
68+
key: key,
69+
defaultValue: defaultValue,
70+
evaluationContext: context
71+
) { provider in
72+
return provider.getStringEvaluation(key:defaultValue:context:)
73+
}
6974
}
7075

7176
public func getIntegerEvaluation(key: String, defaultValue: Int64, context: EvaluationContext?) throws
7277
-> ProviderEvaluation<Int64>
7378
{
7479
return try strategy.evaluate(
75-
providers: providers, key: key, defaultValue: defaultValue, evaluationContext: context,
76-
flagEvaluation: { provider in
77-
return provider.getIntegerEvaluation(key:defaultValue:context:)
78-
})
80+
providers: providers,
81+
key: key,
82+
defaultValue: defaultValue,
83+
evaluationContext: context
84+
) { provider in
85+
return provider.getIntegerEvaluation(key:defaultValue:context:)
86+
}
7987
}
8088

8189
public func getDoubleEvaluation(key: String, defaultValue: Double, context: EvaluationContext?) throws
8290
-> ProviderEvaluation<Double>
8391
{
8492
return try strategy.evaluate(
85-
providers: providers, key: key, defaultValue: defaultValue, evaluationContext: context,
86-
flagEvaluation: { provider in
87-
return provider.getDoubleEvaluation(key:defaultValue:context:)
88-
})
93+
providers: providers,
94+
key: key,
95+
defaultValue: defaultValue,
96+
evaluationContext: context
97+
) { provider in
98+
return provider.getDoubleEvaluation(key:defaultValue:context:)
99+
}
89100
}
90101

91102
public func getObjectEvaluation(key: String, defaultValue: Value, context: EvaluationContext?) throws
92103
-> ProviderEvaluation<Value>
93104
{
94105
return try strategy.evaluate(
95-
providers: providers, key: key, defaultValue: defaultValue, evaluationContext: context,
96-
flagEvaluation: { provider in
97-
return provider.getObjectEvaluation(key:defaultValue:context:)
98-
})
106+
providers: providers,
107+
key: key,
108+
defaultValue: defaultValue,
109+
evaluationContext: context
110+
) { provider in
111+
return provider.getObjectEvaluation(key:defaultValue:context:)
112+
}
99113
}
100114

101115
public func observe() -> AnyPublisher<ProviderEvent?, Never> {

Tests/OpenFeatureTests/EvalContextTests.swift

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -144,10 +144,12 @@ final class EvalContextTests: XCTestCase {
144144
originalContext.add(key: "integer", value: .integer(42))
145145
originalContext.add(key: "boolean", value: .boolean(true))
146146
originalContext.add(key: "list", value: .list([.string("item1"), .integer(100)]))
147-
originalContext.add(key: "structure", value: .structure([
148-
"nested-string": .string("nested-value"),
149-
"nested-int": .integer(200),
150-
]))
147+
originalContext.add(
148+
key: "structure",
149+
value: .structure([
150+
"nested-string": .string("nested-value"),
151+
"nested-int": .integer(200),
152+
]))
151153

152154
guard let copiedContext = originalContext.deepCopy() as? MutableContext else {
153155
XCTFail("Failed to cast to MutableContext")
@@ -207,10 +209,12 @@ final class EvalContextTests: XCTestCase {
207209
originalContext.add(key: "double", value: .double(3.14159))
208210
originalContext.add(key: "date", value: .date(date))
209211
originalContext.add(key: "list", value: .list([.string("list-item"), .integer(999)]))
210-
originalContext.add(key: "structure", value: .structure([
211-
"struct-key": .string("struct-value"),
212-
"struct-number": .integer(777),
213-
]))
212+
originalContext.add(
213+
key: "structure",
214+
value: .structure([
215+
"struct-key": .string("struct-value"),
216+
"struct-number": .integer(777),
217+
]))
214218

215219
guard let copiedContext = originalContext.deepCopy() as? MutableContext else {
216220
XCTFail("Failed to cast to MutableContext")

Tests/OpenFeatureTests/ImmutableContextTests.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import XCTest
2+
23
@testable import OpenFeature
34

45
final class ImmutableContextTests: XCTestCase {
@@ -97,7 +98,7 @@ final class ImmutableContextTests: XCTestCase {
9798

9899
// For null values, we need to check the unwrapped value
99100
let nullValue = objectMap["null"]
100-
XCTAssertNil(nullValue as? AnyHashable) // But the unwrapped value is nil
101+
XCTAssertNil(nullValue as? AnyHashable) // But the unwrapped value is nil
101102
}
102103

103104
func testImmutableContextWithTargetingKey() {
@@ -182,7 +183,8 @@ final class ImmutableContextTests: XCTestCase {
182183
expectation.expectedFulfillmentCount = 10
183184

184185
DispatchQueue.concurrentPerform(iterations: 10) { index in
185-
let modified = original
186+
let modified =
187+
original
186188
.withAttribute(key: "thread", value: .integer(Int64(index)))
187189
.withAttribute(key: "timestamp", value: .double(Double(index)))
188190

0 commit comments

Comments
 (0)