dropwizard/dropwizard

View on GitHub

Showing 869 of 869 total issues

Method testMinimalConfiguration has 36 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    @Test
    void testMinimalConfiguration() throws Exception {
        DataSourceFactory ds = getDataSourceFactory("yaml/minimal_db_pool.yml");

        assertThat(ds.getDriverClass()).isEqualTo("org.postgresql.Driver");

    Method configure has 36 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        @Override
        protected Application configure() {
            final MetricRegistry metricRegistry = new MetricRegistry();
            final SessionFactoryFactory factory = new SessionFactoryFactory();
            final DataSourceFactory dbConfig = new DataSourceFactory();

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

              assertThat(baos.toString(UTF_8.name())).isEqualTo(String.format(
                      "usage: db status [-h] [--migrations MIGRATIONS-FILE] [--catalog CATALOG]%n" +
                              "          [--schema SCHEMA] [-v] [-i CONTEXTS] [file]%n" +
                              "%n" +
                              "Check for pending change sets.%n" +
      dropwizard-migrations/src/test/java/io/dropwizard/migrations/DbDropAllCommandTest.java on lines 51..71

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

      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

              assertThat(out.toString(UTF_8.name())).isEqualTo(String.format(
                  "usage: db drop-all [-h] [--migrations MIGRATIONS-FILE] [--catalog CATALOG]%n" +
                      "          [--schema SCHEMA] --confirm-delete-everything [file]%n" +
                      "%n" +
                      "Delete all user-owned objects from the database.%n" +
      dropwizard-migrations/src/test/java/io/dropwizard/migrations/DbStatusCommandTest.java on lines 62..82

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

      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

      Method configure has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

          @Override
          public void configure(ResourceInfo resourceInfo, FeatureContext context) {
              final AnnotatedMethod am = new AnnotatedMethod(resourceInfo.getResourceMethod());
              final Annotation[][] parameterAnnotations = am.getParameterAnnotations();
              final Class<?>[] parameterTypes = am.getParameterTypes();

      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 buildAppender has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

          protected FileAppender<E> buildAppender(LoggerContext context) {
              if (archive) {
                  final RollingFileAppender<E> appender = new RollingFileAppender<>();
                  appender.setContext(context);
                  appender.setFile(currentLogFilename);

      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 configureLoggers has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

          private Logger configureLoggers(String name) {
              final Logger root = loggerContext.getLogger(org.slf4j.Logger.ROOT_LOGGER_NAME);
              loggerContext.reset();
      
              final LevelChangePropagator propagator = new LevelChangePropagator();

      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 buildSetUIDListener has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

          protected SetUIDListener buildSetUIDListener() {
              final SetUIDListener listener = new SetUIDListener();
      
              if (startsAsRoot != null) {
                  listener.setStartServerAsPrivileged(startsAsRoot);

      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 doGet has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

          @Override
          protected void doGet(HttpServletRequest req,
                               HttpServletResponse resp) throws ServletException, IOException {
              if (!Optional.ofNullable(req.getPathInfo()).filter(s -> !s.isEmpty()).isPresent()) {
                  try (final PrintWriter output = resp.getWriter()) {

      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

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

          @Test
          void nonCriticalHealthCheckFailureShouldNotResultInUnhealthyApp() {
              final HealthApp app = TEST_APP_RULE.getApplication();
              app.getCriticalCheckHealthy1().set(true);
              app.getCriticalCheckHealthy2().set(true);
      dropwizard-e2e/src/test/java/com/example/health/HealthIntegrationTest.java on lines 86..101

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

      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

      Method stopIfRequired has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

          private void stopIfRequired() {
              if (jettyServer != null) {
                  for (ServiceListener<C> listener : listeners) {
                      try {
                          listener.onStop(this);

      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

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

          @Test
          void createPerson() {
              final Person jeff = daoTestRule.inTransaction(() -> personDAO.create(new Person("Jeff", "The plumber", 1995)));
              assertThat(jeff.getId()).isPositive();
              assertThat(jeff.getFullName()).isEqualTo("Jeff");
      dropwizard-example/src/test/java/com/example/helloworld/db/PersonDAOTest.java on lines 31..39

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

      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

      Method logMethodLines has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

              private List<EndpointLogLine> logMethodLines(Resource resource, String contextPath) {
                  final List<EndpointLogLine> methodLines = new ArrayList<>();
                  for (ResourceMethod method : resource.getAllMethods()) {
                      if ("OPTIONS".equalsIgnoreCase(method.getHttpMethod())) {
                          continue;

      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

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

          @Test
          void healthCheckShouldReportHealthyWhenAllHealthChecksHealthy() {
              final HealthApp app = TEST_APP_RULE.getApplication();
              app.getCriticalCheckHealthy1().set(true);
              app.getCriticalCheckHealthy2().set(true);
      dropwizard-e2e/src/test/java/com/example/health/HealthIntegrationTest.java on lines 103..119

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

      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

      Method startIfRequired has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

          private void startIfRequired() throws Exception {
              if (jettyServer != null) {
                  return;
              }
      
      

      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

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

          @Test
          void createPerson() {
              final Person jeff = daoTestRule.inTransaction(() -> personDAO.create(new Person("Jeff", "The plumber", 1995)));
              assertThat(jeff.getId()).isPositive();
              assertThat(jeff.getFullName()).isEqualTo("Jeff");
      dropwizard-example/src/test/java/com/example/helloworld/db/PersonDAOIntegrationTest.java on lines 50..58

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

      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

      Method doPost has 35 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          @Override
          protected void doPost(HttpServletRequest req,
                                HttpServletResponse resp) throws ServletException, IOException {
              final String pathInfo = req.getPathInfo();
              final Task task = pathInfo != null ? tasks.get(pathInfo) : null;

        Method testLogJsonToConsole has 35 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            @Test
            void testLogJsonToConsole() throws Exception {
                ConsoleAppenderFactory<ILoggingEvent> consoleAppenderFactory = getAppenderFactory("yaml/json-log-default.yml");
                DefaultLoggingFactory defaultLoggingFactory = new DefaultLoggingFactory();
                defaultLoggingFactory.setAppenders(Collections.singletonList(consoleAppenderFactory));

          Method addsTheViewMessageBodyWriterWithSingleViewRendererToTheEnvironment has 35 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              @Test
              void addsTheViewMessageBodyWriterWithSingleViewRendererToTheEnvironment() throws Exception {
                  final String configurationKey = "freemarker";
                  final String testKey = "testKey";
                  final Map<String, String> freeMarkerConfig = Collections.singletonMap(testKey, "yes");

            Method shouldContinueScheduledCheckingWhileDelayingShutdown has 35 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                @Test
                @DisabledOnOs(OS.WINDOWS)
                void shouldContinueScheduledCheckingWhileDelayingShutdown() throws Exception {
                    // given
                    final int checkIntervalMillis = 10;
              Severity
              Category
              Status
              Source
              Language