summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHarsh Shandilya <me@msfjarvis.dev>2023-04-27 14:43:47 +0530
committerHarsh Shandilya <me@msfjarvis.dev>2023-04-27 14:45:06 +0530
commit5659ad9863f7ce47962668a473fd29c79d9c710e (patch)
treefd1f6d0cee7665b078a852fff56544816ed14832
parentf0ac9f97e2551aef14cd023de95da3281f12a5ee (diff)
feat(build): add Slack's Compose Lints
-rw-r--r--app/lint-baseline.xml11
-rw-r--r--build-logic/src/main/kotlin/app/passwordstore/gradle/AndroidCommon.kt8
-rw-r--r--build-logic/src/main/kotlin/app/passwordstore/gradle/KotlinJVMLibrary.kt2
-rw-r--r--build-logic/src/main/kotlin/app/passwordstore/gradle/LintConfig.kt6
-rw-r--r--gradle/libs.versions.toml1
5 files changed, 26 insertions, 2 deletions
diff --git a/app/lint-baseline.xml b/app/lint-baseline.xml
index e0ce6073..d599da9d 100644
--- a/app/lint-baseline.xml
+++ b/app/lint-baseline.xml
@@ -129,6 +129,17 @@
</issue>
<issue
+ id="ComposeUnstableCollections"
+ message="The Compose Compiler cannot infer the stability of a parameter if a List&lt;GpgIdentifier> is used in it, even if the item type is stable.&#xA;You should use Kotlinx Immutable Collections instead: `identifiers: ImmutableList&lt;GpgIdentifier>` or create an `@Immutable` wrapper for this class: `@Immutable data class IdentifiersList(val items: List&lt;GpgIdentifier>)`&#xA;See https://slackhq.github.io/compose-lints/rules/#avoid-using-unstable-collections for more information."
+ errorLine1=" identifiers: List&lt;GpgIdentifier>,"
+ errorLine2=" ~~~~~~~~~~~~~~~~~~~">
+ <location
+ file="src/main/java/app/passwordstore/ui/pgp/PGPKeyList.kt"
+ line="36"
+ column="16"/>
+ </issue>
+
+ <issue
id="UnknownNullness"
message="Should explicitly declare type here since implicit type does not specify nullness (Lazy&lt;Array&lt;(GitCommand&lt;out (Any or Any?)> or GitCommand&lt;out (Any or Any?)>?)>>)"
errorLine1=" override val commands by unsafeLazy {"
diff --git a/build-logic/src/main/kotlin/app/passwordstore/gradle/AndroidCommon.kt b/build-logic/src/main/kotlin/app/passwordstore/gradle/AndroidCommon.kt
index 04a2dc7a..c337d9d5 100644
--- a/build-logic/src/main/kotlin/app/passwordstore/gradle/AndroidCommon.kt
+++ b/build-logic/src/main/kotlin/app/passwordstore/gradle/AndroidCommon.kt
@@ -7,9 +7,11 @@ import com.android.build.api.dsl.LibraryExtension
import com.android.build.gradle.TestedExtension
import org.gradle.api.JavaVersion
import org.gradle.api.Project
+import org.gradle.api.artifacts.VersionCatalogsExtension
import org.gradle.api.tasks.testing.Test
import org.gradle.kotlin.dsl.configure
import org.gradle.kotlin.dsl.findByType
+import org.gradle.kotlin.dsl.getByType
import org.gradle.kotlin.dsl.withType
object AndroidCommon {
@@ -56,5 +58,11 @@ object AndroidCommon {
}
project.extensions.findByType<ApplicationExtension>()?.run { lint.configureLint(project) }
project.extensions.findByType<LibraryExtension>()?.run { lint.configureLint(project) }
+ val catalog = project.extensions.getByType<VersionCatalogsExtension>()
+ val libs = catalog.named("libs")
+ project.dependencies.addProvider(
+ "lintChecks",
+ libs.findLibrary("thirdparty-compose-lints").get()
+ )
}
}
diff --git a/build-logic/src/main/kotlin/app/passwordstore/gradle/KotlinJVMLibrary.kt b/build-logic/src/main/kotlin/app/passwordstore/gradle/KotlinJVMLibrary.kt
index 253c7aed..c5cf84a0 100644
--- a/build-logic/src/main/kotlin/app/passwordstore/gradle/KotlinJVMLibrary.kt
+++ b/build-logic/src/main/kotlin/app/passwordstore/gradle/KotlinJVMLibrary.kt
@@ -23,6 +23,6 @@ class KotlinJVMLibrary : Plugin<Project> {
apply(LintPlugin::class)
apply(KotlinCommonPlugin::class)
}
- project.extensions.configure<Lint> { configureLint(project) }
+ project.extensions.configure<Lint> { configureLint(project, isJVM = true) }
}
}
diff --git a/build-logic/src/main/kotlin/app/passwordstore/gradle/LintConfig.kt b/build-logic/src/main/kotlin/app/passwordstore/gradle/LintConfig.kt
index 41bb781f..de63c580 100644
--- a/build-logic/src/main/kotlin/app/passwordstore/gradle/LintConfig.kt
+++ b/build-logic/src/main/kotlin/app/passwordstore/gradle/LintConfig.kt
@@ -4,7 +4,7 @@ import com.android.build.api.dsl.Lint
import org.gradle.api.Project
object LintConfig {
- fun Lint.configureLint(project: Project) {
+ fun Lint.configureLint(project: Project, isJVM: Boolean = false) {
quiet = project.providers.environmentVariable("CI").isPresent
abortOnError = true
checkReleaseBuilds = true
@@ -28,6 +28,10 @@ object LintConfig {
disable += "TypographyQuotes"
// False-positives abound due to use of ViewBinding
disable += "UnusedIds"
+ if (!isJVM) {
+ enable += "ComposeM2Api"
+ error += "ComposeM2Api"
+ }
baseline = project.file("lint-baseline.xml")
}
}
diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml
index 238133f3..a4c8e428 100644
--- a/gradle/libs.versions.toml
+++ b/gradle/libs.versions.toml
@@ -79,6 +79,7 @@ testing-turbine = "app.cash.turbine:turbine:0.12.3"
thirdparty-bouncycastle-bcpkix = { module = "org.bouncycastle:bcpkix-jdk15to18", version.ref = "bouncycastle" }
thirdparty-bouncycastle-bcprov = { module = "org.bouncycastle:bcprov-jdk15to18", version.ref = "bouncycastle" }
thirdparty-commons_codec = "commons-codec:commons-codec:1.14"
+thirdparty-compose-lints = "com.slack.lint.compose:compose-lint-checks:1.2.0"
thirdparty-eddsa = "net.i2p.crypto:eddsa:0.3.0"
thirdparty-fastscroll = "me.zhanghai.android.fastscroll:library:1.2.0"
thirdparty-flowbinding-android = { module = "io.github.reactivecircus.flowbinding:flowbinding-android", version.ref = "flowbinding" }