From 0d2fb8e3d089bce9c47f3ace8b170be6c661ffe5 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Wed, 4 Jan 2023 10:17:35 +0100 Subject: [PATCH] Lint: fix KotlinNullnessAnnotation warning --- .../java/org/matrix/android/sdk/internal/di/SerializeNulls.kt | 2 -- .../internal/network/interceptors/FormattedJsonHttpLogger.kt | 3 +-- .../android/sdk/internal/network/parsing/CheckNumberType.kt | 3 --- tools/lint/lint.xml | 1 + .../java/im/vector/app/core/resources/StringArrayProvider.kt | 2 -- .../main/java/im/vector/app/core/resources/StringProvider.kt | 4 ---- 6 files changed, 2 insertions(+), 13 deletions(-) diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/di/SerializeNulls.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/di/SerializeNulls.kt index 9bd197e42e..f89221b627 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/di/SerializeNulls.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/di/SerializeNulls.kt @@ -16,7 +16,6 @@ package org.matrix.android.sdk.internal.di -import androidx.annotation.Nullable import com.squareup.moshi.JsonAdapter import com.squareup.moshi.JsonQualifier import com.squareup.moshi.Moshi @@ -28,7 +27,6 @@ import java.lang.reflect.Type internal annotation class SerializeNulls { companion object { val JSON_ADAPTER_FACTORY: JsonAdapter.Factory = object : JsonAdapter.Factory { - @Nullable override fun create(type: Type, annotations: Set, moshi: Moshi): JsonAdapter<*>? { val nextAnnotations = Types.nextAnnotations(annotations, SerializeNulls::class.java) ?: return null diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/network/interceptors/FormattedJsonHttpLogger.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/network/interceptors/FormattedJsonHttpLogger.kt index 4e0525536c..334a8c5076 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/network/interceptors/FormattedJsonHttpLogger.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/network/interceptors/FormattedJsonHttpLogger.kt @@ -16,7 +16,6 @@ package org.matrix.android.sdk.internal.network.interceptors -import androidx.annotation.NonNull import okhttp3.logging.HttpLoggingInterceptor import org.json.JSONArray import org.json.JSONException @@ -38,7 +37,7 @@ internal class FormattedJsonHttpLogger( * @param message */ @Synchronized - override fun log(@NonNull message: String) { + override fun log(message: String) { Timber.v(message) // Try to log formatted Json only if there is a chance that [message] contains Json. diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/network/parsing/CheckNumberType.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/network/parsing/CheckNumberType.kt index 8b54978279..6c28b9fcce 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/network/parsing/CheckNumberType.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/network/parsing/CheckNumberType.kt @@ -16,7 +16,6 @@ package org.matrix.android.sdk.internal.network.parsing -import androidx.annotation.Nullable import com.squareup.moshi.JsonAdapter import com.squareup.moshi.JsonReader import com.squareup.moshi.JsonWriter @@ -32,14 +31,12 @@ internal interface CheckNumberType { companion object { val JSON_ADAPTER_FACTORY = object : JsonAdapter.Factory { - @Nullable override fun create(type: Type, annotations: Set, moshi: Moshi): JsonAdapter<*>? { if (type !== Any::class.java) { return null } val delegate: JsonAdapter = moshi.nextAdapter(this, Any::class.java, emptySet()) return object : JsonAdapter() { - @Nullable @Throws(IOException::class) override fun fromJson(reader: JsonReader): Any? { return if (reader.peek() !== JsonReader.Token.NUMBER) { diff --git a/tools/lint/lint.xml b/tools/lint/lint.xml index 3d3b073749..dbe30f2267 100644 --- a/tools/lint/lint.xml +++ b/tools/lint/lint.xml @@ -77,6 +77,7 @@ + diff --git a/vector/src/main/java/im/vector/app/core/resources/StringArrayProvider.kt b/vector/src/main/java/im/vector/app/core/resources/StringArrayProvider.kt index 9ed3c02ba4..3c057e0635 100644 --- a/vector/src/main/java/im/vector/app/core/resources/StringArrayProvider.kt +++ b/vector/src/main/java/im/vector/app/core/resources/StringArrayProvider.kt @@ -18,7 +18,6 @@ package im.vector.app.core.resources import android.content.res.Resources import androidx.annotation.ArrayRes -import androidx.annotation.NonNull import javax.inject.Inject class StringArrayProvider @Inject constructor(private val resources: Resources) { @@ -31,7 +30,6 @@ class StringArrayProvider @Inject constructor(private val resources: Resources) * @return The string array associated with the resource, stripped of styled * text information. */ - @NonNull fun getStringArray(@ArrayRes resId: Int): Array { return resources.getStringArray(resId) } diff --git a/vector/src/main/java/im/vector/app/core/resources/StringProvider.kt b/vector/src/main/java/im/vector/app/core/resources/StringProvider.kt index 7e322daaae..e5f48f8be0 100644 --- a/vector/src/main/java/im/vector/app/core/resources/StringProvider.kt +++ b/vector/src/main/java/im/vector/app/core/resources/StringProvider.kt @@ -17,7 +17,6 @@ package im.vector.app.core.resources import android.content.res.Resources -import androidx.annotation.NonNull import androidx.annotation.PluralsRes import androidx.annotation.StringRes import javax.inject.Inject @@ -32,7 +31,6 @@ class StringProvider @Inject constructor(private val resources: Resources) { * @return The string data associated with the resource, stripped of styled * text information. */ - @NonNull fun getString(@StringRes resId: Int): String { return resources.getString(resId) } @@ -48,12 +46,10 @@ class StringProvider @Inject constructor(private val resources: Resources) { * @return The string data associated with the resource, formatted and * stripped of styled text information. */ - @NonNull fun getString(@StringRes resId: Int, vararg formatArgs: Any?): String { return resources.getString(resId, *formatArgs) } - @NonNull fun getQuantityString(@PluralsRes resId: Int, quantity: Int, vararg formatArgs: Any?): String { return resources.getQuantityString(resId, quantity, *formatArgs) }