Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: Add compose lints to componentsv2 #170

Open
wants to merge 1 commit into
base: jonny/DCMAW-8694-idiomatic-compose
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions componentsV2/lint-baseline.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<issues format="6" by="lint 8.8.0" type="baseline" client="gradle" dependencies="false" name="AGP (8.8.0)" variant="all" version="8.8.0">

<issue
id="ComposeModifierReused"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These particular problems should not be ignored. I added to the baseline so that future work can benefit from the lint check.

message="Modifiers should only be used once and by the root level layout of a Composable. This is true even if appended to or with other modifiers e.g. modifier.fillMaxWidth().Use Modifier (with a capital &apos;M&apos;) to construct a new Modifier that you can pass to other composables.See https://slackhq.github.io/compose-lints/rules/#dont-re-use-modifiers for more information."
errorLine1=" Button("
errorLine2=" ^">
<location
file="src/main/java/uk/gov/android/ui/componentsv2/button/GdsButton.kt"
line="41"
column="5"/>
</issue>

<issue
id="ComposeModifierReused"
message="Modifiers should only be used once and by the root level layout of a Composable. This is true even if appended to or with other modifiers e.g. modifier.fillMaxWidth().Use Modifier (with a capital &apos;M&apos;) to construct a new Modifier that you can pass to other composables.See https://slackhq.github.io/compose-lints/rules/#dont-re-use-modifiers for more information."
errorLine1=" Content("
errorLine2=" ^">
<location
file="src/main/java/uk/gov/android/ui/componentsv2/button/GdsButton.kt"
line="55"
column="9"/>
</issue>

</issues>
7 changes: 7 additions & 0 deletions componentsv2/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ dependencies {
testImplementation(libs.hilt.android.testing)
testImplementation(libs.junit)
testImplementation(libs.mockito.kotlin)
lintChecks(libs.com.slack.compose.lint.checks)
}

mavenPublishingConfig {
Expand All @@ -103,3 +104,9 @@ mavenPublishingConfig {
)
}
}

android {
lint {
baseline = file("lint-baseline.xml")
}
}
Comment on lines +108 to +112
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needed due to a bug in mobile-android-pipelines where the lint baseline file is not configured to support a multi-module setup.

2 changes: 2 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ androidx-test-orchestrator = "1.5.1" # https://developer.android.com/jetpack/and
appcompat = "1.7.0" # https://developer.android.com/jetpack/androidx/releases/appcompat
archcore-testing = "2.2.0"
compose = "2024.12.01"
compose-lint-checks = "1.4.2"
constraintlayout-compose = "1.1.0"
core-ktx = "1.13.1"
dagger = "2.55" # https://github.com/google/dagger/releases
Expand Down Expand Up @@ -41,6 +42,7 @@ androidx-test-orchestrator = { module = "androidx.test:orchestrator", version.re

appcompat = { group = "androidx.appcompat", name = "appcompat", version.ref = "appcompat" }
arch-core = { group = "androidx.arch.core", name = "core-testing", version.ref = "archcore-testing" }
com-slack-compose-lint-checks = { module = "com.slack.lint.compose:compose-lint-checks", version.ref = "compose-lint-checks" }
core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "core-ktx" }
detekt-gradle = { module = "io.gitlab.arturbosch.detekt:detekt-gradle-plugin", version.ref = "detekt-gradle" }
hilt-android-testing = { group = "com.google.dagger", name = "hilt-android-testing", version.ref = "dagger" }
Expand Down