dropwizard/dropwizard

View on GitHub
dropwizard-client/src/test/java/io/dropwizard/client/JerseyClientBuilderTest.java

Summary

Maintainability
C
1 day
Test Coverage

JerseyClientBuilderTest has 33 methods (exceeds 20 allowed). Consider refactoring.
Open

class JerseyClientBuilderTest {
    private final MetricRegistry metricRegistry = new MetricRegistry();
    private final JerseyClientBuilder builder = new JerseyClientBuilder(metricRegistry);
    private final LifecycleEnvironment lifecycleEnvironment = spy(new LifecycleEnvironment(metricRegistry));
    private final Environment environment = mock(Environment.class);

    File JerseyClientBuilderTest.java has 338 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    package io.dropwizard.client;
    
    import com.codahale.metrics.MetricRegistry;
    import com.codahale.metrics.httpclient.HttpClientMetricNameStrategies;
    import com.codahale.metrics.httpclient.HttpClientMetricNameStrategy;

      Method readFrom has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

              public JerseyClientBuilderTest readFrom(Class<JerseyClientBuilderTest> type, Type genericType,
                                                      Annotation[] annotations, MediaType mediaType,
                                                      MultivaluedMap<String, String> httpHeaders, InputStream entityStream)

        Identical blocks of code found in 3 locations. Consider refactoring.
        Open

                for (Object o : client.getConfiguration().getInstances()) {
                    if (o instanceof DropwizardExecutorProvider) {
                        final DropwizardExecutorProvider provider = (DropwizardExecutorProvider) o;
                        assertThat(provider.getExecutorService()).isSameAs(executorService);
                    }
        dropwizard-client/src/test/java/io/dropwizard/client/JerseyClientBuilderTest.java on lines 157..162
        dropwizard-client/src/test/java/io/dropwizard/client/JerseyClientBuilderTest.java on lines 168..173

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 44.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Identical blocks of code found in 3 locations. Consider refactoring.
        Open

                for (Object o : client.getConfiguration().getInstances()) {
                    if (o instanceof DropwizardExecutorProvider) {
                        final DropwizardExecutorProvider provider = (DropwizardExecutorProvider) o;
                        assertThat(provider.getExecutorService()).isSameAs(executorService);
                    }
        dropwizard-client/src/test/java/io/dropwizard/client/JerseyClientBuilderTest.java on lines 157..162
        dropwizard-client/src/test/java/io/dropwizard/client/JerseyClientBuilderTest.java on lines 180..185

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 44.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Identical blocks of code found in 3 locations. Consider refactoring.
        Open

                for (Object o : client.getConfiguration().getInstances()) {
                    if (o instanceof DropwizardExecutorProvider) {
                        final DropwizardExecutorProvider provider = (DropwizardExecutorProvider) o;
                        assertThat(provider.getExecutorService()).isSameAs(executorService);
                    }
        dropwizard-client/src/test/java/io/dropwizard/client/JerseyClientBuilderTest.java on lines 168..173
        dropwizard-client/src/test/java/io/dropwizard/client/JerseyClientBuilderTest.java on lines 180..185

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 44.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

                final HttpRoutePlanner customHttpRoutePlanner = new SystemDefaultRoutePlanner(new ProxySelector() {
                    @Override
                    public List<Proxy> select(URI uri) {
                        return Collections.singletonList(new Proxy(Proxy.Type.HTTP, new InetSocketAddress("192.168.53.12", 8080)));
                    }
        dropwizard-client/src/test/java/io/dropwizard/client/HttpClientBuilderTest.java on lines 439..449

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 40.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Do not hard code the IP address
        Open

                        return Collections.singletonList(new Proxy(Proxy.Type.HTTP, new InetSocketAddress("192.168.53.12", 8080)));

        AvoidUsingHardCodedIP

        Since: PMD 4.1

        Priority: Medium

        Categories: Style

        Remediation Points: 50000

        Application with hard-coded IP addresses can become impossible to deploy in some cases. Externalizing IP adresses is preferable.

        Example:

        public class Foo {
         private String ip = '127.0.0.1'; // not recommended
        }

        There are no issues that match your filters.

        Category
        Status