Skip to content
Open
Show file tree
Hide file tree
Changes from 7 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
32 changes: 28 additions & 4 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,30 @@ jobs:
with:
category: "KTlint"

detekt:
needs: [lockfiles, yamllint]
runs-on: ubuntu-latest
permissions:
security-events: write
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false

- uses: ./.github/actions/setup-build-env
with:
cache-encryption-key: ${{ secrets.GRADLE_ENCRYPTION_KEY }}
mock-google-services: "true"

# Since `build-logic` is added with `includeBuild` we have to call detektMain explicitly on `:convention`.
- name: Validate Detekt
run: ./gradlew detektMain :build-logic:convention:detektMain --continue

- uses: ./.github/actions/upload-sarif-results
if: always()
with:
category: "Detekt"

lint:
needs: [lockfiles, ktlint]
runs-on: ubuntu-latest
Expand Down Expand Up @@ -191,7 +215,7 @@ jobs:

screenshot_test:
name: "Screenshot Tests"
needs: [lint, lockfiles, ktlint]
needs: [detekt, lint, lockfiles, ktlint]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
Expand Down Expand Up @@ -299,7 +323,7 @@ jobs:

unit_tests:
name: "Unit Tests"
needs: [lint, lockfiles, ktlint]
needs: [detekt, lint, lockfiles, ktlint]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
Expand All @@ -323,7 +347,7 @@ jobs:

build_emulator_wtf_apks:
name: "Build Emulator.wtf APKs"
needs: [lint, lockfiles, ktlint]
needs: [detekt, lint, lockfiles, ktlint]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
Expand Down Expand Up @@ -363,7 +387,7 @@ jobs:

instrumentation_test:
name: "Instrumentation Tests"
needs: [lint, lockfiles, ktlint]
needs: [detekt, lint, lockfiles, ktlint]
runs-on: ubuntu-latest
strategy:
# We want the result of each device to be reported, so we can't fail-fast
Expand Down
25 changes: 25 additions & 0 deletions .idea/runConfigurations/Detekt.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

682 changes: 682 additions & 0 deletions app/detekt-baseline-fullDebug.xml

Large diffs are not rendered by default.

676 changes: 676 additions & 0 deletions app/detekt-baseline-fullRelease.xml

Large diffs are not rendered by default.

595 changes: 595 additions & 0 deletions app/detekt-baseline-minimalDebug.xml

Large diffs are not rendered by default.

589 changes: 589 additions & 0 deletions app/detekt-baseline-minimalRelease.xml

Large diffs are not rendered by default.

326 changes: 326 additions & 0 deletions app/detekt-baseline.xml

Large diffs are not rendered by default.

63 changes: 53 additions & 10 deletions app/gradle.lockfile

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions automotive/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@ android {
}
}

detekt {
// Automotive reuses the app's Kotlin source sets, which are already analyzed by :app.
ignoredFlavors = listOf("full", "minimal")
}
Comment thread
loganrosen marked this conversation as resolved.

dependencies {
// Most of the dependencies are coming from the convention plugin to avoid duplication with `:app` module.
implementation(libs.car.automotive)
Expand Down
63 changes: 53 additions & 10 deletions automotive/gradle.lockfile

Large diffs are not rendered by default.

16 changes: 16 additions & 0 deletions build-logic/convention/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
import dev.detekt.gradle.Detekt
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jlleitschuh.gradle.ktlint.reporter.ReporterType

plugins {
`kotlin-dsl`
alias(libs.plugins.detekt)
alias(libs.plugins.ktlint)
}

group = "io.homeassistant.companion.android.buildlogic"

allprojects {
apply(plugin = rootProject.libs.plugins.detekt.get().pluginId)
apply(plugin = rootProject.libs.plugins.ktlint.get().pluginId)

ktlint {
Expand All @@ -24,6 +27,19 @@ allprojects {
exclude { it.file.path.contains("build${File.separator}generated-sources") }
}
}

detekt {
baseline = project.file("detekt-baseline.xml")
config.setFrom(rootProject.file("../config/detekt/detekt.yml"))
buildUponDefaultConfig = true
}

tasks.withType<Detekt>().configureEach {
reports {
html.required.set(true)
sarif.required.set(true)
}
}
}

// Configure the build-logic plugins to target JDK 17 and is not related to what is running on device.
Expand Down
9 changes: 9 additions & 0 deletions build-logic/convention/detekt-baseline-main.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" ?>
<SmellBaseline>
<ManuallySuppressedIssues/>
<CurrentIssues>
<ID>LongMethod:AndroidApplicationDependenciesConventionPlugin.kt:AndroidApplicationDependenciesConventionPlugin$override fun apply</ID>
<ID>LongMethod:AndroidCommonConventionPlugin.kt:AndroidCommonConventionPlugin$override fun apply</ID>
<ID>MagicNumber:AndroidComposeConventionPlugin.kt:AndroidComposeConventionPlugin$0.00025f</ID>
</CurrentIssues>
</SmellBaseline>
9 changes: 9 additions & 0 deletions build-logic/convention/detekt-baseline.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" ?>
<SmellBaseline>
<ManuallySuppressedIssues/>
<CurrentIssues>
<ID>LongMethod:AndroidApplicationDependenciesConventionPlugin.kt:AndroidApplicationDependenciesConventionPlugin$override fun apply</ID>
<ID>LongMethod:AndroidCommonConventionPlugin.kt:AndroidCommonConventionPlugin$override fun apply</ID>
<ID>MagicNumber:AndroidComposeConventionPlugin.kt:AndroidComposeConventionPlugin$0.00025f</ID>
</CurrentIssues>
</SmellBaseline>
16 changes: 16 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import dev.detekt.gradle.Detekt
import org.jlleitschuh.gradle.ktlint.reporter.ReporterType

val kotlinVersion = libs.versions.kotlin.get()

plugins {
alias(libs.plugins.detekt)
alias(libs.plugins.ktlint)

alias(libs.plugins.aboutlibraries).apply(false)
Expand All @@ -20,6 +22,7 @@ plugins {
}

allprojects {
apply(plugin = rootProject.libs.plugins.detekt.get().pluginId)
apply(plugin = rootProject.libs.plugins.ktlint.get().pluginId)

// TODO this has been added until https://youtrack.jetbrains.com/issue/KT-87220/Kotlin-Gradle-plugin-resolves-kotlinAbiValidationCompatClasspath-to-newer-beta-Kotlin-artifacts-during-dependency-locking is addressed
Expand Down Expand Up @@ -54,6 +57,19 @@ allprojects {
}
}

detekt {
baseline = project.file("detekt-baseline.xml")
config.setFrom(rootProject.file("config/detekt/detekt.yml"))
buildUponDefaultConfig = true
}

tasks.withType<Detekt>().configureEach {
reports {
html.required.set(true)
sarif.required.set(true)
}
}

dependencyLocking {
lockAllConfigurations()
}
Expand Down
Loading
Loading