Skip to content

Commit d0aa19a

Browse files
thiyagu06toddbaert
authored andcommitted
fixed sonar issue.
Signed-off-by: thiyagu06 <[email protected]>
1 parent bfba968 commit d0aa19a

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

src/main/java/dev/openfeature/sdk/ImmutableContext.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,18 +74,18 @@ public EvaluationContext merge(EvaluationContext overridingContext) {
7474
if (overridingContext == null) {
7575
return new ImmutableContext(this.targetingKey, this.asMap());
7676
}
77-
String targetingKey = "";
77+
String newTargetingKey = "";
7878
if (this.getTargetingKey() != null && !this.getTargetingKey().trim().equals("")) {
79-
targetingKey = this.getTargetingKey();
79+
newTargetingKey = this.getTargetingKey();
8080
}
8181

8282
if (overridingContext.getTargetingKey() != null && !overridingContext.getTargetingKey().trim().equals("")) {
83-
targetingKey = overridingContext.getTargetingKey();
83+
newTargetingKey = overridingContext.getTargetingKey();
8484
}
8585
Map<String, Value> merged = new HashMap<>();
8686

8787
merged.putAll(this.asMap());
8888
merged.putAll(overridingContext.asMap());
89-
return new ImmutableContext(targetingKey, merged);
89+
return new ImmutableContext(newTargetingKey, merged);
9090
}
9191
}

src/test/java/dev/openfeature/sdk/ImmutableContextTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import static org.junit.jupiter.api.Assertions.assertEquals;
1010
import static org.junit.jupiter.api.Assertions.assertThrows;
1111

12-
public class ImmutableContextTest {
12+
class ImmutableContextTest {
1313

1414
@Test
1515
@DisplayName("Mutating targeting key is not allowed on Immutable Context")
@@ -26,7 +26,7 @@ void shouldCreateCopyOfAttributesForImmutableContext() {
2626
attributes.put("key2", new Value("val2"));
2727
EvaluationContext ctx = new ImmutableContext("targeting key", attributes);
2828
attributes.put("key3", new Value("val3"));
29-
assertArrayEquals(ctx.keySet().toArray(), new Object[]{"key1", "key2"});
29+
assertArrayEquals(new Object[]{"key1", "key2"}, ctx.keySet().toArray());
3030
}
3131

3232
@DisplayName("targeting key should be changed from the overriding context")
@@ -62,6 +62,6 @@ void mergeShouldReturnAllTheValuesFromTheContextWhenOverridingContextIsNull() {
6262
EvaluationContext ctx = new ImmutableContext("targeting_key", attributes);
6363
EvaluationContext merge = ctx.merge(null);
6464
assertEquals("targeting_key", merge.getTargetingKey());
65-
assertArrayEquals(merge.keySet().toArray(), new Object[]{"key1", "key2"});
65+
assertArrayEquals(new Object[]{"key1", "key2"}, merge.keySet().toArray());
6666
}
6767
}

src/test/java/dev/openfeature/sdk/ImmutableStructureTest.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@
1515
import static org.junit.jupiter.api.Assertions.assertNotSame;
1616
import static org.junit.jupiter.api.Assertions.assertTrue;
1717

18-
public class ImmutableStructureTest {
19-
@Test public void noArgShouldContainEmptyAttributes() {
18+
class ImmutableStructureTest {
19+
@Test void noArgShouldContainEmptyAttributes() {
2020
ImmutableStructure structure = new ImmutableStructure();
2121
assertEquals(0, structure.asMap().keySet().size());
2222
}
2323

24-
@Test public void mapArgShouldContainNewMap() {
24+
@Test void mapArgShouldContainNewMap() {
2525
String KEY = "key";
2626
Map<String, Value> map = new HashMap<String, Value>() {
2727
{
@@ -33,7 +33,7 @@ public class ImmutableStructureTest {
3333
assertNotSame(structure.asMap(), map); // should be a copy
3434
}
3535

36-
@Test public void MutatingGetValueShouldNotChangeOriginalValue() {
36+
@Test void MutatingGetValueShouldNotChangeOriginalValue() {
3737
String KEY = "key";
3838
List<Value> lists = new ArrayList<>();
3939
lists.add(new Value(KEY));
@@ -50,7 +50,7 @@ public class ImmutableStructureTest {
5050
assertNotSame(structure.asMap(), map); // should be a copy
5151
}
5252

53-
@Test public void MutatingGetInstantValueShouldNotChangeOriginalValue() {
53+
@Test void MutatingGetInstantValueShouldNotChangeOriginalValue() {
5454
String KEY = "key";
5555
Instant now = Instant.now();
5656
Map<String, Value> map = new HashMap<String, Value>() {
@@ -68,7 +68,7 @@ public class ImmutableStructureTest {
6868
assertEquals(now, structure.getValue(KEY).asInstant());
6969
}
7070

71-
@Test public void MutatingGetStructureValueShouldNotChangeOriginalValue() {
71+
@Test void MutatingGetStructureValueShouldNotChangeOriginalValue() {
7272
String KEY = "key";
7373
List<Value> lists = new ArrayList<>();
7474
lists.add(new Value("dummy_list_1"));

0 commit comments

Comments
 (0)