diff --git a/app/build.gradle b/app/build.gradle
index d591f9d4d..1c35b6c9b 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -17,16 +17,18 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
+import com.github.spotbugs.snom.SpotBugsTask
apply plugin: 'com.android.application'
-//apply plugin: 'findbugs'
apply plugin: 'kotlin-android'
+apply plugin: 'com.github.spotbugs'
+apply plugin: 'kotlin-kapt'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
apply plugin: 'kotlinx-serialization'
def taskRequest = getGradle().getStartParameter().getTaskRequests().toString()
-if (taskRequest.contains("Gplay") || taskRequest.contains("findbugs") ||
+if (taskRequest.contains("Gplay") || taskRequest.contains("spotbugs") ||
taskRequest.contains("lint")) {
apply from: 'gplay.gradle'
}
@@ -151,6 +153,26 @@ android {
htmlOutput file("$project.buildDir/reports/lint/lint.html")
disable 'MissingTranslation'
}
+
+ android.applicationVariants.all { variant ->
+ String variantName = variant.name
+ String capVariantName = variantName.substring(0, 1).toUpperCase() + variantName.substring(1)
+ tasks.register("spotbugs${capVariantName}Report", SpotBugsTask) {
+ ignoreFailures = true // should continue checking
+ effort = "max"
+ reportLevel = "medium"
+ classes = fileTree("${project.rootDir}/app/build/intermediates/javac/${variantName}/classes/com/nextcloud/talk/")
+ excludeFilter = file("${project.rootDir}/findbugs-filter.xml")
+
+ reports {
+ xml.enabled = false
+ html {
+ enabled = true
+ destination = file("$project.buildDir/reports/spotbugs/spotbugs.html")
+ }
+ }
+ }
+ }
}
ext {
@@ -325,4 +347,7 @@ dependencies {
})
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.0.0'
implementation 'com.github.Kennyc1012:BottomSheet:2.4.1'
+
+ spotbugsPlugins 'com.h3xstream.findsecbugs:findsecbugs-plugin:1.10.1'
+ spotbugsPlugins 'com.mebigfatguy.fb-contrib:fb-contrib:7.4.7'
}
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 14f5bdd0b..9434b8661 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -81,6 +81,11 @@
android:name="android.max_aspect"
android:value="10" />
+
Summary<\/h1>/,/Warnings<\/h1>/p" app/build/reports/findbugs/findbugs.html | head -n-1 | sed s'/<\/a>//'g | sed s'///'g | sed s'/Summary/FindBugs (master)/' | tr "\"" "\'" | tr -d "\r\n")
+ summary=$(sed -n "/Summary<\/h1>/,/Warnings<\/h1>/p" app/build/reports/spotbugs/spotbugs.html | head -n-1 | sed s'/<\/a>//'g | sed s'///'g | sed s'/Summary/FindBugs (master)/' | tr "\"" "\'" | tr -d "\r\n")
curl -u $4:$5 -X PUT -d "$summary" https://nextcloud.kaminsky.me/remote.php/webdav/talk-findbugs/findbugs.html
if [ $lintValue -ne 1 ]; then
@@ -40,7 +40,7 @@ else
curl 2>/dev/null -u $4:$5 -X PUT https://nextcloud.kaminsky.me/remote.php/webdav/talk-lint/$6.html --upload-file app/build/reports/lint/lint.html
echo "New findbugs results at https://www.kaminsky.me/nc-dev/talk-findbugs/$6.html"
- curl 2>/dev/null -u $4:$5 -X PUT https://nextcloud.kaminsky.me/remote.php/webdav/talk-findbugs/$6.html --upload-file app/build/reports/findbugs/findbugs.html
+ curl 2>/dev/null -u $4:$5 -X PUT https://nextcloud.kaminsky.me/remote.php/webdav/talk-findbugs/$6.html --upload-file app/build/reports/spotbugs/spotbugs.html
# delete all old comments
oldComments=$(curl 2>/dev/null -u $1:$2 -X GET https://api.github.com/repos/nextcloud/talk-android/issues/$7/comments | jq '.[] | (.id |tostring) + "|" + (.user.login | test("nextcloud-android-bot") | tostring) ' | grep true | tr -d "\"" | cut -f1 -d"|")
@@ -56,8 +56,8 @@ else
lintErrorOld=$(grep "[0-9]* error" scripts/analysis/lint-results.txt -o | cut -f1 -d" ")
lintWarningOld=$(grep "[0-9]* warning" scripts/analysis/lint-results.txt -o | cut -f1 -d" ")
lintResult="Lint
Type | Master | PR |
Warnings | "$lintWarningOld" | "$lintWarningNew" |
Errors | "$lintErrorOld" | "$lintErrorNew" |
"
- findbugsResultNew=$(sed -n "/Summary<\/h1>/,/Warnings<\/h1>/p" app/build/reports/findbugs/findbugs.html |head -n-1 | sed s'/<\/a>//'g | sed s'///'g | sed s"#Summary#FindBugs (new)#" | tr "\"" "\'" | tr -d "\n")
- findbugsResultOld=$(curl 2>/dev/null https://nextcloud.kaminsky.me/s/oaof9LtJHibyRGx/download | tr "\"" "\'" | tr -d "\r\n" | sed s'#FindBugs#FindBugs#'| tr "\"" "\'" | tr -d "\n")
+ findbugsResultNew=$(sed -n "/Summary<\/h1>/,/Warnings<\/h1>/p" app/build/reports/spotbugs/spotbugs.html |head -n-1 | sed s'/<\/a>//'g | sed s'///'g | sed s"#Summary#FindBugs (new)#" | tr "\"" "\'" | tr -d "\n")
+ findbugsResultOld=$(curl 2>/dev/null https://www.kaminsky.me/nc-dev/talk-findbugs/findbugs.html | tr "\"" "\'" | tr -d "\r\n" | sed s'#FindBugs#FindBugs#'| tr "\"" "\'" | tr -d "\n")
curl -u $1:$2 -X POST https://api.github.com/repos/nextcloud/talk-android/issues/$7/comments -d "{ \"body\" : \"$lintResult $findbugsResultNew $findbugsResultOld \" }"
if [ $lintValue -eq 2 ]; then
diff --git a/scripts/analysis/lint-results.txt b/scripts/analysis/lint-results.txt
index 4b1cd30e0..b57288621 100644
--- a/scripts/analysis/lint-results.txt
+++ b/scripts/analysis/lint-results.txt
@@ -1,2 +1,2 @@
DO NOT TOUCH; GENERATED BY DRONE
- Lint Report: 4 errors and 238 warnings
+ Lint Report: 11 errors and 561 warnings