From 72e5ca887d4b587d32b200b868b77672f3a6b5c5 Mon Sep 17 00:00:00 2001 From: Nik Clayton Date: Fri, 1 Mar 2024 23:07:14 +0100 Subject: [PATCH] fix(deps): update agp to v8.3.0, lint to 31.3.0 (#483) New lint rules highlighted a potential crash; the use of named match groups (used here when extracting server versions) requires API >= 26 or throws an exception. Use the group numbers instead of names when extracting the value, but keep the group names in the regular expressions for readability. --- app/lint-baseline.xml | 24 +++++- .../main/kotlin/app/pachli/KotlinAndroid.kt | 2 +- .../main/kotlin/app/pachli/PachliFlavor.kt | 8 +- core/network/lint-baseline.xml | 2 +- .../kotlin/app/pachli/core/network/Server.kt | 15 ++-- core/testing/lint-baseline.xml | 79 +------------------ gradle/libs.versions.toml | 4 +- 7 files changed, 42 insertions(+), 92 deletions(-) diff --git a/app/lint-baseline.xml b/app/lint-baseline.xml index 89bcf046a..7f4f0d77c 100644 --- a/app/lint-baseline.xml +++ b/app/lint-baseline.xml @@ -1,5 +1,5 @@ - + + + + + + + + + , + commonExtension: CommonExtension<*, *, *, *, *, *>, ) { commonExtension.apply { compileSdk = 34 diff --git a/build-logic/convention/src/main/kotlin/app/pachli/PachliFlavor.kt b/build-logic/convention/src/main/kotlin/app/pachli/PachliFlavor.kt index 99f7f82be..d529ec52b 100644 --- a/build-logic/convention/src/main/kotlin/app/pachli/PachliFlavor.kt +++ b/build-logic/convention/src/main/kotlin/app/pachli/PachliFlavor.kt @@ -25,7 +25,7 @@ import com.android.build.api.dsl.ProductFlavor @Suppress("EnumEntryName") enum class FlavorDimension { color, - store + store, } @Suppress("EnumEntryName") @@ -47,12 +47,12 @@ enum class PachliFlavor( ), fdroid(FlavorDimension.store), github(FlavorDimension.store), - google(FlavorDimension.store) + google(FlavorDimension.store), } fun configureFlavors( - commonExtension: CommonExtension<*, *, *, *, *>, - flavorConfigurationBlock: ProductFlavor.(flavor: PachliFlavor) -> Unit = {} + commonExtension: CommonExtension<*, *, *, *, *, *>, + flavorConfigurationBlock: ProductFlavor.(flavor: PachliFlavor) -> Unit = {}, ) { commonExtension.apply { flavorDimensions += FlavorDimension.color.name diff --git a/core/network/lint-baseline.xml b/core/network/lint-baseline.xml index 03c0924e0..fb7b14703 100644 --- a/core/network/lint-baseline.xml +++ b/core/network/lint-baseline.xml @@ -1,4 +1,4 @@ - + diff --git a/core/network/src/main/kotlin/app/pachli/core/network/Server.kt b/core/network/src/main/kotlin/app/pachli/core/network/Server.kt index 7ec54b032..ba05ac6f4 100644 --- a/core/network/src/main/kotlin/app/pachli/core/network/Server.kt +++ b/core/network/src/main/kotlin/app/pachli/core/network/Server.kt @@ -162,7 +162,8 @@ data class Server( rx.find(version) .toResultOr { UnparseableVersion(version, ParseException("unexpected null", 0)) } .andThen { - val adjusted = "${it.groups["major"]?.value}.${it.groups["minor"]?.value}.${it.groups["patch"]?.value}" + // Fetching groups by name instead of index requires API >= 26 + val adjusted = "${it.groups[1]?.value}.${it.groups[2]?.value}.${it.groups[3]?.value}" runSuspendCatching { Version.parse(adjusted, strict = false) } .mapError { UnparseableVersion(version, it) } } @@ -180,7 +181,8 @@ data class Server( rx.find(version) .toResultOr { UnparseableVersion(version, ParseException("unexpected null", 0)) } .andThen { - val adjusted = "${it.groups["major"]?.value}.${it.groups["minor"]?.value}.0" + // Fetching groups by name instead of index requires API >= 26 + val adjusted = "${it.groups[1]?.value}.${it.groups[2]?.value}.0" runSuspendCatching { Version.parse(adjusted, strict = false) } .mapError { UnparseableVersion(version, it) } } @@ -216,7 +218,8 @@ data class Server( val rx = """^0*(?\d+)\.0*(?\d+)\.0*(?\d+)""".toRegex() rx.find(version).toResultOr { UnparseableVersion(version, ParseException("unexpected null", 0)) } .andThen { - val adjusted = "${it.groups["major"]?.value}.${it.groups["minor"]?.value ?: 0}.${it.groups["patch"]?.value ?: 0}" + // Fetching groups by name instead of index requires API >= 26 + val adjusted = "${it.groups[1]?.value}.${it.groups[2]?.value ?: 0}.${it.groups[3]?.value ?: 0}" runSuspendCatching { Version.parse(adjusted, strict = false) } .mapError { UnparseableVersion(adjusted, it) } } @@ -228,7 +231,8 @@ data class Server( val rx = """Pleroma (?\d+)\.(?\d+)\.(?\d+)""".toRegex() rx.find(version).toResultOr { UnparseableVersion(version, ParseException("unexpected null", 0)) } .andThen { - val adjusted = "${it.groups["major"]?.value}.${it.groups["minor"]?.value}.${it.groups["patch"]?.value}" + // Fetching groups by name instead of index requires API >= 26 + val adjusted = "${it.groups[1]?.value}.${it.groups[2]?.value}.${it.groups[3]?.value}" runSuspendCatching { Version.parse(adjusted, strict = false) } .mapError { UnparseableVersion(adjusted, it) } } @@ -240,7 +244,8 @@ data class Server( val rx = """^(?\d+)\.(?\d+)\.(?\d+)""".toRegex() rx.find(version).toResultOr { UnparseableVersion(version, ParseException("unexpected null", 0)) } .andThen { - val adjusted = "${it.groups["major"]?.value}.${it.groups["minor"]?.value}.${it.groups["patch"]?.value}" + // Fetching groups by name instead of index requires API >= 26 + val adjusted = "${it.groups[1]?.value}.${it.groups[2]?.value}.${it.groups[3]?.value}" runSuspendCatching { Version.parse(adjusted, strict = false) } .mapError { UnparseableVersion(adjusted, it) } } diff --git a/core/testing/lint-baseline.xml b/core/testing/lint-baseline.xml index a2ca26aaa..77667c9db 100644 --- a/core/testing/lint-baseline.xml +++ b/core/testing/lint-baseline.xml @@ -1,5 +1,5 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 1845b16be..421d7927d 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,7 +1,7 @@ [versions] aboutlibraries = "10.10.0" acra = "5.11.3" -agp = "8.2.2" +agp = "8.3.0" androidx-activity = "1.8.2" androidx-appcompat = "1.6.1" androidx-browser = "1.7.0" @@ -46,7 +46,7 @@ kotlin-result = "1.1.18" ksp = "1.9.22-1.0.17" image-cropper = "4.3.2" leakcanary = "2.13" -lint = "31.2.2" # = agp + 23.0.0 (= 8.2.2), see https://github.com/googlesamples/android-custom-lint-rules#lint-version +lint = "31.3.0" # = agp + 23.0.0 (= 8.3.0), see https://github.com/googlesamples/android-custom-lint-rules#lint-version material = "1.11.0" material-drawer = "9.0.2" material-typeface = "4.0.0.2-kotlin"