dropwizard-json-logging/src/test/java/io/dropwizard/logging/json/LayoutIntegrationTests.java
Method testLogAccessJsonToConsole
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
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
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
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
Open
assertThat(jsonNode.get("remoteAddress").asText()).isEqualTo("10.0.0.1");
- Read upRead up
- Exclude checks
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
Open
when(request.getRemoteAddr()).thenReturn("10.0.0.1");
- Read upRead up
- Exclude checks
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
}