Skip to content

Commit

Permalink
ci: add android and compose lint
Browse files Browse the repository at this point in the history
  • Loading branch information
vitorhugods committed May 21, 2024
1 parent fd020b2 commit 651f981
Show file tree
Hide file tree
Showing 7 changed files with 8,698 additions and 11 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/codestyle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ jobs:
cache: gradle
- name: Validate Gradle wrapper
uses: gradle/wrapper-validation-action@5188e9b5527a0a094cee21e2fe9a8ca44b4629af
- name: Run Linter
run: |
./gradlew lint
- name: Run Detekt
run: |
./gradlew detektAll
Expand Down
8,292 changes: 8,292 additions & 0 deletions app/lint-baseline.xml

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions benchmark/lint-baseline.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<issues format="6" by="lint 8.2.0" type="baseline" client="gradle" dependencies="false" name="AGP (8.2.0)" variant="all" version="8.2.0">

</issues>
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import org.gradle.kotlin.dsl.provideDelegate
import org.gradle.kotlin.dsl.withType
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import versionCatalog
import findLibrary

internal fun Project.configureKotlinAndroid(
commonExtension: CommonExtension<*, *, *, *, *>, // Add another `*` when upgrading AGP to 8.3
Expand All @@ -50,17 +51,7 @@ internal fun Project.configureKotlinAndroid(
dependencies {
add("coreLibraryDesugaring", versionCatalog.findLibrary("android.desugarJdkLibs").get())
}

// Lint Configuration
lint {
quiet = true
abortOnError = false
ignoreWarnings = true
disable.add("InvalidPackage") // Some libraries have issues with this.
disable.add("OldTargetApi") // Lint gives this warning related to SDK Beta.
disable.add("IconDensities") // For testing purpose. This is safe to remove.
disable.add("IconMissingDensityFolder") // For testing purpose. This is safe to remove.
}
configureLint(project)
}

/**
Expand All @@ -85,6 +76,26 @@ private fun Project.configureKotlin() {
}
}

private fun CommonExtension<*, *, *, *, *>.configureLint(project: Project) {
lint {
quiet = false
abortOnError = true
ignoreWarnings = true
disable.add("InvalidPackage") // Some libraries have issues with this.
disable.add("OldTargetApi") // Lint gives this warning related to SDK Beta.
disable.add("IconDensities") // For testing purpose. This is safe to remove.
disable.add("IconMissingDensityFolder") // For testing purpose. This is safe to remove.
disable.add("ComposePreviewPublic") // Needed for screenshot testing.
baseline = project.file("lint-baseline.xml")
}

with(project) {
dependencies {
add("lintChecks", findLibrary("lint-compose"))
}
}
}

// Add another `*` when upgrading AGP to 8.3
internal fun CommonExtension<*, *, *, *, *>.configureAndroidKotlinTests() {
defaultConfig {
Expand Down
345 changes: 345 additions & 0 deletions core/ui-common/lint-baseline.xml

Large diffs are not rendered by default.

26 changes: 26 additions & 0 deletions features/sketch/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.2.0" type="baseline" client="gradle" dependencies="false" name="AGP (8.2.0)" variant="all" version="8.2.0">

<issue
id="ComposeModifierMissing"
message="This @Composable function emits content but doesn&apos;t have a modifier parameter.See https://slackhq.github.io/compose-lints/rules/#when-should-i-expose-modifier-parameters for more information."
errorLine1="fun DrawingCanvasBottomSheet("
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/java/com/wire/android/feature/sketch/DrawingCanvasBottomSheet.kt"
line="72"
column="5"/>
</issue>

<issue
id="ComposeModifierMissing"
message="This @Composable function emits content but doesn&apos;t have a modifier parameter.See https://slackhq.github.io/compose-lints/rules/#when-should-i-expose-modifier-parameters for more information."
errorLine1="fun DrawingToolPicker("
errorLine2=" ~~~~~~~~~~~~~~~~~">
<location
file="src/main/java/com/wire/android/feature/sketch/DrawingToolPicker.kt"
line="68"
column="5"/>
</issue>

</issues>
6 changes: 6 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ rss-parser = "6.0.7"
# Logging
dataDog = "1.19.3"

# Lint
lint-compose = "1.3.1"

#OAuth
openIdAppAuth = "0.11.1"

Expand Down Expand Up @@ -216,6 +219,9 @@ coil-compose = { module = "io.coil-kt:coil-compose", version.ref = "coil" }
# RSS Feed Loading
rss-parser = { module = "com.prof18.rssparser:rssparser", version.ref = "rss-parser" }

# Lint
lint-compose = { module = "com.slack.lint.compose:compose-lint-checks", version.ref = "lint-compose" }

# Logging
dataDog-core = { module = "com.datadoghq:dd-sdk-android", version.ref = "dataDog" }
dataDog-compose = { module = "com.datadoghq:dd-sdk-android-compose", version.ref = "dataDog" }
Expand Down

0 comments on commit 651f981

Please sign in to comment.