FINERACT-822 Integrating Error Prone
This commit is contained in:
committed by
Michael Vorburger ⛑️
parent
896571d479
commit
e10a78b2bd
@@ -47,6 +47,7 @@ buildscript {
|
|||||||
classpath "gradle.plugin.com.github.spotbugs.snom:spotbugs-gradle-plugin:4.2.0"
|
classpath "gradle.plugin.com.github.spotbugs.snom:spotbugs-gradle-plugin:4.2.0"
|
||||||
classpath "gradle.plugin.com.github.andygoossens:gradle-modernizer-plugin:1.3.0"
|
classpath "gradle.plugin.com.github.andygoossens:gradle-modernizer-plugin:1.3.0"
|
||||||
classpath "gradle.plugin.com.gorylenko.gradle-git-properties:gradle-git-properties:2.2.2"
|
classpath "gradle.plugin.com.gorylenko.gradle-git-properties:gradle-git-properties:2.2.2"
|
||||||
|
classpath "net.ltgt.gradle:gradle-errorprone-plugin:1.1.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -67,6 +68,7 @@ apply plugin: 'checkstyle'
|
|||||||
apply plugin: 'com.github.andygoossens.gradle-modernizer-plugin'
|
apply plugin: 'com.github.andygoossens.gradle-modernizer-plugin'
|
||||||
apply plugin: 'jacoco'
|
apply plugin: 'jacoco'
|
||||||
apply plugin: "com.gorylenko.gradle-git-properties"
|
apply plugin: "com.gorylenko.gradle-git-properties"
|
||||||
|
apply plugin: "net.ltgt.errorprone"
|
||||||
// apply plugin: 'pmd'
|
// apply plugin: 'pmd'
|
||||||
|
|
||||||
dependencyManagement {
|
dependencyManagement {
|
||||||
@@ -278,6 +280,88 @@ configurations {
|
|||||||
tasks.withType(JavaCompile) {
|
tasks.withType(JavaCompile) {
|
||||||
options.compilerArgs += ["-Xlint:unchecked","-Xlint:cast","-Werror"] // TODO FINERACT-959 (gradually) enable -Xlint:all (see "javac -help -X")
|
options.compilerArgs += ["-Xlint:unchecked","-Xlint:cast","-Werror"] // TODO FINERACT-959 (gradually) enable -Xlint:all (see "javac -help -X")
|
||||||
options.deprecation = true
|
options.deprecation = true
|
||||||
|
options.errorprone {
|
||||||
|
disableWarningsInGeneratedCode = true
|
||||||
|
//Todo Remove necessary checks from this list
|
||||||
|
disable("UnusedVariable",
|
||||||
|
"VariableNameSameAsType",
|
||||||
|
"InconsistentCapitalization",
|
||||||
|
"UnnecessaryParentheses",
|
||||||
|
"ClassCanBeStatic",
|
||||||
|
"MissingCasesInEnumSwitch",
|
||||||
|
"CompareToZero",
|
||||||
|
"OperatorPrecedence",
|
||||||
|
"MixedMutabilityReturnType",
|
||||||
|
"SameNameButDifferent",
|
||||||
|
"EqualsGetClass",
|
||||||
|
"ReferenceEquality",
|
||||||
|
"StringSplitter",
|
||||||
|
"MissingOverride",
|
||||||
|
"BigDecimalEquals",
|
||||||
|
"ImmutableEnumChecker",
|
||||||
|
"EqualsUnsafeCast",
|
||||||
|
"AssertEqualsArgumentOrderChecker",
|
||||||
|
"BoxedPrimitiveEquality",
|
||||||
|
"BadImport",
|
||||||
|
"UnusedMethod",
|
||||||
|
"ModifiedButNotUsed",
|
||||||
|
"ArgumentSelectionDefectChecker",
|
||||||
|
"JodaPlusMinusLong",
|
||||||
|
"TypeParameterUnusedInFormals",
|
||||||
|
"DoubleBraceInitialization",
|
||||||
|
"UnusedNestedClass",
|
||||||
|
"UndefinedEquals",
|
||||||
|
"JdkObsolete",
|
||||||
|
"OperatorPrecedence",
|
||||||
|
"NarrowingCompoundAssignment"
|
||||||
|
)
|
||||||
|
//TODO gradually enable these checks
|
||||||
|
error( "DefaultCharset",
|
||||||
|
// "ReturnMissingNullable",
|
||||||
|
// "InconsistentOverloads",
|
||||||
|
// "MethodCanBeStatic",
|
||||||
|
// "Var",
|
||||||
|
// "ConstantField",
|
||||||
|
// "EmptySetMultibindingContributions",
|
||||||
|
// "MixedArrayDimensions",
|
||||||
|
// "MultipleTopLevelClasses",
|
||||||
|
// "MultiVariableDeclaration",
|
||||||
|
// "PackageLocation",
|
||||||
|
// "PrivateConstructorForNoninstantiableModule",
|
||||||
|
// "RemoveUnusedImports",
|
||||||
|
// "UnnecessaryStaticImport",
|
||||||
|
// "UseBinds",
|
||||||
|
// "WildcardImport",
|
||||||
|
// "FutureReturnValueIgnored",
|
||||||
|
// "IntLongMath",
|
||||||
|
// "FloatCast",
|
||||||
|
// "ClassNewInstance",
|
||||||
|
// "ConstructorInvokesOverridable",
|
||||||
|
// "ThreeLetterTimeZoneID",
|
||||||
|
// "UnsafeFinalization",
|
||||||
|
// "MutableMethodReturnType",
|
||||||
|
// "SynchronizeOnNonFinalField",
|
||||||
|
// "WaitNotInLoop",
|
||||||
|
// "SwitchDefault",
|
||||||
|
// "ReachabilityFenceUsage",
|
||||||
|
// "BoxedPrimitiveConstructor",
|
||||||
|
// "InjectOnConstructorOfAbstractClass",
|
||||||
|
//// "StringSplitter",
|
||||||
|
// "UnnecessaryDefaultInEnumSwitch",
|
||||||
|
// "StreamResourceLeak",
|
||||||
|
//// "InconsistentCapitalization",
|
||||||
|
// "TruthIncompatibleType",
|
||||||
|
// "ByteBufferBackingArray",
|
||||||
|
// "OrphanedFormatString",
|
||||||
|
// "CatchAndPrintStackTrace",
|
||||||
|
// "VarTypeName",
|
||||||
|
// "ObjectToString",
|
||||||
|
// "AssertThrowsMultipleStatements",
|
||||||
|
// "FieldCanBeFinal"
|
||||||
|
)
|
||||||
|
}
|
||||||
|
options.compilerArgs +=["-Xmaxwarns",1500,"-Xmaxerrs",1500]
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
apply from: 'dependencies.gradle'
|
apply from: 'dependencies.gradle'
|
||||||
@@ -398,6 +482,9 @@ dependencies {
|
|||||||
tomcat "org.apache.tomcat:tomcat:9.0.34@zip"
|
tomcat "org.apache.tomcat:tomcat:9.0.34@zip"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
errorprone "com.google.errorprone:error_prone_core:2.3.4"
|
||||||
|
}
|
||||||
cargo {
|
cargo {
|
||||||
containerId "tomcat9x"
|
containerId "tomcat9x"
|
||||||
|
|
||||||
|
|||||||
+8
@@ -31,6 +31,7 @@ import org.apache.fineract.integrationtests.common.Utils;
|
|||||||
import org.apache.fineract.integrationtests.common.organisation.StaffHelper;
|
import org.apache.fineract.integrationtests.common.organisation.StaffHelper;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
|
import org.junit.Ignore;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
public class StaffTest {
|
public class StaffTest {
|
||||||
@@ -91,6 +92,8 @@ public class StaffTest {
|
|||||||
StaffHelper.createStaffWithJson(requestSpec, responseSpecForValidationError, new Gson().toJson(map));
|
StaffHelper.createStaffWithJson(requestSpec, responseSpecForValidationError, new Gson().toJson(map));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Ignore //TODO FINERACT-1005
|
||||||
public void testStaffCreateMaxNameLength() {
|
public void testStaffCreateMaxNameLength() {
|
||||||
|
|
||||||
final HashMap<String, Object> map = new HashMap<>();
|
final HashMap<String, Object> map = new HashMap<>();
|
||||||
@@ -102,6 +105,7 @@ public class StaffTest {
|
|||||||
StaffHelper.createStaffWithJson(requestSpec, responseSpec, new Gson().toJson(map));
|
StaffHelper.createStaffWithJson(requestSpec, responseSpec, new Gson().toJson(map));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testStaffCreateExternalIdValidationError() {
|
public void testStaffCreateExternalIdValidationError() {
|
||||||
final HashMap<String, Object> map = new HashMap<>();
|
final HashMap<String, Object> map = new HashMap<>();
|
||||||
|
|
||||||
@@ -183,6 +187,8 @@ public class StaffTest {
|
|||||||
Assert.assertEquals(mobileNo, changes.get("mobileNo"));
|
Assert.assertEquals(mobileNo, changes.get("mobileNo"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Ignore // TODO FINERACT- 1005
|
||||||
public void testStaffUpdateLongExternalIdError() {
|
public void testStaffUpdateLongExternalIdError() {
|
||||||
final HashMap<String, Object> map = new HashMap<>();
|
final HashMap<String, Object> map = new HashMap<>();
|
||||||
map.put("externalId", Utils.randomStringGenerator("EXT", 98));
|
map.put("externalId", Utils.randomStringGenerator("EXT", 98));
|
||||||
@@ -190,6 +196,8 @@ public class StaffTest {
|
|||||||
StaffHelper.updateStaff(requestSpec, responseSpecForValidationError, 1, map);
|
StaffHelper.updateStaff(requestSpec, responseSpecForValidationError, 1, map);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Ignore // TODO FINERACT- 1005
|
||||||
public void testStaffUpdateWrongActiveState() {
|
public void testStaffUpdateWrongActiveState() {
|
||||||
final HashMap<String, Object> map = new HashMap<>();
|
final HashMap<String, Object> map = new HashMap<>();
|
||||||
map.put("isActive", "xyz");
|
map.put("isActive", "xyz");
|
||||||
|
|||||||
+4
-3
@@ -19,6 +19,7 @@
|
|||||||
package org.apache.fineract.integrationtests.common;
|
package org.apache.fineract.integrationtests.common;
|
||||||
|
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
public class OfficeDomain {
|
public class OfficeDomain {
|
||||||
|
|
||||||
@@ -127,7 +128,7 @@ public class OfficeDomain {
|
|||||||
hash += this.externalId.hashCode();
|
hash += this.externalId.hashCode();
|
||||||
}
|
}
|
||||||
if (this.openingDate != null) {
|
if (this.openingDate != null) {
|
||||||
hash += this.openingDate.hashCode();
|
hash += Arrays.hashCode(this.openingDate);
|
||||||
}
|
}
|
||||||
if (this.hierarchy != null) {
|
if (this.hierarchy != null) {
|
||||||
hash += this.hierarchy.hashCode();
|
hash += this.hierarchy.hashCode();
|
||||||
@@ -151,11 +152,11 @@ public class OfficeDomain {
|
|||||||
if (this.id == od.getId() && this.name.equals(od.getName())
|
if (this.id == od.getId() && this.name.equals(od.getName())
|
||||||
&& this.nameDecorated.equals(od.getName())
|
&& this.nameDecorated.equals(od.getName())
|
||||||
&& this.externalId.equals(od.getExternalId())
|
&& this.externalId.equals(od.getExternalId())
|
||||||
&& this.openingDate.equals(od.getOpeningDate())
|
&& Arrays.equals(this.openingDate, od.getOpeningDate())
|
||||||
&& this.hierarchy.equals(od.getHierarchy())) {
|
&& this.hierarchy.equals(od.getHierarchy())) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-1
@@ -284,13 +284,14 @@ public class VariableInstallmentsDecliningBalanceHelper {
|
|||||||
}
|
}
|
||||||
return toReturn;
|
return toReturn;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String formatDate(ArrayList list) {
|
public static String formatDate(ArrayList list) {
|
||||||
Calendar cal = Calendar.getInstance();
|
Calendar cal = Calendar.getInstance();
|
||||||
cal.set(Calendar.YEAR, (int) list.get(0));
|
cal.set(Calendar.YEAR, (int) list.get(0));
|
||||||
cal.set(Calendar.MONTH, (int) list.get(1) - 1);
|
cal.set(Calendar.MONTH, (int) list.get(1) - 1);
|
||||||
cal.set(Calendar.DAY_OF_MONTH, (int) list.get(2));
|
cal.set(Calendar.DAY_OF_MONTH, (int) list.get(2));
|
||||||
Date date = cal.getTime();
|
Date date = cal.getTime();
|
||||||
DateFormat requiredFormat = new SimpleDateFormat("dd MMMM YYYY");
|
DateFormat requiredFormat = new SimpleDateFormat("dd MMMM yyyy");
|
||||||
return requiredFormat.format(date);
|
return requiredFormat.format(date);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -209,7 +209,7 @@ public class VariableInstallmentsFlatHelper {
|
|||||||
cal.set(Calendar.MONTH, (int) list.get(1) - 1);
|
cal.set(Calendar.MONTH, (int) list.get(1) - 1);
|
||||||
cal.set(Calendar.DAY_OF_MONTH, (int) list.get(2));
|
cal.set(Calendar.DAY_OF_MONTH, (int) list.get(2));
|
||||||
Date date = cal.getTime();
|
Date date = cal.getTime();
|
||||||
DateFormat requiredFormat = new SimpleDateFormat("dd MMMM YYYY");
|
DateFormat requiredFormat = new SimpleDateFormat("dd MMMM yyyy");
|
||||||
return requiredFormat.format(date);
|
return requiredFormat.format(date);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+7
-3
@@ -88,9 +88,13 @@ public class MathUtil {
|
|||||||
/** @return calculates minimum of the two values considering null values
|
/** @return calculates minimum of the two values considering null values
|
||||||
* @param notNull if true then null parameter is omitted, otherwise returns null */
|
* @param notNull if true then null parameter is omitted, otherwise returns null */
|
||||||
public static Long min(Long first, Long second, boolean notNull) {
|
public static Long min(Long first, Long second, boolean notNull) {
|
||||||
return first == null
|
if (first == null){
|
||||||
? (notNull ? second : null)
|
return notNull ? second : null;
|
||||||
: second == null ? (notNull ? first : null) : Math.min(first, second);
|
}
|
||||||
|
if (second == null) {
|
||||||
|
return notNull ? first : null;
|
||||||
|
}
|
||||||
|
return Math.min(first, second);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @return calculates minimum of the values considering null values
|
/** @return calculates minimum of the values considering null values
|
||||||
|
|||||||
+1
-1
@@ -42,7 +42,7 @@ public class FloatingRateDTO {
|
|||||||
public BigDecimal fetchBaseRate(LocalDate date) {
|
public BigDecimal fetchBaseRate(LocalDate date) {
|
||||||
BigDecimal rate = null;
|
BigDecimal rate = null;
|
||||||
for (FloatingRatePeriodData periodData : this.baseLendingRatePeriods) {
|
for (FloatingRatePeriodData periodData : this.baseLendingRatePeriods) {
|
||||||
final LocalDate periodFromDate = new LocalDate(periodData.getFromDate());
|
final LocalDate periodFromDate = periodData.getFromDate();
|
||||||
if (periodFromDate.isBefore(date) || periodFromDate.isEqual(date)) {
|
if (periodFromDate.isBefore(date) || periodFromDate.isEqual(date)) {
|
||||||
rate = periodData.getInterestRate();
|
rate = periodData.getInterestRate();
|
||||||
break;
|
break;
|
||||||
|
|||||||
+1
-1
@@ -62,7 +62,7 @@ public class FloatingRatePeriodData implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
public LocalDate getFromDateAsLocalDate() {
|
public LocalDate getFromDateAsLocalDate() {
|
||||||
return new LocalDate(this.fromDate);
|
return this.fromDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BigDecimal getInterestRate() {
|
public BigDecimal getInterestRate() {
|
||||||
|
|||||||
+2
-2
@@ -1657,7 +1657,7 @@ public class SavingsAccountWritePlatformServiceJpaRepositoryImpl implements Savi
|
|||||||
|
|
||||||
for (SavingsAccountTransaction transaction : savingsAccount.getTransactions()) {
|
for (SavingsAccountTransaction transaction : savingsAccount.getTransactions()) {
|
||||||
if ((transaction.getTransactionLocalDate().isEqual(transferDate)
|
if ((transaction.getTransactionLocalDate().isEqual(transferDate)
|
||||||
&& transaction.getTransactionLocalDate().isAfter(new LocalDate(transferDate)))
|
&& transaction.getTransactionLocalDate().isAfter(transferDate))
|
||||||
|| transaction.getTransactionLocalDate().isAfter(transferDate)) {
|
|| transaction.getTransactionLocalDate().isAfter(transferDate)) {
|
||||||
throw new GeneralPlatformDomainRuleException(TransferApiConstants.transferClientSavingsException,
|
throw new GeneralPlatformDomainRuleException(TransferApiConstants.transferClientSavingsException,
|
||||||
TransferApiConstants.transferClientSavingsException, new LocalDate(transaction.createdDate()),
|
TransferApiConstants.transferClientSavingsException, new LocalDate(transaction.createdDate()),
|
||||||
@@ -1667,4 +1667,4 @@ public class SavingsAccountWritePlatformServiceJpaRepositoryImpl implements Savi
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user