dropwizard/dropwizard

View on GitHub

Showing 869 of 869 total issues

Method getConverter has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

    @Override
    @Nullable
    public <T> ParamConverter<T> getConverter(final Class<T> rawType, final Type genericType, final Annotation[] annotations) {
        if (Optional.class.equals(rawType)) {
            final List<ClassTypePair> ctps = ReflectionHelper.getTypeArgumentAndClass(genericType);

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Method createClient has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

    protected ConfiguredCloseableHttpClient createClient(
            final org.apache.http.impl.client.HttpClientBuilder builder,
            final InstrumentedHttpClientConnectionManager manager,
            final String name) {
        final String cookiePolicy = configuration.isCookiesEnabled() ? CookieSpecs.DEFAULT : CookieSpecs.IGNORE_COOKIES;

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

FileAppenderFactoryTest has 24 methods (exceeds 20 allowed). Consider refactoring.
Open

class FileAppenderFactoryTest {

    static {
        BootstrapLogging.bootstrap();
    }

    AuthBaseTest has 24 methods (exceeds 20 allowed). Consider refactoring.
    Open

    public abstract class AuthBaseTest<T extends DropwizardResourceConfig> extends JerseyTest {
        protected static final String ADMIN_ROLE = "ADMIN";
        protected static final String ADMIN_USER = "good-guy";
        protected static final String ORDINARY_USER = "ordinary-guy";
        protected static final String BADGUY_USER = "bad-guy";
    Severity: Minor
    Found in dropwizard-auth/src/test/java/io/dropwizard/auth/AuthBaseTest.java - About 2 hrs to fix

      Builder has 24 methods (exceeds 20 allowed). Consider refactoring.
      Open

          static class Builder {
              private static final int MAX_SUGGESTIONS = 5;
      
              private String summary;
              private String detail = "";

        Method testHelpPage has 65 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            @Test
            void testHelpPage() throws Exception {
                MigrationTestSupport.createSubparser(dumpCommand).printHelp(new PrintWriter(new OutputStreamWriter(baos, UTF_8), true));
                assertThat(baos.toString(UTF_8.name())).isEqualTo(String.format(
                        "usage: db dump [-h] [--migrations MIGRATIONS-FILE] [--catalog CATALOG]%n" +

          File DropwizardTestSupport.java has 275 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          package io.dropwizard.testing;
          
          import com.fasterxml.jackson.databind.ObjectMapper;
          import io.dropwizard.Application;
          import io.dropwizard.Configuration;

            Method doGet has 63 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                @Override
                protected void doGet(HttpServletRequest req,
                                     HttpServletResponse resp) throws ServletException, IOException {
                    try {
                        final StringBuilder builder = new StringBuilder(req.getServletPath());

              AbstractAppenderFactory has 23 methods (exceeds 20 allowed). Consider refactoring.
              Open

              public abstract class AbstractAppenderFactory<E extends DeferredProcessingAware> implements AppenderFactory<E> {
                  private static final Logger LOGGER = LoggerFactory.getLogger(AbstractAppenderFactory.class);
              
                  @NotNull
                  protected Level threshold = Level.ALL;

                FileAppenderFactory has 23 methods (exceeds 20 allowed). Consider refactoring.
                Open

                @JsonTypeName("file")
                public class FileAppenderFactory<E extends DeferredProcessingAware> extends AbstractOutputStreamAppenderFactory<E> {
                
                    @Nullable
                    private String currentLogFilename;

                  Bootstrap has 22 methods (exceeds 20 allowed). Consider refactoring.
                  Open

                  public class Bootstrap<T extends Configuration> {
                      private final Application<T> application;
                      private final List<ConfiguredBundle<? super T>> configuredBundles;
                      private final List<Command> commands;
                  
                  
                  Severity: Minor
                  Found in dropwizard-core/src/main/java/io/dropwizard/setup/Bootstrap.java - About 2 hrs to fix

                    TaskServletTest has 22 methods (exceeds 20 allowed). Consider refactoring.
                    Open

                    class TaskServletTest {
                        private final Task gc = mock(Task.class);
                        private final PostBodyTask printJSON = mock(PostBodyTask.class);
                    
                        private final MetricRegistry metricRegistry = new MetricRegistry();

                      UnitOfWorkApplicationListenerTest has 22 methods (exceeds 20 allowed). Consider refactoring.
                      Open

                      @SuppressWarnings("HibernateResourceOpenedButNotSafelyClosed")
                      class UnitOfWorkApplicationListenerTest {
                          private final SessionFactory sessionFactory = mock(SessionFactory.class);
                          private final SessionFactory analyticsSessionFactory = mock(SessionFactory.class);
                          private final UnitOfWorkApplicationListener listener = new UnitOfWorkApplicationListener();

                        File DropwizardSSLConnectionSocketFactoryTest.java has 263 lines of code (exceeds 250 allowed). Consider refactoring.
                        Open

                        package io.dropwizard.client;
                        
                        import io.dropwizard.Application;
                        import io.dropwizard.Configuration;
                        import io.dropwizard.client.ssl.TlsConfiguration;

                          Method testBuildConnector has 57 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              @Test
                              void testBuildConnector() throws Exception {
                                  HttpConnectorFactory http = spy(new HttpConnectorFactory());
                                  http.setBindHost("127.0.0.1");
                                  http.setAcceptorThreads(Optional.of(1));

                            File UnitOfWorkApplicationListenerTest.java has 261 lines of code (exceeds 250 allowed). Consider refactoring.
                            Open

                            package io.dropwizard.hibernate;
                            
                            import org.glassfish.jersey.server.ExtendedUriInfo;
                            import org.glassfish.jersey.server.model.Resource;
                            import org.glassfish.jersey.server.monitoring.RequestEvent;

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

                                  @Test
                                  void testRemoveOnCancelTrue() {
                                      final String poolName = this.getClass().getSimpleName();
                              
                                      final ScheduledExecutorServiceBuilder test = new ScheduledExecutorServiceBuilder(this.le,
                              dropwizard-lifecycle/src/test/java/io/dropwizard/lifecycle/setup/ScheduledExecutorServiceBuilderTest.java on lines 101..121

                              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 145.

                              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

                                  @Test
                                  void testRemoveOnCancelFalse() {
                                      final String poolName = this.getClass().getSimpleName();
                              
                                      final ScheduledExecutorServiceBuilder test = new ScheduledExecutorServiceBuilder(this.le,
                              dropwizard-lifecycle/src/test/java/io/dropwizard/lifecycle/setup/ScheduledExecutorServiceBuilderTest.java on lines 79..99

                              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 145.

                              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

                                  @Test
                                  void isUnhealthyIfIsNotValid() {
                                      final Session session = mock(Session.class);
                                      when(factory.openSession()).thenReturn(session);
                              
                              
                              dropwizard-hibernate/src/test/java/io/dropwizard/hibernate/SessionFactoryHealthCheckTest.java on lines 63..81

                              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 143.

                              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

                                  @Test
                                  void isHealthyIfIsValid() {
                                      final Session session = mock(Session.class);
                                      when(factory.openSession()).thenReturn(session);
                              
                              
                              dropwizard-hibernate/src/test/java/io/dropwizard/hibernate/SessionFactoryHealthCheckTest.java on lines 110..128

                              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 143.

                              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

                              Severity
                              Category
                              Status
                              Source
                              Language