Skip to content

chore: fix issues with compilation on later JDKs #178

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class MyClass {
For complete documentation, visit: https://docs.openfeature.dev/docs/category/concepts

## Requirements
- Java 8+
- Java 8+ (compiler target is 1.8)

## Installation

Expand Down
7 changes: 7 additions & 0 deletions checkstyle-suppressions.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0"?>

<!DOCTYPE suppressions PUBLIC "-//Checkstyle//DTD SuppressionFilter Configuration 1.2//EN" "https://checkstyle.org/dtds/suppressions_1_2.dtd">

<suppressions>
<!-- checkstyle suppressions can go here -->
</suppressions>
32 changes: 24 additions & 8 deletions checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
<property name="optional" value="true"/>
</module>


<!-- Checks for whitespace -->
<!-- See http://checkstyle.org/config_whitespace.html -->
<module name="FileTabCharacter">
Expand All @@ -46,7 +47,23 @@
<property name="ignorePattern" value="^package.*|^import.*|a href|href|http://|https://|ftp://"/>
</module>

<module name="SuppressWarningsFilter" />

<module name="TreeWalker">
<!-- needed for SuppressWarningsFilter -->
<module name="SuppressWarningsHolder" />

<module name="SuppressWarnings">
<property name="id" value="checkstyle:suppresswarnings"/>
</module>
Comment on lines +50 to +58
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New stuff to support suppression via annotations.


<!-- https://checkstyle.org/config_filters.html#SuppressionXpathFilter -->
<module name="SuppressionXpathFilter">
<property name="file" value="${org.checkstyle.google.suppressionxpathfilter.config}"
default="checkstyle-xpath-suppressions.xml" />
<property name="optional" value="true"/>
</module>

<module name="OuterTypeFilename"/>
<module name="IllegalTokenText">
<property name="tokens" value="STRING_LITERAL, CHAR_LITERAL"/>
Expand Down Expand Up @@ -223,7 +240,7 @@
<property name="arrayInitIndent" value="4"/>
</module>
<module name="AbbreviationAsWordInName">
<property name="ignoreFinal" value="false"/>
<property name="ignoreFinal" value="true"/>
<property name="allowedAbbreviations" value="API" />
<property name="allowedAbbreviationLength" value="1"/>
<property name="tokens"
Expand Down Expand Up @@ -292,6 +309,12 @@
<property name="allowedAnnotations" value="Override, Test"/>
<property name="tokens" value="METHOD_DEF, CTOR_DEF, ANNOTATION_FIELD_DEF"/>
</module>
<module name="MissingJavadocType">
<property name="scope" value="protected"/>
<property name="tokens" value="CLASS_DEF, INTERFACE_DEF, ENUM_DEF,
RECORD_DEF, ANNOTATION_DEF"/>
<property name="excludeScope" value="nothing"/>
</module>
<module name="MethodName">
<property name="format" value="^[a-z][a-z0-9][a-zA-Z0-9_]*$"/>
<message key="name.invalidPattern"
Expand All @@ -306,12 +329,5 @@
<module name="CommentsIndentation">
<property name="tokens" value="SINGLE_LINE_COMMENT, BLOCK_COMMENT_BEGIN"/>
</module>
<!-- https://checkstyle.org/config_filters.html#SuppressionXpathFilter -->
<module name="SuppressionXpathFilter">
<property name="file" value="${org.checkstyle.google.suppressionxpathfilter.config}"
default="checkstyle-xpath-suppressions.xml" />
<property name="optional" value="true"/>
</module>
Comment on lines -309 to -314
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I moved all the suppression-related config to the top of the parent element.

</module>
</module>

1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,7 @@
<version>3.4.1</version>
<configuration>
<failOnWarnings>true</failOnWarnings>
<doclint>all,-missing</doclint> <!-- ignore missing javadoc, these are enforced with more customizability in the checkstyle plugin -->
</configuration>
<executions>
<execution>
Expand Down
3 changes: 0 additions & 3 deletions spotbugs-exclusions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@
<Bug pattern="EI_EXPOSE_REP2"/>
</And>




<!-- Test class that should be excluded -->
<Match>
<Class name="dev.openfeature.sdk.DoSomethingProvider"/>
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/dev/openfeature/sdk/BooleanHook.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package dev.openfeature.sdk;

/**
* {@inheritDoc}
*/
public interface BooleanHook extends Hook<Boolean> {

@Override
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/dev/openfeature/sdk/DoubleHook.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package dev.openfeature.sdk;

/**
* {@inheritDoc}
*/
public interface DoubleHook extends Hook<Double> {

@Override
Expand Down
1 change: 1 addition & 0 deletions src/main/java/dev/openfeature/sdk/ErrorCode.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package dev.openfeature.sdk;

@SuppressWarnings("checkstyle:MissingJavadocType")
public enum ErrorCode {
PROVIDER_NOT_READY, FLAG_NOT_FOUND, PARSE_ERROR, TYPE_MISMATCH, TARGETING_KEY_MISSING, INVALID_CONTEXT, GENERAL
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public class FlagEvaluationDetails<T> implements BaseEvaluation<T> {

/**
* Generate detail payload from the provider response.
*
* @param providerEval provider response
* @param flagKey key for the flag being evaluated
* @param <T> type of flag being returned
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import lombok.Builder;
import lombok.Singular;

@SuppressWarnings("checkstyle:MissingJavadocType")
@lombok.Value
@Builder
public class FlagEvaluationOptions {
Expand Down
1 change: 1 addition & 0 deletions src/main/java/dev/openfeature/sdk/FlagValueType.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package dev.openfeature.sdk;

@SuppressWarnings("checkstyle:MissingJavadocType")
public enum FlagValueType {
STRING, INTEGER, DOUBLE, OBJECT, BOOLEAN;
}
5 changes: 4 additions & 1 deletion src/main/java/dev/openfeature/sdk/HookSupport.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package dev.openfeature.sdk;

import java.util.*;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.function.Consumer;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/dev/openfeature/sdk/IntegerHook.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package dev.openfeature.sdk;

/**
* {@inheritDoc}
*/
public interface IntegerHook extends Hook<Integer> {

@Override
Expand Down
15 changes: 6 additions & 9 deletions src/main/java/dev/openfeature/sdk/MutableStructure.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package dev.openfeature.sdk;

import java.time.Instant;
import java.util.*;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;

import dev.openfeature.sdk.exceptions.ValueNotConvertableError;
Expand All @@ -16,7 +19,7 @@
*/
@ToString
@EqualsAndHashCode
@SuppressWarnings("PMD.BeanMembersShouldSerialize")
@SuppressWarnings({"PMD.BeanMembersShouldSerialize", "checkstyle:MissingJavadocType"})
public class MutableStructure implements Structure {

protected final Map<String, Value> attributes;
Expand Down Expand Up @@ -66,13 +69,6 @@ public MutableStructure add(String key, Double value) {
return this;
}

/**
* Add date-time relevant key.
*
* @param key feature key
* @param value date-time value
* @return Structure
*/
public MutableStructure add(String key, Instant value) {
attributes.put(key, new Value(value));
return this;
Expand Down Expand Up @@ -116,6 +112,7 @@ public Map<String, Object> asObjectMap() {

/**
* convertValue is converting the object type Value in a primitive type.
*
* @param value - Value object to convert
* @return an Object containing the primitive type.
*/
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/dev/openfeature/sdk/OpenFeatureClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;

/**
* {@inheritDoc}
*/
@Slf4j
@SuppressWarnings({ "PMD.DataflowAnomalyAnalysis", "PMD.BeanMembersShouldSerialize", "unchecked", "rawtypes" })
public class OpenFeatureClient implements Client {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import javax.annotation.Nullable;

@SuppressWarnings("checkstyle:MissingJavadocType")
@Data @Builder
public class ProviderEvaluation<T> implements BaseEvaluation<T> {
T value;
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/dev/openfeature/sdk/Reason.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package dev.openfeature.sdk;

/**
* Predefined resolution reasons.
*/
Comment on lines +3 to +5
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one it debatable but I wanted to make it clear that you're not limited to just these reasons, these are just some we pre-defined.

public enum Reason {
DISABLED, SPLIT, TARGETING_MATCH, DEFAULT, UNKNOWN, ERROR
}
3 changes: 3 additions & 0 deletions src/main/java/dev/openfeature/sdk/StringHook.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package dev.openfeature.sdk;

/**
* {@inheritDoc}
*/
public interface StringHook extends Hook<String> {

@Override
Expand Down
5 changes: 4 additions & 1 deletion src/main/java/dev/openfeature/sdk/Value.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,14 @@
*/
@ToString
@EqualsAndHashCode
@SuppressWarnings("PMD.BeanMembersShouldSerialize")
@SuppressWarnings({"PMD.BeanMembersShouldSerialize", "checkstyle:MissingJavadocType"})
public class Value {

private final Object innerObject;

/**
* Construct a new null Value.
*/
public Value() {
this.innerObject = null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import lombok.Getter;
import lombok.experimental.StandardException;

@SuppressWarnings("checkstyle:MissingJavadocType")
@StandardException
public class FlagNotFoundError extends OpenFeatureError {
private static final long serialVersionUID = 1L;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import lombok.Getter;
import lombok.experimental.StandardException;

@SuppressWarnings("checkstyle:MissingJavadocType")
@StandardException
public class GeneralError extends OpenFeatureError {
private static final long serialVersionUID = 1L;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
import lombok.Getter;
import lombok.experimental.StandardException;

/**
* The evaluation context does not meet provider requirements.
*/
@StandardException
public class InvalidContextError extends OpenFeatureError {
private static final long serialVersionUID = 1L;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import dev.openfeature.sdk.ErrorCode;
import lombok.experimental.StandardException;

@SuppressWarnings("checkstyle:MissingJavadocType")
@StandardException
public abstract class OpenFeatureError extends RuntimeException {
private static final long serialVersionUID = 1L;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
import lombok.Getter;
import lombok.experimental.StandardException;

/**
* An error was encountered parsing data, such as a flag configuration.
*/
@StandardException
public class ParseError extends OpenFeatureError {
private static final long serialVersionUID = 1L;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
import lombok.Getter;
import lombok.experimental.StandardException;

/**
* The provider requires a targeting key and one was not provided in the evaluation context.
*/
@StandardException
public class TargetingKeyMissingError extends OpenFeatureError {
private static final long serialVersionUID = 1L;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
import lombok.Getter;
import lombok.experimental.StandardException;

/**
* The type of the flag value does not match the expected type.
*/
@StandardException
public class TypeMismatchError extends OpenFeatureError {
private static final long serialVersionUID = 1L;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
import lombok.Getter;
import lombok.experimental.StandardException;

/**
* The value can not be converted to a {@link dev.openfeature.sdk.Value}.
*/
@StandardException
public class ValueNotConvertableError extends OpenFeatureError {
private static final long serialVersionUID = 1L;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package dev.openfeature.sdk.internal;

@SuppressWarnings("checkstyle:MissingJavadocType")
public interface AutoCloseableLock extends AutoCloseable {

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
package dev.openfeature.sdk.internal;

import java.util.*;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.function.Supplier;
import java.util.stream.Collectors;

import lombok.experimental.UtilityClass;

@SuppressWarnings("checkstyle:MissingJavadocType")
@UtilityClass
public class ObjectUtils {

Expand Down