use SpotBugs & fix over 300 high priority rule violations (FINERACT-702)

This PR also serves as a base solution for upcoming FINERACT-712 and
FINERACT-696.  It includes using Objects.equals() to prevent NPEs, and
adding gradle check to run SpotBugs on Travis CI.

PS: SpotBugs is the successor to (and same code as) FindBugs.
This commit is contained in:
Awasum Yannick
2020-01-12 13:16:42 +01:00
committed by Michael Vorburger ⛑️
parent 75f7c5947d
commit af0dd7e5f3
145 changed files with 1273 additions and 1191 deletions
+14 -1
View File
@@ -42,6 +42,10 @@ buildscript {
classpath "org.apache.openjpa:openjpa:$openJPAVersion"
classpath 'com.radcortez.gradle:openjpa-gradle-plugin:3.1.0'
classpath 'gradle.plugin.org.nosphere.apache:creadur-rat-gradle:0.2.2'
classpath "com.github.spotbugs:spotbugs-gradle-plugin:2.0.1"
//Use Guava version 23+ as a workaround to spotbug intergration.
// See: https://github.com/spotbugs/spotbugs-gradle-plugin/issues/128#issuecomment-535864882
classpath 'com.google.guava:guava:28.1-jre'
}
}
@@ -57,6 +61,7 @@ apply plugin: 'com.bmuschko.tomcat'
apply plugin: 'project-report'
apply plugin: 'java-library'
apply plugin: 'openjpa'
apply plugin: "com.github.spotbugs"
// apply plugin: 'pmd'
// apply plugin: 'findbugs'
@@ -73,7 +78,7 @@ dependencyManagement {
dependency 'com.squareup.okhttp:okhttp:2.0.0'
dependency 'com.squareup.okhttp:okhttp-urlconnection:2.0.0'
dependency 'com.google.code.gson:gson:+'
dependency 'com.google.guava:guava:15.0'
dependency 'com.google.guava:guava:28.1-jre'
dependency 'joda-time:joda-time:+'
dependency 'org.apache.commons:commons-email:1.3.3'
dependency 'org.apache.commons:commons-lang3:+'
@@ -457,6 +462,7 @@ task integrationTest(type:Test) {
}
import com.github.spotbugs.SpotBugsTask
import groovy.sql.Sql
repositories {
@@ -522,3 +528,10 @@ springBoot {
bootWar {
mainClassName = 'org.apache.fineract.ServerWithMariaDB4jApplication'
}
// To generate an HTML report instead of XML
tasks.withType(SpotBugsTask) {
reports.xml.enabled = false
reports.html.enabled = true
reportLevel = "high"
}