Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/talk-android.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.drone.yml56
-rw-r--r--.github/workflows/analysis.yml49
-rw-r--r--.gitignore35
-rw-r--r--app/build.gradle46
-rw-r--r--app/src/main/java/com/nextcloud/talk/jobs/AccountRemovalWorker.java8
-rw-r--r--app/src/main/java/com/nextcloud/talk/presenters/MentionAutocompletePresenter.java9
-rw-r--r--app/src/main/java/com/nextcloud/talk/ui/dialog/SortingOrderDialogFragment.java4
-rw-r--r--app/src/main/java/com/nextcloud/talk/utils/ApiUtils.java7
-rw-r--r--app/src/main/java/com/nextcloud/talk/utils/preferences/preferencestorage/DatabaseStorageModule.java15
-rw-r--r--build.gradle2
-rwxr-xr-xscripts/analysis/analysis-wrapper.sh103
-rwxr-xr-xscripts/analysis/findbugs-up.rb2
-rw-r--r--scripts/analysis/lint-up.rb35
-rwxr-xr-xscripts/analysis/spotbugs-up.rb48
-rwxr-xr-xscripts/analysis/spotbugsComparison.py52
-rwxr-xr-xscripts/analysis/spotbugsSummary.py61
-rwxr-xr-xscripts/checkGplayLimitation.sh13
-rwxr-xr-xscripts/lib.sh48
18 files changed, 417 insertions, 176 deletions
diff --git a/.drone.yml b/.drone.yml
index 559e40412..5fd2aa73e 100644
--- a/.drone.yml
+++ b/.drone.yml
@@ -75,59 +75,3 @@ trigger:
event:
- push
- pull_request
-
----
-kind: pipeline
-type: docker
-name: analysis
-
-steps:
- - name: analysis
- image: ghcr.io/nextcloud/continuous-integration-android8:2
- environment:
- GIT_USERNAME:
- from_secret: GIT_USERNAME
- GIT_TOKEN:
- from_secret: GIT_TOKEN
- LOG_USERNAME:
- from_secret: LOG_USERNAME
- LOG_PASSWORD:
- from_secret: LOG_PASSWORD
- commands:
- - export BRANCH=$(scripts/analysis/getBranchName.sh $GIT_USERNAME $GIT_TOKEN $DRONE_PULL_REQUEST)
- - scripts/analysis/analysis-wrapper.sh $GIT_USERNAME $GIT_TOKEN $BRANCH $LOG_USERNAME $LOG_PASSWORD $DRONE_BUILD_NUMBER $DRONE_PULL_REQUEST
-
- - name: notify
- image: drillster/drone-email
- host: $EMAIL_HOST
- port: 587
- username: $EMAIL_USERNAME
- password: $EMAIL_PASSWORD
- from: nextcloud-drone@kaminsky.me
- skip_verify: true
- recipients_only: true
- recipients: [ $EMAIL_RECIPIENTS ]
- environment:
- EMAIL_USERNAME:
- from_secret: EMAIL_USERNAME
- EMAIL_PASSWORD:
- from_secret: EMAIL_PASSWORD
- EMAIL_RECIPIENTS:
- from_secret: EMAIL_RECIPIENTS
- EMAIL_HOST:
- from_secret: EMAIL_HOST
- when:
- event:
- - push
- status:
- - failure
- branch:
- - master
-
-trigger:
- branch:
- - master
- - stable-*
- event:
- - push
- - pull_request
diff --git a/.github/workflows/analysis.yml b/.github/workflows/analysis.yml
new file mode 100644
index 000000000..6a3ce2ebc
--- /dev/null
+++ b/.github/workflows/analysis.yml
@@ -0,0 +1,49 @@
+name: "Analysis"
+
+on:
+ pull_request:
+ branches: [ master, stable-* ]
+ push:
+ branches: [ master, stable-* ]
+
+permissions:
+ pull-requests: write
+ contents: write
+
+jobs:
+ analysis:
+ runs-on: ubuntu-latest
+ steps:
+ - name: Setup variables
+ id: get-vars
+ run: |
+ if [ -z "$GITHUB_HEAD_REF" ]; then
+ # push
+ echo "::set-output name=branch::$GITHUB_REF_NAME"
+ echo "::set-output name=pr::$GITHUB_RUN_ID"
+ echo "::set-output name=repo::${{ github.repository }}"
+ else
+ # pull request
+ echo "::set-output name=branch::$GITHUB_HEAD_REF"
+ echo "::set-output name=pr::${{ github.event.pull_request.number }}"
+ echo "::set-output name=repo::${{ github.event.pull_request.head.repo.full_name }}"
+ fi
+ - uses: actions/checkout@v3
+ with:
+ repository: ${{ steps.get-vars.outputs.repo }}
+ ref: ${{ steps.get-vars.outputs.branch }}
+ - name: Set up JDK 11
+ uses: actions/setup-java@v3
+ with:
+ distribution: "temurin"
+ java-version: 11
+ - name: Install dependencies
+ run: |
+ python3 -m pip install defusedxml
+ - name: Run analysis wrapper
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ run: |
+ mkdir -p $HOME/.gradle
+ echo "org.gradle.jvmargs=-Xmx2g -XX:MaxMetaspaceSize=512m -XX:+HeapDumpOnOutOfMemoryError" > $HOME/.gradle/gradle.properties
+ scripts/analysis/analysis-wrapper.sh ${{ steps.get-vars.outputs.branch }} ${{ secrets.LOG_USERNAME }} ${{ secrets.LOG_PASSWORD }} $GITHUB_RUN_NUMBER ${{ steps.get-vars.outputs.pr }}
diff --git a/.gitignore b/.gitignore
index 0154ebcf3..3cd6df61f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,6 +1,7 @@
# Built application files
*.apk
*.ap_
+*.aab
# Files for the ART/Dalvik VM
*.dex
@@ -10,25 +11,36 @@
# Generated files
bin/
+build/
+*.iml
gen/
-out/
+target/
-# Local configuration file (sdk path, etc)
+# Local configuration files (sdk path, etc)
local.properties
tests/local.properties
+# Mac .DS_Store files
+.DS_Store
+
# Proguard folder generated by Eclipse
proguard/
+proguard-project.txt
+tests/proguard-project.txt
# Log Files
*.log
# Android Studio and Gradle specific entries
-*.iml
.gradle
+.idea/*
+!.idea/codeStyles/
.idea
build
/gradle.properties
+.attach_pid*
+fastlane/Fastfile
+*.hprof
captures/
.navigation/
app/gplay/
@@ -55,4 +67,21 @@ freeline/
freeline_project_description.json
.DS_Store
+# fastlane specific
+**/fastlane/report.xml
+
+# deliver temporary files
+**/fastlane/Preview.html
+
+# snapshot generated screenshots
+**/fastlane/screenshots
+
+# scan temporary files
+**/fastlane/test_output
+/fastlane/vendor/
+/.bundle/
+/fastlane/.bundle
+
+# python
+**/__pycache__/
diff --git a/app/build.gradle b/app/build.gradle
index 7de7c7ea9..840171974 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -120,26 +120,6 @@ android {
}
}
- android.applicationVariants.all { variant ->
- String variantName = variant.name
- String capVariantName = variantName.substring(0, 1).toUpperCase(Locale.ROOT) + variantName.substring(1)
- tasks.register("spotbugs${capVariantName}Report", SpotBugsTask) {
- ignoreFailures = true // should continue checking
- effort = "max"
- reportLevel = "medium"
- classes = fileTree("$project.buildDir/intermediates/javac/${variantName}/classes/")
- excludeFilter = file("${project.rootDir}/spotbugs-filter.xml")
-
- reports {
- xml.enabled = false
- html {
- enabled = true
- destination = file("$project.buildDir/reports/spotbugs/spotbugs.html")
- }
- }
- }
- }
-
check.dependsOn 'spotbugsGplayDebug', 'lint', 'ktlintCheck', 'detekt'
compileOptions {
@@ -346,6 +326,32 @@ task installGitHooks(type: Copy, group: "development") {
into '../.git/hooks'
}
+spotbugs {
+ ignoreFailures = true // should continue checking
+ effort = "max"
+ reportLevel = "medium"
+}
+
+tasks.withType(SpotBugsTask) { task ->
+ String variantNameCap = task.name.replace("spotbugs", "")
+ String variantName = variantNameCap.substring(0, 1).toLowerCase() + variantNameCap.substring(1)
+
+ dependsOn "compile${variantNameCap}Sources"
+
+ excludeFilter = file("${project.rootDir}/spotbugs-filter.xml")
+ classes = fileTree("$project.buildDir/intermediates/javac/${variantName}/classes/")
+ reports {
+ xml {
+ required = true
+ }
+ html {
+ required = true
+ outputLocation = file("$project.buildDir/reports/spotbugs/spotbugs.html")
+ stylesheet = 'fancy.xsl'
+ }
+ }
+}
+
tasks.named("detekt").configure {
reports {
html.required.set(true)
diff --git a/app/src/main/java/com/nextcloud/talk/jobs/AccountRemovalWorker.java b/app/src/main/java/com/nextcloud/talk/jobs/AccountRemovalWorker.java
index f29736aa0..91043e44b 100644
--- a/app/src/main/java/com/nextcloud/talk/jobs/AccountRemovalWorker.java
+++ b/app/src/main/java/com/nextcloud/talk/jobs/AccountRemovalWorker.java
@@ -39,8 +39,6 @@ import com.nextcloud.talk.users.UserManager;
import com.nextcloud.talk.utils.ApiUtils;
import com.nextcloud.talk.webrtc.WebSocketConnectionHelper;
-import org.jetbrains.annotations.NotNull;
-
import java.net.CookieManager;
import java.util.HashMap;
import java.util.List;
@@ -105,12 +103,12 @@ public class AccountRemovalWorker extends Worker {
ApiUtils.getUrlNextcloudPush(user.getBaseUrl()))
.blockingSubscribe(new Observer<GenericOverall>() {
@Override
- public void onSubscribe(@NotNull Disposable d) {
+ public void onSubscribe(@io.reactivex.annotations.NonNull Disposable d) {
// unused atm
}
@Override
- public void onNext(@NotNull GenericOverall genericOverall) {
+ public void onNext(@io.reactivex.annotations.NonNull GenericOverall genericOverall) {
GenericMeta meta = Objects.requireNonNull(genericOverall.getOcs()).getMeta();
int statusCode = Objects.requireNonNull(meta).getStatusCode();
@@ -126,7 +124,7 @@ public class AccountRemovalWorker extends Worker {
}
@Override
- public void onError(@NotNull Throwable e) {
+ public void onError(@io.reactivex.annotations.NonNull Throwable e) {
Log.e(TAG, "error while trying to unregister Device For Notifications", e);
}
diff --git a/app/src/main/java/com/nextcloud/talk/presenters/MentionAutocompletePresenter.java b/app/src/main/java/com/nextcloud/talk/presenters/MentionAutocompletePresenter.java
index ada79fd7c..f6a28dab8 100644
--- a/app/src/main/java/com/nextcloud/talk/presenters/MentionAutocompletePresenter.java
+++ b/app/src/main/java/com/nextcloud/talk/presenters/MentionAutocompletePresenter.java
@@ -41,8 +41,6 @@ import com.nextcloud.talk.users.UserManager;
import com.nextcloud.talk.utils.ApiUtils;
import com.otaliastudios.autocomplete.RecyclerViewPresenter;
-import org.jetbrains.annotations.NotNull;
-
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@@ -57,6 +55,7 @@ import eu.davidea.flexibleadapter.FlexibleAdapter;
import eu.davidea.flexibleadapter.items.AbstractFlexibleItem;
import io.reactivex.Observer;
import io.reactivex.android.schedulers.AndroidSchedulers;
+import io.reactivex.annotations.NonNull;
import io.reactivex.disposables.Disposable;
import io.reactivex.schedulers.Schedulers;
@@ -137,12 +136,12 @@ public class MentionAutocompletePresenter extends RecyclerViewPresenter<Mention>
.retry(3)
.subscribe(new Observer<MentionOverall>() {
@Override
- public void onSubscribe(@NotNull Disposable d) {
+ public void onSubscribe(@NonNull Disposable d) {
// no actions atm
}
@Override
- public void onNext(@NotNull MentionOverall mentionOverall) {
+ public void onNext(@NonNull MentionOverall mentionOverall) {
List<Mention> mentionsList = mentionOverall.getOcs().getData();
if (mentionsList.size() == 0) {
@@ -168,7 +167,7 @@ public class MentionAutocompletePresenter extends RecyclerViewPresenter<Mention>
@SuppressLint("LongLogTag")
@Override
- public void onError(@NotNull Throwable e) {
+ public void onError(@NonNull Throwable e) {
adapter.clear();
Log.e(TAG, "failed to get MentionAutocompleteSuggestions", e);
}
diff --git a/app/src/main/java/com/nextcloud/talk/ui/dialog/SortingOrderDialogFragment.java b/app/src/main/java/com/nextcloud/talk/ui/dialog/SortingOrderDialogFragment.java
index 5bd21b2ef..d3744072a 100644
--- a/app/src/main/java/com/nextcloud/talk/ui/dialog/SortingOrderDialogFragment.java
+++ b/app/src/main/java/com/nextcloud/talk/ui/dialog/SortingOrderDialogFragment.java
@@ -39,8 +39,6 @@ import com.nextcloud.talk.ui.theme.ViewThemeUtils;
import com.nextcloud.talk.utils.FileSortOrder;
import com.nextcloud.talk.utils.preferences.AppPreferences;
-import org.jetbrains.annotations.NotNull;
-
import javax.inject.Inject;
import androidx.annotation.NonNull;
@@ -70,7 +68,7 @@ public class SortingOrderDialogFragment extends DialogFragment implements View.O
private View[] taggedViews;
private String currentSortOrderName;
- public static SortingOrderDialogFragment newInstance(@NotNull FileSortOrder sortOrder) {
+ public static SortingOrderDialogFragment newInstance(@NonNull FileSortOrder sortOrder) {
SortingOrderDialogFragment dialogFragment = new SortingOrderDialogFragment();
Bundle args = new Bundle();
diff --git a/app/src/main/java/com/nextcloud/talk/utils/ApiUtils.java b/app/src/main/java/com/nextcloud/talk/utils/ApiUtils.java
index cac2501cd..c12c04572 100644
--- a/app/src/main/java/com/nextcloud/talk/utils/ApiUtils.java
+++ b/app/src/main/java/com/nextcloud/talk/utils/ApiUtils.java
@@ -34,11 +34,10 @@ import com.nextcloud.talk.data.user.model.User;
import com.nextcloud.talk.models.RetrofitBucket;
import com.nextcloud.talk.utils.database.user.CapabilitiesUtilNew;
-import org.jetbrains.annotations.NotNull;
-
import java.util.HashMap;
import java.util.Map;
+import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import okhttp3.Credentials;
@@ -471,8 +470,8 @@ public class ApiUtils {
return baseUrl + ocsApiVersion + spreedApiVersion + "/reaction/" + roomToken + "/" + messageId;
}
- @NotNull
- public static String getUrlForUnifiedSearch(@NotNull String baseUrl, @NotNull String providerId) {
+ @NonNull
+ public static String getUrlForUnifiedSearch(@NonNull String baseUrl, @NonNull String providerId) {
return baseUrl + ocsApiVersion + "/search/providers/" + providerId + "/search";
}
diff --git a/app/src/main/java/com/nextcloud/talk/utils/preferences/preferencestorage/DatabaseStorageModule.java b/app/src/main/java/com/nextcloud/talk/utils/preferences/preferencestorage/DatabaseStorageModule.java
index b38ee30c7..9e891efec 100644
--- a/app/src/main/java/com/nextcloud/talk/utils/preferences/preferencestorage/DatabaseStorageModule.java
+++ b/app/src/main/java/com/nextcloud/talk/utils/preferences/preferencestorage/DatabaseStorageModule.java
@@ -39,8 +39,6 @@ import com.nextcloud.talk.utils.UserIdUtils;
import com.nextcloud.talk.utils.database.user.CapabilitiesUtilNew;
import com.yarolegovich.mp.io.StorageModule;
-import org.jetbrains.annotations.NotNull;
-
import java.util.Set;
import javax.inject.Inject;
@@ -48,6 +46,7 @@ import javax.inject.Inject;
import autodagger.AutoInjector;
import io.reactivex.Observer;
import io.reactivex.android.schedulers.AndroidSchedulers;
+import io.reactivex.annotations.NonNull;
import io.reactivex.disposables.Disposable;
import io.reactivex.schedulers.Schedulers;
@@ -91,17 +90,17 @@ public class DatabaseStorageModule implements StorageModule {
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Observer<GenericOverall>() {
@Override
- public void onSubscribe(@NotNull Disposable d) {
+ public void onSubscribe(@NonNull Disposable d) {
// unused atm
}
@Override
- public void onNext(@NotNull GenericOverall genericOverall) {
+ public void onNext(@NonNull GenericOverall genericOverall) {
Log.d(TAG, "Toggled notification calls");
}
@Override
- public void onError(@NotNull Throwable e) {
+ public void onError(@NonNull Throwable e) {
Log.e(TAG, "Error when trying to toggle notification calls", e);
}
@@ -144,17 +143,17 @@ public class DatabaseStorageModule implements StorageModule {
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Observer<GenericOverall>() {
@Override
- public void onSubscribe(@NotNull Disposable d) {
+ public void onSubscribe(@NonNull Disposable d) {
// unused atm
}
@Override
- public void onNext(@NotNull GenericOverall genericOverall) {
+ public void onNext(@NonNull GenericOverall genericOverall) {
messageExpiration = valueInt;
}
@Override
- public void onError(@NotNull Throwable e) {
+ public void onError(@NonNull Throwable e) {
Log.e(TAG, "Error when trying to set message expiration", e);
}
diff --git a/build.gradle b/build.gradle
index 6030bd6fb..1e000a0f9 100644
--- a/build.gradle
+++ b/build.gradle
@@ -37,7 +37,7 @@ buildscript {
classpath 'com.android.tools.build:gradle:7.3.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${kotlinVersion}"
classpath "org.jetbrains.kotlin:kotlin-serialization:${kotlinVersion}"
- classpath 'gradle.plugin.com.github.spotbugs.snom:spotbugs-gradle-plugin:4.7.5'
+ classpath 'com.github.spotbugs.snom:spotbugs-gradle-plugin:5.0.11'
classpath "io.gitlab.arturbosch.detekt:detekt-gradle-plugin:1.21.0"
classpath "org.jlleitschuh.gradle:ktlint-gradle:11.0.0"
diff --git a/scripts/analysis/analysis-wrapper.sh b/scripts/analysis/analysis-wrapper.sh
index 1720ba4f0..5d84ea0f7 100755
--- a/scripts/analysis/analysis-wrapper.sh
+++ b/scripts/analysis/analysis-wrapper.sh
@@ -1,66 +1,59 @@
#!/usr/bin/env bash
-#1: GIT_USERNAME
-#2: GIT_TOKEN
-#3: BRANCH
-#4: LOG_USERNAME
-#5: LOG_PASSWORD
-#6: DRONE_BUILD_NUMBER
-#7: PULL_REQUEST_NUMBER
+BRANCH=$1
+LOG_USERNAME=$2
+LOG_PASSWORD=$3
+BUILD_NUMBER=$4
+PR_NUMBER=$5
-repository="talk"
+stableBranch="master"
+repository="talk-android"
-stableBranch=$(git branch | grep '*' | cut -d' ' -f2)
-if [[ $stableBranch = \stable-* ]] ; then
- stableBranch=$3
-else
- stableBranch="master"
-fi
-
-ruby scripts/analysis/lint-up.rb $1 $2 $3
+ruby scripts/analysis/lint-up.rb
lintValue=$?
-ruby scripts/analysis/findbugs-up.rb $1 $2 $3
-findbugsValue=$?
+curl "https://www.kaminsky.me/nc-dev/$repository-findbugs/$stableBranch.xml" -o "/tmp/$stableBranch.xml"
+ruby scripts/analysis/spotbugs-up.rb "$stableBranch"
+spotbugsValue=$?
# exit codes:
# 0: count was reduced
# 1: count was increased
# 2: count stayed the same
-echo "Branch: $3"
+source scripts/lib.sh
-if [ $3 = $stableBranch ]; then
- echo "New findbugs result for $stableBranch at: https://www.kaminsky.me/nc-dev/$repository-findbugs/$stableBranch.html"
- curl -k -u $4:$5 -X PUT https://nextcloud.kaminsky.me/remote.php/webdav/$repository-findbugs/$stableBranch.html --upload-file app/build/reports/spotbugs/spotbugs.html
+echo "Branch: $BRANCH"
- summary=$(sed -n "/<h1>Summary<\/h1>/,/<h1>Warnings<\/h1>/p" app/build/reports/spotbugs/spotbugs.html | head -n-1 | sed s'/<\/a>//'g | sed s'/<a.*>//'g | sed s"/Summary/SpotBugs ($stableBranch)/" | tr "\"" "\'" | tr -d "\r\n")
- curl -k -u $4:$5 -X PUT -d "$summary" https://nextcloud.kaminsky.me/remote.php/webdav/$repository-findbugs/findbugs-summary-$stableBranch.html
+if [ "$BRANCH" = $stableBranch ]; then
+ echo "New spotbugs result for $stableBranch at: https://www.kaminsky.me/nc-dev/$repository-findbugs/$stableBranch.html"
+ curl -u "${LOG_USERNAME}:${LOG_PASSWORD}" -X PUT https://nextcloud.kaminsky.me/remote.php/webdav/$repository-findbugs/$stableBranch.html --upload-file app/build/reports/spotbugs/spotbugs.html
+ curl 2>/dev/null -u "${LOG_USERNAME}:${LOG_PASSWORD}" -X PUT "https://nextcloud.kaminsky.me/remote.php/webdav/$repository-findbugs/$stableBranch.xml" --upload-file app/build/reports/spotbugs/gplayDebug.xml
if [ $lintValue -ne 1 ]; then
echo "New lint result for $stableBranch at: https://www.kaminsky.me/nc-dev/$repository-lint/$stableBranch.html"
- curl -k -u $4:$5 -X PUT https://nextcloud.kaminsky.me/remote.php/webdav/$repository-lint/$stableBranch.html --upload-file app/build/reports/lint/lint.html
+ curl -u "${LOG_USERNAME}:${LOG_PASSWORD}" -X PUT https://nextcloud.kaminsky.me/remote.php/webdav/$repository-lint/$stableBranch.html --upload-file app/build/reports/lint/lint.html
exit 0
fi
else
- if [ -e $6 ]; then
+ if [ -e "${BUILD_NUMBER}" ]; then
6=$stableBranch"-"$(date +%F)
fi
- echo "New lint results at https://www.kaminsky.me/nc-dev/$repository-lint/$6.html"
- curl -k -u $4:$5 -X PUT https://nextcloud.kaminsky.me/remote.php/webdav/$repository-lint/$6.html --upload-file app/build/reports/lint/lint.html
+ echo "New lint results at https://www.kaminsky.me/nc-dev/$repository-lint/${BUILD_NUMBER}.html"
+ curl 2>/dev/null -u "${LOG_USERNAME}:${LOG_PASSWORD}" -X PUT "https://nextcloud.kaminsky.me/remote.php/webdav/$repository-lint/${BUILD_NUMBER}.html" --upload-file app/build/reports/lint/lint.html
- echo "New findbugs results at https://www.kaminsky.me/nc-dev/$repository-findbugs/$6.html"
- curl -k -u $4:$5 -X PUT https://nextcloud.kaminsky.me/remote.php/webdav/$repository-findbugs/$6.html --upload-file app/build/reports/spotbugs/spotbugs.html
+ echo "New spotbugs results at https://www.kaminsky.me/nc-dev/$repository-findbugs/${BUILD_NUMBER}.html"
+ curl 2>/dev/null -u "${LOG_USERNAME}:${LOG_PASSWORD}" -X PUT "https://nextcloud.kaminsky.me/remote.php/webdav/$repository-findbugs/${BUILD_NUMBER}.html" --upload-file app/build/reports/spotbugs/spotbugs.html
- # delete all old comments
- oldComments=$(curl -k 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"|")
+ # delete all old comments, starting with Codacy
+ oldComments=$(curl_gh -X GET "https://api.github.com/repos/nextcloud/$repository/issues/${PR_NUMBER}/comments" | jq '.[] | select((.user.login | contains("github-actions")) and (.body | test("<h1>Codacy.*"))) | .id')
- echo $oldComments | while read comment ; do
- curl -k 2>/dev/null -u $1:$2 -X DELETE https://api.github.com/repos/nextcloud/talk-android/issues/comments/$comment
+ echo "$oldComments" | while read -r comment ; do
+ curl_gh -X DELETE "https://api.github.com/repos/nextcloud/$repository/issues/comments/$comment"
done
- # lint and findbugs file must exist
+ # lint and spotbugs file must exist
if [ ! -s app/build/reports/lint/lint.html ] ; then
echo "lint.html file is missing!"
exit 1
@@ -84,7 +77,7 @@ else
lintWarningNew=0
fi
- lintResultOld=$(curl -k 2>/dev/null https://raw.githubusercontent.com/nextcloud/talk-android/$stableBranch/scripts/analysis/lint-results.txt)
+ lintResultOld=$(curl 2>/dev/null "https://raw.githubusercontent.com/nextcloud/$repository/$stableBranch/scripts/analysis/lint-results.txt")
lintErrorOld=$(echo $lintResultOld | grep "[0-9]* error" -o | cut -f1 -d" ")
if ( [ -z $lintErrorOld ] ); then
lintErrorOld=0
@@ -95,37 +88,55 @@ else
lintWarningOld=0
fi
- lintResult="<h1>Lint</h1><table width='500' cellpadding='5' cellspacing='2'><tr class='tablerow0'><td>Type</td><td><a href='https://www.kaminsky.me/nc-dev/"$repository"-lint/"$stableBranch".html'>$stableBranch</a></td><td><a href='https://www.kaminsky.me/nc-dev/"$repository"-lint/"$6".html'>PR</a></td></tr><tr class='tablerow1'><td>Warnings</td><td>"$lintWarningOld"</td><td>"$lintWarningNew"</td></tr><tr class='tablerow0'><td>Errors</td><td>"$lintErrorOld"</td><td>"$lintErrorNew"</td></tr></table>"
- findbugsResultNew=$(sed -n "/<h1>Summary<\/h1>/,/<h1>Warnings<\/h1>/p" app/build/reports/spotbugs/spotbugs.html |head -n-1 | sed s'/<\/a>//'g | sed s'/<a.*>//'g | sed s"#Summary#<a href=\"https://www.kaminsky.me/nc-dev/$repository-findbugs/$6.html\">SpotBugs</a> (new)#" | tr "\"" "\'" | tr -d "\n")
- findbugsResultOld=$(curl -k 2>/dev/null https://www.kaminsky.me/nc-dev/$repository-findbugs/findbugs-summary-$stableBranch.html | tr "\"" "\'" | tr -d "\r\n" | sed s"#SpotBugs#<a href=\"https://www.kaminsky.me/nc-dev/$repository-findbugs/$stableBranch.html\">SpotBugs</a>#" | tr "\"" "\'" | tr -d "\n")
+ if [ $stableBranch = "master" ] ; then
+ codacyValue=$(curl 2>/dev/null https://app.codacy.com/gh/nextcloud/$repository/dashboard | grep "total issues" | cut -d">" -f3 | cut -d"<" -f1)
+ codacyResult="<h1>Codacy</h1>$codacyValue"
+ else
+ codacyResult=""
+ fi
+
+ lintResult="<h1>Lint</h1><table width='500' cellpadding='5' cellspacing='2'><tr class='tablerow0'><td>Type</td><td><a href='https://www.kaminsky.me/nc-dev/$repository-lint/$stableBranch.html'>$stableBranch</a></td><td><a href='https://www.kaminsky.me/nc-dev/$repository-lint/${BUILD_NUMBER}.html'>PR</a></td></tr><tr class='tablerow1'><td>Warnings</td><td>$lintWarningOld</td><td>$lintWarningNew</td></tr><tr class='tablerow0'><td>Errors</td><td>$lintErrorOld</td><td>$lintErrorNew</td></tr></table>"
+ spotbugsResult="<h1>SpotBugs</h1>$(scripts/analysis/spotbugsComparison.py "/tmp/$stableBranch.xml" app/build/reports/spotbugs/gplayDebug.xml --link-new "https://www.kaminsky.me/nc-dev/$repository-findbugs/${BUILD_NUMBER}.html" --link-base "https://www.kaminsky.me/nc-dev/$repository-findbugs/$stableBranch.html")"
if ( [ $lintValue -eq 1 ] ) ; then
lintMessage="<h1>Lint increased!</h1>"
fi
- if ( [ $findbugsValue -eq 1 ] ) ; then
- findbugsMessage="<h1>SpotBugs increased!</h1>"
+ if ( [ $spotbugsValue -eq 1 ] ) ; then
+ spotbugsMessage="<h1>SpotBugs increased!</h1>"
+ fi
+
+ # check gplay limitation: all changelog files must only have 500 chars
+ gplayLimitation=$(scripts/checkGplayLimitation.sh)
+
+ if [ ! -z "$gplayLimitation" ]; then
+ gplayLimitation="<h1>Following files are beyond 500 char limit:</h1><br><br>"$gplayLimitation
fi
# check for NotNull
- if [[ $(grep org.jetbrains.annotations src/main/* -ir -c) -gt 0 ]] ; then
+ if [[ $(grep org.jetbrains.annotations app/src/main/* -irl | wc -l) -gt 0 ]] ; then
notNull="org.jetbrains.annotations.NotNull is used. Please use androidx.annotation.NonNull instead.<br><br>"
fi
- curl -k -u $1:$2 -X POST https://api.github.com/repos/nextcloud/talk-android/issues/$7/comments -d "{ \"body\" : \"$lintResult $findbugsResultNew $findbugsResultOld $lintMessage $findbugsMessage $notNull\" }"
+ payload="{ \"body\" : \"$codacyResult $lintResult $spotbugsResult $lintMessage $spotbugsMessage $gplayLimitation $notNull\" }"
+ curl_gh -X POST "https://api.github.com/repos/nextcloud/$repository/issues/${PR_NUMBER}/comments" -d "$payload"
+
+ if [ ! -z "$gplayLimitation" ]; then
+ exit 1
+ fi
if [ ! $lintValue -eq 2 ]; then
exit $lintValue
fi
- if [[ -n $notNull ]]; then
+ if [ -n "$notNull" ]; then
exit 1
fi
- if [ $findbugsValue -eq 2 ]; then
+ if [ $spotbugsValue -eq 2 ]; then
exit 0
else
- exit $findbugsValue
+ exit $spotbugsValue
fi
fi
diff --git a/scripts/analysis/findbugs-up.rb b/scripts/analysis/findbugs-up.rb
index 663894eb4..31ad1fb4c 100755
--- a/scripts/analysis/findbugs-up.rb
+++ b/scripts/analysis/findbugs-up.rb
@@ -39,7 +39,7 @@ require 'open3'
begin
gem "xml-simple"
rescue LoadError
- system("gem install xml-simple")
+ system("gem install --user-install xml-simple")
Gem.clear_paths
end
diff --git a/scripts/analysis/lint-up.rb b/scripts/analysis/lint-up.rb
index 44eb132d8..c9d486413 100644
--- a/scripts/analysis/lint-up.rb
+++ b/scripts/analysis/lint-up.rb
@@ -1,14 +1,14 @@
## Script from https://github.com/tir38/android-lint-entropy-reducer at 07.05.2017
# adapts to drone, use git username / token as parameter
+# TODO cleanup this script, it has a lot of unused stuff
+
+
Encoding.default_external = Encoding::UTF_8
Encoding.default_internal = Encoding::UTF_8
puts "=================== starting Android Lint Entropy Reducer ===================="
-# get args
-git_user, git_token, git_branch = ARGV
-
# ======================== SETUP ============================
# User name for git commits made by this script.
@@ -39,7 +39,7 @@ require 'open3'
begin
gem "xml-simple"
rescue LoadError
- system("gem install xml-simple")
+ system("gem install --user-install xml-simple")
Gem.clear_paths
end
@@ -56,12 +56,12 @@ end
# run Lint
puts "running Lint..."
-system './gradlew --console=plain lintGplayDebug'
+system './gradlew clean lintGplayDebug 1>/dev/null'
# confirm that Lint ran w/out error
result = $?.to_i
if result != 0
- puts "FAIL: failed to run ./gradlew --console=plain lintGplayDebug"
+ puts "FAIL: failed to run ./gradlew clean lintGplayDebug"
exit 1
end
@@ -169,31 +169,18 @@ end
# write new results to file (will overwrite existing, or create new)
File.write(previous_lint_report, "DO NOT TOUCH; GENERATED BY DRONE\n" + error_warning_string)
-# push changes to github (if this script is run locally, we don't want to overwrite git username and email, so save temporarily)
-previous_git_username, _ = Open3.capture2('git config user.name')
-previous_git_username = previous_git_username.strip
-
-previous_git_email, _ = Open3.capture3('git config user.email')
-previous_git_email = previous_git_email.strip
-
# update git user name and email for this script
-system ("git config --local user.name '" + git_user + "'")
-system ("git config --local user.email '.'") # set email blank
-system ("git remote rm origin")
-system ("git remote add origin https://" + git_user + ":" + git_token + "@github.com/nextcloud/talk-android")
+system ("git config --local user.name 'github-actions'")
+system ("git config --local user.email 'github-actions@github.com'")
# add previous Lint result file to git
system ('git add ' + PREVIOUS_LINT_RESULTS_FILE)
-# commit changes; Add "skip ci" so that we don't accidentally trigger another Drone build
-system({"GIT_COMMITTER_EMAIL" => "drone@nextcloud.com", "GIT_AUTHOR_EMAIL" => "drone@nextcloud.com"}, 'git commit -sm "Drone: update Lint results to reflect reduced error/warning count [skip ci]"')
+# commit changes
+system('git commit -sm "Analysis: update lint results to reflect reduced error/warning count"')
# push to origin
-system ('git push origin HEAD:' + git_branch)
-
-# restore previous git user name and email
-system("git config --local user.name '#{previous_git_username}'")
-system("git config --local user.email '#{previous_git_email}'")
+system ('git push')
puts "SUCCESS: count was reduced"
exit 0 # success
diff --git a/scripts/analysis/spotbugs-up.rb b/scripts/analysis/spotbugs-up.rb
new file mode 100755
index 000000000..ed046c411
--- /dev/null
+++ b/scripts/analysis/spotbugs-up.rb
@@ -0,0 +1,48 @@
+## Script originally from https://github.com/tir38/android-lint-entropy-reducer at 07.05.2017
+# heavily modified since then
+
+Encoding.default_external = Encoding::UTF_8
+Encoding.default_internal = Encoding::UTF_8
+
+puts "=================== starting Android Spotbugs Entropy Reducer ===================="
+
+# get args
+base_branch = ARGV[0]
+
+require 'fileutils'
+require 'pathname'
+require 'open3'
+
+# run Spotbugs
+puts "running Spotbugs..."
+system './gradlew spotbugsGplayDebug 1>/dev/null 2>&1'
+
+# find number of warnings
+current_warning_count = `./scripts/analysis/spotbugsSummary.py --total`.to_i
+puts "found warnings: " + current_warning_count.to_s
+
+# get warning counts from target branch
+previous_xml = "/tmp/#{base_branch}.xml"
+previous_results = File.file?(previous_xml)
+
+if previous_results == true
+ previous_warning_count = `./scripts/analysis/spotbugsSummary.py --total --file #{previous_xml}`.to_i
+ puts "previous warnings: " + previous_warning_count.to_s
+end
+
+# compare previous warning count with current warning count
+if previous_results == true && current_warning_count > previous_warning_count
+ puts "FAIL: warning count increased"
+ exit 1
+end
+
+# check if warning and error count stayed the same
+if previous_results == true && current_warning_count == previous_warning_count
+ puts "SUCCESS: count stayed the same"
+ exit 0
+end
+
+# warning count DECREASED
+if previous_results == true && current_warning_count < previous_warning_count
+ puts "SUCCESS: count decreased from " + previous_warning_count.to_s + " to " + current_warning_count.to_s
+end
diff --git a/scripts/analysis/spotbugsComparison.py b/scripts/analysis/spotbugsComparison.py
new file mode 100755
index 000000000..cc85d868c
--- /dev/null
+++ b/scripts/analysis/spotbugsComparison.py
@@ -0,0 +1,52 @@
+#!/usr/bin/env python3
+import argparse
+import defusedxml.ElementTree as ET
+import spotbugsSummary
+
+
+def print_comparison(old: dict, new: dict, link_base: str, link_new: str):
+ all_keys = sorted(set(list(old.keys()) + list(new.keys())))
+
+ output = "<table><tr><th>Category</th>"
+ old_header = f"<a href='{link_base}'>Base</a>" if link_base is not None else "Base"
+ output += f"<th>{old_header}</th>"
+ new_header = f"<a href='{link_new}'>New</a>" if link_new is not None else "New"
+ output += f"<th>{new_header}</th>"
+ output += "</tr>"
+
+ for category in all_keys:
+ category_count_old = old[category] if category in old else 0
+ category_count_new = new[category] if category in new else 0
+ new_str = f"<b>{category_count_new}</b>" if category_count_new != category_count_old else str(category_count_new)
+ output += "<tr>"
+ output += f"<td>{category}</td>"
+ output += f"<td>{category_count_old}</td>"
+ output += f"<td>{new_str}</td>"
+ output += "</tr>"
+
+ output += "<tr>"
+ output += "<td><b>Total</b></td>"
+ output += f"<td><b>{sum(old.values())}</b></td>"
+ output += f"<td><b>{sum(new.values())}</b></td>"
+ output += "</tr>"
+
+ output += "</table>"
+
+ print(output)
+
+
+if __name__ == "__main__":
+ parser = argparse.ArgumentParser()
+ parser.add_argument("base_file", help="base file for comparison")
+ parser.add_argument("new_file", help="new file for comparison")
+ parser.add_argument("--link-base", help="http link to base html report")
+ parser.add_argument("--link-new", help="http link to new html report")
+ args = parser.parse_args()
+
+ base_tree = ET.parse(args.base_file)
+ base_summary = spotbugsSummary.get_counts(base_tree)
+
+ new_tree = ET.parse(args.new_file)
+ new_summary = spotbugsSummary.get_counts(new_tree)
+
+ print_comparison(base_summary, new_summary, args.link_base, args.link_new)
diff --git a/scripts/analysis/spotbugsSummary.py b/scripts/analysis/spotbugsSummary.py
new file mode 100755
index 000000000..4fc886fa7
--- /dev/null
+++ b/scripts/analysis/spotbugsSummary.py
@@ -0,0 +1,61 @@
+#!/usr/bin/env python3
+import argparse
+import defusedxml.ElementTree as ET
+
+
+def get_counts(tree):
+ category_counts = {}
+ category_names = {}
+ for child in tree.getroot():
+ if child.tag == "BugInstance":
+ category = child.attrib['category']
+ if category in category_counts:
+ category_counts[category] = category_counts[category] + 1
+ else:
+ category_counts[category] = 1
+ elif child.tag == "BugCategory":
+ category = child.attrib['category']
+ category_names[category] = child[0].text
+
+ summary = {}
+ for category in category_counts.keys():
+ summary[category_names[category]] = category_counts[category]
+ return summary
+
+
+def print_html(summary):
+ output = "<table><tr><th>Category</th><th>Count</th></tr>"
+
+ categories = sorted(summary.keys())
+ for category in categories:
+ output += "<tr>"
+ output += f"<td>{category}</td>"
+ output += f"<td>{summary[category]}</td>"
+ output += "</tr>"
+
+ output += "<tr>"
+ output += "<td><b>Total</b></td>"
+ output += f"<td><b>{sum(summary.values())}</b></td>"
+ output += "</tr>"
+
+ output += "</table>"
+
+ print(output)
+
+
+def print_total(summary):
+ print(sum(summary.values()))
+
+
+if __name__ == "__main__":
+ parser = argparse.ArgumentParser()
+ parser.add_argument("--total", help="print total count instead of summary HTML",
+ action="store_true")
+ parser.add_argument("--file", help="file to parse", default="app/build/reports/spotbugs/gplayDebug.xml")
+ args = parser.parse_args()
+ tree = ET.parse(args.file)
+ summary = get_counts(tree)
+ if args.total:
+ print_total(summary)
+ else:
+ print_html(summary)
diff --git a/scripts/checkGplayLimitation.sh b/scripts/checkGplayLimitation.sh
new file mode 100755
index 000000000..de4ed0bb3
--- /dev/null
+++ b/scripts/checkGplayLimitation.sh
@@ -0,0 +1,13 @@
+#!/usr/bin/env bash
+
+result=""
+
+for log in fastlane/metadata/android/*/changelogs/*
+ do
+ if [[ -e $log && $(wc -m $log | cut -d" " -f1) -gt 500 ]]
+ then
+ result=$log"<br>"$result
+ fi
+done
+
+echo -e "$result";
diff --git a/scripts/lib.sh b/scripts/lib.sh
new file mode 100755
index 000000000..e99547399
--- /dev/null
+++ b/scripts/lib.sh
@@ -0,0 +1,48 @@
+#!/usr/bin/env bash
+#
+# Nextcloud Android Library is available under MIT license
+#
+# @author Álvaro Brey Vilas
+# Copyright (C) 2022 Álvaro Brey Vilas
+# Copyright (C) 2022 Nextcloud GmbH
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+# THE SOFTWARE.
+#
+
+## This file is intended to be sourced by other scripts
+
+
+function err() {
+ echo >&2 "$@"
+}
+
+
+function curl_gh() {
+ if [[ -n "$GITHUB_TOKEN" ]]
+ then
+ curl \
+ --silent \
+ --header "Authorization: token $GITHUB_TOKEN" \
+ "$@"
+ else
+ err "WARNING: No GITHUB_TOKEN found. Skipping API call"
+ fi
+
+}