Skip to content

Commit bc3a4eb

Browse files
committed
lint fixes
Signed-off-by: Kavindu Dodanduwa <[email protected]>
1 parent d6a2405 commit bc3a4eb

File tree

5 files changed

+27
-14
lines changed

5 files changed

+27
-14
lines changed

checkstyle-suppressions.xml

+3
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,7 @@
55
<suppressions>
66
<!-- don't check style of generated sources (GRPC bindings) -->
77
<suppress files="[\\/]generated-sources[\\/]" checks="[a-zA-Z0-9]*" />
8+
9+
<!-- ignore Murmur3 implementation -->
10+
<suppress files="[Murmur3]" checks="[a-zA-Z0-9]*" />
811
</suppressions>

providers/flagd/src/main/java/dev/openfeature/contrib/providers/flagd/resolver/process/model/FlagParser.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,13 @@ public class FlagParser {
4040
private static JsonSchema SCHEMA_VALIDATOR;
4141

4242
static {
43-
try( final InputStream schema = FlagParser.class.getClassLoader().getResourceAsStream(SCHEMA_RESOURCE)) {
43+
try (final InputStream schema = FlagParser.class.getClassLoader().getResourceAsStream(SCHEMA_RESOURCE)) {
4444
if (schema == null) {
4545
log.log(Level.WARNING, String.format("Resource %s not found", SCHEMA_RESOURCE));
4646
} else {
4747
final ByteArrayOutputStream result = new ByteArrayOutputStream();
4848
byte[] buffer = new byte[512];
49-
for (int size; 0 <(size = schema.read(buffer));){
49+
for (int size; 0 < (size = schema.read(buffer)); ) {
5050
result.write(buffer, 0, size);
5151
}
5252

providers/flagd/src/main/java/dev/openfeature/contrib/providers/flagd/resolver/process/targeting/Operator.java

+12-9
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
*/
1414
public class Operator {
1515

16-
final static String FLAG_KEY = "$flagKey";
17-
final static String TARGET_KEY = "targetingKey";
16+
static final String FLAG_KEY = "$flagKey";
17+
static final String TARGET_KEY = "targetingKey";
1818

1919
private final JsonLogic jsonLogicHandler;
2020

@@ -29,6 +29,9 @@ public Operator() {
2929
jsonLogicHandler.addOperation(new StringComp(StringComp.Type.ENDS_WITH));
3030
}
3131

32+
/**
33+
* Apply this operator on the provided rule.
34+
*/
3235
public Object apply(final String flagKey, final String targetingRule, final EvaluationContext ctx)
3336
throws TargetingRuleException {
3437
final Map<String, Object> valueMap = ctx.asObjectMap();
@@ -50,18 +53,18 @@ static class FlagProperties {
5053
if (from instanceof Map) {
5154
Map<?, ?> dataMap = (Map<?, ?>) from;
5255

53-
Object fKey = dataMap.get(FLAG_KEY);
56+
Object flagKey = dataMap.get(FLAG_KEY);
5457

55-
if (fKey instanceof String) {
56-
flagKey = (String) fKey;
58+
if (flagKey instanceof String) {
59+
this.flagKey = (String) flagKey;
5760
} else {
58-
flagKey = null;
61+
this.flagKey = null;
5962
}
6063

61-
Object tKey = dataMap.get(TARGET_KEY);
64+
Object targetKey = dataMap.get(TARGET_KEY);
6265

63-
if (tKey instanceof String) {
64-
targetingKey = (String) tKey;
66+
if (targetKey instanceof String) {
67+
targetingKey = (String) targetKey;
6568
} else {
6669
targetingKey = null;
6770
}
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
package dev.openfeature.contrib.providers.flagd.resolver.process.targeting;
22

3-
public class TargetingRuleException extends Exception{
3+
/**
4+
* Exception used by targeting rule package.
5+
**/
6+
public class TargetingRuleException extends Exception {
47

5-
public TargetingRuleException(final String message, final Throwable t){
8+
/**
9+
* Construct exception.
10+
**/
11+
public TargetingRuleException(final String message, final Throwable t) {
612
super(message, t);
713
}
814
}

providers/flagd/src/test/java/dev/openfeature/contrib/providers/flagd/resolver/process/model/FlagParserTest.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ public void validJsonConfigurationWithTargetingRulesParsing() throws IOException
4646
assertEquals("loop", variants.get("loop"));
4747
assertEquals("binet", variants.get("binet"));
4848

49-
assertEquals("{\"if\":[{\"in\":[\"@faas.com\",{\"var\":[\"email\"]}]},\"binet\",null]}", stringFlag.getTargeting());
49+
assertEquals("{\"if\":[{\"in\":[\"@faas.com\",{\"var\":[\"email\"]}]},\"binet\",null]}",
50+
stringFlag.getTargeting());
5051
}
5152

5253

0 commit comments

Comments
 (0)