From 4c004f0a873818956630fca0a4056b20c3973e60 Mon Sep 17 00:00:00 2001 From: percyashu Date: Mon, 8 Jun 2020 00:14:27 +0100 Subject: [PATCH] FINERACT-822 enable DoubleBraceInitialization error --- fineract-provider/build.gradle | 2 +- .../ReadWriteNonCoreDataServiceImpl.java | 24 +++++++++---------- .../exception/ResetPasswordException.java | 14 ++++------- ...SpringSecurityPlatformSecurityContext.java | 9 +++---- 4 files changed, 20 insertions(+), 29 deletions(-) diff --git a/fineract-provider/build.gradle b/fineract-provider/build.gradle index 440f8a692..fc6b7ddc7 100644 --- a/fineract-provider/build.gradle +++ b/fineract-provider/build.gradle @@ -328,7 +328,6 @@ tasks.withType(JavaCompile) { "ModifiedButNotUsed", "JodaPlusMinusLong", "TypeParameterUnusedInFormals", - "DoubleBraceInitialization", "UnusedNestedClass", "UndefinedEquals", ) @@ -374,6 +373,7 @@ tasks.withType(JavaCompile) { "OperatorPrecedence", "EqualsGetClass", "JdkObsolete", + "DoubleBraceInitialization", // "ReturnMissingNullable", // "InconsistentOverloads", // "MethodCanBeStatic", diff --git a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/dataqueries/service/ReadWriteNonCoreDataServiceImpl.java b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/dataqueries/service/ReadWriteNonCoreDataServiceImpl.java index e1eb06e78..25442375c 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/dataqueries/service/ReadWriteNonCoreDataServiceImpl.java +++ b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/dataqueries/service/ReadWriteNonCoreDataServiceImpl.java @@ -18,6 +18,7 @@ */ package org.apache.fineract.infrastructure.dataqueries.service; +import com.google.common.collect.ImmutableMap; import com.google.gson.JsonArray; import com.google.gson.JsonElement; import com.google.gson.JsonObject; @@ -89,19 +90,16 @@ public class ReadWriteNonCoreDataServiceImpl implements ReadWriteNonCoreDataServ private final static String CODE_VALUES_TABLE = "m_code_value"; private final static Logger LOG = LoggerFactory.getLogger(ReadWriteNonCoreDataServiceImpl.class); - private final static HashMap apiTypeToMySQL = new HashMap() { - - { - put("string", "VARCHAR"); - put("number", "INT"); - put("boolean", "BIT"); - put("decimal", "DECIMAL"); - put("date", "DATE"); - put("datetime", "DATETIME"); - put("text", "TEXT"); - put("dropdown", "INT"); - } - }; + private final static ImmutableMap apiTypeToMySQL = ImmutableMap.builder() + .put("string", "VARCHAR") + .put("number", "INT") + .put("boolean", "BIT") + .put("decimal", "DECIMAL") + .put("date", "DATE") + .put("datetime", "DATETIME") + .put("text", "TEXT") + .put("dropdown", "INT") + .build(); private final static List stringDataTypes = Arrays.asList("char", "varchar", "blob", "text", "tinyblob", "tinytext", "mediumblob", "mediumtext", "longblob", "longtext"); diff --git a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/security/exception/ResetPasswordException.java b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/security/exception/ResetPasswordException.java index 4f8ecbb76..b5f69b858 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/security/exception/ResetPasswordException.java +++ b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/security/exception/ResetPasswordException.java @@ -19,6 +19,7 @@ package org.apache.fineract.infrastructure.security.exception; import java.util.ArrayList; +import java.util.List; import org.apache.fineract.infrastructure.core.data.ApiParameterError; import org.apache.fineract.infrastructure.core.exception.PlatformApiDataValidationException; @@ -31,17 +32,12 @@ public class ResetPasswordException extends PlatformApiDataValidationException { public ResetPasswordException(final Long userId) { super("error.msg.password.outdated", "The password of the user with id " + userId + " has expired, please reset it", - new ArrayList() { - - { - add(ApiParameterError.parameterError("error.msg.password.outdated", "The password of the user with id " + userId - + " has expired, please reset it", "userId", userId)); - - } - } + new ArrayList (List.of( + ApiParameterError.parameterError("error.msg.password.outdated", "The password of the user with id " + userId + + " has expired, please reset it", "userId", userId))) ); } -} \ No newline at end of file +} diff --git a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/security/service/SpringSecurityPlatformSecurityContext.java b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/security/service/SpringSecurityPlatformSecurityContext.java index 6b9df7947..9dcde6c58 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/security/service/SpringSecurityPlatformSecurityContext.java +++ b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/security/service/SpringSecurityPlatformSecurityContext.java @@ -49,12 +49,9 @@ public class SpringSecurityPlatformSecurityContext implements PlatformSecurityCo private final ConfigurationDomainService configurationDomainService; - protected static final List EXEMPT_FROM_PASSWORD_RESET_CHECK = new ArrayList() { - - { - add(new CommandWrapperBuilder().updateUser(null).build()); - } - }; + protected static final List EXEMPT_FROM_PASSWORD_RESET_CHECK = new ArrayList(List.of( + new CommandWrapperBuilder().updateUser(null).build()) + ); @Autowired SpringSecurityPlatformSecurityContext(final ConfigurationDomainService configurationDomainService) {