dropwizard/dropwizard

View on GitHub
dropwizard-json-logging/src/test/java/io/dropwizard/logging/json/LayoutIntegrationTests.java

Summary

Maintainability
B
4 hrs
Test Coverage

Method testLogAccessJsonToConsole has 47 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    @Test
    void testLogAccessJsonToConsole() throws Exception {
        ConsoleAppenderFactory<IAccessEvent> consoleAppenderFactory = getAppenderFactory("yaml/json-access-log-default.yml");
        // Use sys.err, because there are some other log configuration messages in std.out
        consoleAppenderFactory.setTarget(ConsoleAppenderFactory.ConsoleStream.STDERR);

    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 testDeserializeAccessJson has 26 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          @Test
          void testDeserializeAccessJson() throws Exception {
              assertThat(getAppenderFactory("yaml/json-access-log.yml"))
                  .extracting(ConsoleAppenderFactory::getLayout)
                  .isInstanceOfSatisfying(AccessJsonLayoutBaseFactory.class, accessJsonLayoutBaseFactory -> assertThat(accessJsonLayoutBaseFactory)

        Do not hard code the IP address
        Open

                    assertThat(jsonNode.get("remoteAddress").asText()).isEqualTo("10.0.0.1");

        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
        }

        Do not hard code the IP address
        Open

                    when(request.getRemoteAddr()).thenReturn("10.0.0.1");

        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