Skip to content
This repository has been archived by the owner on Nov 12, 2024. It is now read-only.

Integrate Compose Lint Checks #1072

Merged
merged 1 commit into from
Feb 20, 2023
Merged
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
2 changes: 2 additions & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,8 @@ dependencies {
implementation(libs.compose.animation.animation)
implementation(libs.compose.ui.tooling)

lintChecks(libs.slack.lint.compose)

implementation(libs.accompanist.navigation.animation)
implementation(libs.accompanist.navigation.material)

Expand Down
6 changes: 6 additions & 0 deletions common/ui/compose/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ android {
composeOptions {
kotlinCompilerExtensionVersion = libs.versions.composecompiler.get()
}

lint {
baseline = file("lint-baseline.xml")
}
}

dependencies {
Expand Down Expand Up @@ -60,4 +64,6 @@ dependencies {
implementation(libs.androidx.paging.compose)

implementation(libs.coil.compose)

lintChecks(libs.slack.lint.compose)
}
37 changes: 37 additions & 0 deletions common/ui/compose/lint-baseline.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?xml version="1.0" encoding="UTF-8"?>
<issues format="6" by="lint 8.0.0-beta02" type="baseline" client="gradle" dependencies="false" name="AGP (8.0.0-beta02)" variant="all" version="8.0.0-beta02">

<issue
id="ComposeParameterOrder"
message="Parameters in a composable function should be ordered following this pattern: params without defaults, modifiers, params with defaults and optionally, a trailing function that might not have a default param.&#xA;Current params are: [title: @Composable () -> Unit, modifier: Modifier = Modifier, navigationIcon: @Composable () -> Unit, bottomContent: @Composable (() -> Unit)? = null, actions: @Composable RowScope.() -> Unit = {}, containerColor: Color = MaterialTheme.colorScheme.surface, contentColor: Color = contentColorFor(containerColor), elevation: Dp = 0.dp] but should be [title: @Composable () -> Unit, navigationIcon: @Composable () -> Unit, modifier: Modifier = Modifier, bottomContent: @Composable (() -> Unit)? = null, actions: @Composable RowScope.() -> Unit = {}, containerColor: Color = MaterialTheme.colorScheme.surface, contentColor: Color = contentColorFor(containerColor), elevation: Dp = 0.dp].&#xA;See https://slackhq.github.io/compose-lints/rules/#ordering-composable-parameters-properly for more information."
errorLine1="/**"
errorLine2="^">
<location
file="src/main/java/app/tivi/common/compose/ui/AppBar.kt"
line="39"
column="1"/>
</issue>

<issue
id="ComposeUnstableCollections"
message="The Compose Compiler cannot infer the stability of a parameter if a List&lt;SortOption> is used in it, even if the item type is stable.&#xA;You should use Kotlinx Immutable Collections instead: `sortOptions: ImmutableList&lt;SortOption>` or create an `@Immutable` wrapper for this class: `@Immutable data class SortOptionsList(val items: List&lt;SortOption>)`&#xA;See https://slackhq.github.io/compose-lints/rules/#avoid-using-unstable-collections for more information."
errorLine1=" sortOptions: List&lt;SortOption>,"
errorLine2=" ~~~~~~~~~~~~~~~~">
<location
file="src/main/java/app/tivi/common/compose/ui/SortChip.kt"
line="43"
column="18"/>
</issue>

<issue
id="ComposeUnstableCollections"
message="The Compose Compiler cannot infer the stability of a parameter if a List&lt;SortOption> is used in it, even if the item type is stable.&#xA;You should use Kotlinx Immutable Collections instead: `sortOptions: ImmutableList&lt;SortOption>` or create an `@Immutable` wrapper for this class: `@Immutable data class SortOptionsList(val items: List&lt;SortOption>)`&#xA;See https://slackhq.github.io/compose-lints/rules/#avoid-using-unstable-collections for more information."
errorLine1=" sortOptions: List&lt;SortOption>,"
errorLine2=" ~~~~~~~~~~~~~~~~">
<location
file="src/main/java/app/tivi/common/compose/ui/SortMenuPopup.kt"
line="32"
column="18"/>
</issue>

</issues>
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,14 @@ import app.tivi.common.compose.theme.TiviTheme
fun ScrimmedIconButton(
showScrim: Boolean,
onClick: () -> Unit,
modifier: Modifier = Modifier,
invertThemeOnScrim: Boolean = true,
icon: @Composable () -> Unit,
) {
IconButton(onClick = onClick) {
IconButton(
onClick = onClick,
modifier = modifier,
) {
if (invertThemeOnScrim) {
val isLight = MaterialTheme.colorScheme.surface.luminance() > 0.5

Expand Down
2 changes: 2 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,8 @@ retrofit-mock = { module = "com.squareup.retrofit2:retrofit-mock", version.ref =

robolectric = "org.robolectric:robolectric:4.9.2"

slack-lint-compose = "com.slack.lint.compose:compose-lint-checks:1.0.1"

swipe = "me.saket.swipe:swipe:1.1.1"

store = "org.mobilenativefoundation.store:store5:5.0.0-alpha03"
Expand Down
2 changes: 2 additions & 0 deletions ui/account/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,6 @@ dependencies {
implementation(libs.coil.compose)

ksp(libs.kotlininject.compiler)

lintChecks(libs.slack.lint.compose)
}
2 changes: 2 additions & 0 deletions ui/discover/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,6 @@ dependencies {
implementation(libs.compose.ui.tooling)

ksp(libs.kotlininject.compiler)

lintChecks(libs.slack.lint.compose)
}
2 changes: 2 additions & 0 deletions ui/episode/details/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,6 @@ dependencies {
implementation(libs.coil.compose)

ksp(libs.kotlininject.compiler)

lintChecks(libs.slack.lint.compose)
}
2 changes: 2 additions & 0 deletions ui/episode/track/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,6 @@ dependencies {
implementation(libs.coil.compose)

ksp(libs.kotlininject.compiler)

lintChecks(libs.slack.lint.compose)
}
2 changes: 2 additions & 0 deletions ui/library/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,6 @@ dependencies {
implementation(libs.coil.compose)

ksp(libs.kotlininject.compiler)

lintChecks(libs.slack.lint.compose)
}
2 changes: 2 additions & 0 deletions ui/popular/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,6 @@ dependencies {
implementation(libs.compose.ui.tooling)

ksp(libs.kotlininject.compiler)

lintChecks(libs.slack.lint.compose)
}
2 changes: 2 additions & 0 deletions ui/recommended/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,6 @@ dependencies {
implementation(libs.compose.ui.tooling)

ksp(libs.kotlininject.compiler)

lintChecks(libs.slack.lint.compose)
}
2 changes: 2 additions & 0 deletions ui/search/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,6 @@ dependencies {
implementation(libs.compose.ui.tooling)

ksp(libs.kotlininject.compiler)

lintChecks(libs.slack.lint.compose)
}
2 changes: 2 additions & 0 deletions ui/show/details/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,6 @@ dependencies {
implementation(libs.coil.compose)

ksp(libs.kotlininject.compiler)

lintChecks(libs.slack.lint.compose)
}
2 changes: 2 additions & 0 deletions ui/show/seasons/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,6 @@ dependencies {
implementation(libs.coil.compose)

ksp(libs.kotlininject.compiler)

lintChecks(libs.slack.lint.compose)
}
2 changes: 2 additions & 0 deletions ui/trending/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,6 @@ dependencies {
implementation(libs.compose.ui.tooling)

ksp(libs.kotlininject.compiler)

lintChecks(libs.slack.lint.compose)
}