-
Notifications
You must be signed in to change notification settings - Fork 78
chore: resolve a bunch of linter warnings, no logic changes #334
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,7 +8,6 @@ | |
| import io.getunleash.event.IsEnabledImpressionEvent; | ||
| import io.getunleash.event.ToggleEvaluated; | ||
| import io.getunleash.event.VariantImpressionEvent; | ||
| import io.getunleash.metric.UnleashMetricService; | ||
| import io.getunleash.repository.FeatureRepository; | ||
| import io.getunleash.repository.YggdrasilAdapters; | ||
| import io.getunleash.strategy.*; | ||
|
|
@@ -27,7 +26,6 @@ public class DefaultUnleash implements Unleash { | |
|
|
||
| private static ConcurrentHashMap<String, LongAdder> initCounts = new ConcurrentHashMap<>(); | ||
|
|
||
| private final UnleashMetricService metricService; | ||
| private final FeatureRepository featureRepository; | ||
| private final UnleashContextProvider contextProvider; | ||
| private final EventDispatcher eventDispatcher; | ||
|
|
@@ -69,7 +67,6 @@ public DefaultUnleash( | |
|
|
||
| this.config = unleashConfig; | ||
| this.featureRepository = engineProxy; | ||
| this.metricService = engineProxy; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
But but.. |
||
| this.contextProvider = contextProvider; | ||
| this.eventDispatcher = eventDispatcher; | ||
| initCounts.compute( | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,11 +8,8 @@ | |
| import java.time.LocalDateTime; | ||
| import java.time.ZoneId; | ||
| import java.util.Set; | ||
| import org.slf4j.Logger; | ||
| import org.slf4j.LoggerFactory; | ||
|
|
||
| public class UnleashMetricServiceImpl implements UnleashMetricService { | ||
| private static final Logger LOGGER = LoggerFactory.getLogger(UnleashMetricServiceImpl.class); | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not used |
||
| private final LocalDateTime started; | ||
| private final UnleashConfig unleashConfig; | ||
| private final MetricSender metricSender; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -48,7 +48,11 @@ public void setInterval(Runnable command, long initialDelaySec, long periodSec) | |
|
|
||
| @Override | ||
| public Future<Void> scheduleOnce(Runnable runnable) { | ||
| return (Future<Void>) executorService.submit(runnable); | ||
| return executorService.submit( | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Think this was just wrong but didn't matter because the result wasn't really used. Pretty sure this is correct but still won't matter Linter stops freaking though, which is nice |
||
| () -> { | ||
| runnable.run(); | ||
| return null; | ||
| }); | ||
| } | ||
|
|
||
| @Override | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,9 +23,7 @@ | |
| import io.getunleash.util.UnleashConfig; | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Mostly a bunch of unuseds which don't impact the test runs in anyway |
||
| import java.net.URI; | ||
| import java.net.URISyntaxException; | ||
| import java.util.HashMap; | ||
| import java.util.List; | ||
| import java.util.Map; | ||
| import java.util.Optional; | ||
| import org.junit.jupiter.api.BeforeEach; | ||
| import org.junit.jupiter.api.Test; | ||
|
|
@@ -56,7 +54,6 @@ public void setup() { | |
| UnleashConfig unleashConfig = | ||
| UnleashConfig.builder().unleashAPI("http://fakeAPI").appName("fakeApp").build(); | ||
| engineProxy = mock(EngineProxy.class); | ||
| Map<String, Strategy> strategyMap = new HashMap<>(); | ||
| contextProvider = mock(UnleashContextProvider.class); | ||
| eventDispatcher = mock(EventDispatcher.class); | ||
|
|
||
|
|
@@ -145,7 +142,7 @@ public void not_setting_current_time_falls_back_to_correct_now_instant() { | |
|
|
||
| @Test | ||
| public void multiple_instantiations_of_the_same_config_gives_errors() { | ||
| ListAppender<ILoggingEvent> appender = new ListAppender(); | ||
| ListAppender<ILoggingEvent> appender = new ListAppender<>(); | ||
| appender.start(); | ||
| Logger unleashLogger = (Logger) LoggerFactory.getLogger(DefaultUnleash.class); | ||
| unleashLogger.addAppender(appender); | ||
|
|
@@ -158,13 +155,13 @@ public void multiple_instantiations_of_the_same_config_gives_errors() { | |
| .apiKey("default:development:1234567890123456") | ||
| .instanceId(instanceId) | ||
| .build(); | ||
| Unleash unleash1 = new DefaultUnleash(config); | ||
| new DefaultUnleash(config); | ||
| // We've only instantiated the client once, so no errors should've been logged | ||
| assertThat(appender.list).isEmpty(); | ||
| Unleash unleash2 = new DefaultUnleash(config); | ||
| new DefaultUnleash(config); | ||
| // We've now instantiated the client twice, so we expect an error log line. | ||
| assertThat(appender.list).hasSize(1); | ||
| String id = config.getClientIdentifier(); | ||
| config.getClientIdentifier(); | ||
| assertThat(appender.list) | ||
| .extracting(ILoggingEvent::getFormattedMessage) | ||
| .containsExactly( | ||
|
|
@@ -174,7 +171,7 @@ public void multiple_instantiations_of_the_same_config_gives_errors() { | |
| + instanceId | ||
| + "] running. Please double check your code where you are instantiating the Unleash SDK"); | ||
| appender.list.clear(); | ||
| Unleash unleash3 = new DefaultUnleash(config); | ||
| new DefaultUnleash(config); | ||
| // We've now instantiated the client twice, so we expect an error log line. | ||
| assertThat(appender.list).hasSize(1); | ||
| assertThat(appender.list) | ||
|
|
@@ -197,10 +194,10 @@ public void supports_failing_hard_on_multiple_instantiations() { | |
| .instanceId("multiple_connection_exception") | ||
| .build(); | ||
| String id = config.getClientIdentifier(); | ||
| Unleash unleash1 = new DefaultUnleash(config); | ||
| new DefaultUnleash(config); | ||
| assertThatThrownBy( | ||
| () -> { | ||
| Unleash unleash2 = new DefaultUnleash(config, null, null, null, true); | ||
| new DefaultUnleash(config, null, null, null, true); | ||
| }) | ||
| .isInstanceOf(RuntimeException.class) | ||
| .withFailMessage( | ||
|
|
@@ -294,7 +291,7 @@ public void asynchronous_fetch_on_initialisation_fails_silently_and_retries() | |
| .unleashFeatureFetcherFactory((UnleashConfig c) -> fetcher) | ||
| .build(); | ||
|
|
||
| Unleash unleash = new DefaultUnleash(config); | ||
| new DefaultUnleash(config); | ||
| Thread.sleep(1); | ||
| verify(fetcher, times(1)).fetchFeatures(); | ||
| Thread.sleep(1200); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -59,6 +59,7 @@ public void fallback_function_should_be_invoked_and_return_true() { | |
| .thenReturn(new FlatResponse<Boolean>(false, null)); | ||
| Unleash unleash = new DefaultUnleash(baseConfig, engineProxy); | ||
|
|
||
| @SuppressWarnings("unchecked") | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Think this is correct thing to do here. Mocking is runtime goop so I don't think this has a meaningful way to determine the type |
||
| BiPredicate<String, UnleashContext> fallbackAction = mock(BiPredicate.class); | ||
| when(fallbackAction.test(eq("test"), any(UnleashContext.class))).thenReturn(true); | ||
|
|
||
|
|
@@ -73,6 +74,7 @@ public void fallback_function_should_be_invoked_also_with_context() { | |
| .thenReturn(new FlatResponse<Boolean>(false, null)); | ||
| Unleash unleash = new DefaultUnleash(baseConfig, engineProxy); | ||
|
|
||
| @SuppressWarnings("unchecked") | ||
| BiPredicate<String, UnleashContext> fallbackAction = mock(BiPredicate.class); | ||
| when(fallbackAction.test(eq("test"), any(UnleashContext.class))).thenReturn(true); | ||
|
|
||
|
|
@@ -89,6 +91,7 @@ void fallback_function_should_be_invoked_and_return_false() { | |
| .thenReturn(new FlatResponse<Boolean>(false, null)); | ||
| Unleash unleash = new DefaultUnleash(baseConfig, engineProxy); | ||
|
|
||
| @SuppressWarnings("unchecked") | ||
| BiPredicate<String, UnleashContext> fallbackAction = mock(BiPredicate.class); | ||
| when(fallbackAction.test(eq("test"), any(UnleashContext.class))).thenReturn(false); | ||
|
|
||
|
|
@@ -103,6 +106,7 @@ void fallback_function_should_not_be_called_when_toggle_is_defined() { | |
| .thenReturn(new FlatResponse<Boolean>(true, true)); | ||
| Unleash unleash = new DefaultUnleash(baseConfig, engineProxy); | ||
|
|
||
| @SuppressWarnings("unchecked") | ||
| BiPredicate<String, UnleashContext> fallbackAction = mock(BiPredicate.class); | ||
| when(fallbackAction.test(eq("test"), any(UnleashContext.class))).thenReturn(false); | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| package io.getunleash.integration; | ||
| package io.getunleash.streaming; | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure why this was in the integration package. It's alone in there, doesn't match it's actual package structure and that doesn't follow the pattern for our test packages anyway |
||
|
|
||
| import static com.github.tomakehurst.wiremock.client.WireMock.*; | ||
| import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All handled by the EngineProxy