Skip to content
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 .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
root = true

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true

[*.{kt,kts}]
indent_size = 4
indent_style = space
ij_kotlin_allow_trailing_comma = true
ij_kotlin_allow_trailing_comma_on_call_site = true
ij_kotlin_name_count_to_use_star_import = 2147483647
ij_kotlin_name_count_to_use_star_import_for_members = 2147483647
ij_kotlin_packages_to_use_import_on_demand = unset
ktlint_class_signature_rule_force_multiline_when_parameter_count_greater_or_equal_than = 1
ij_kotlin_line_break_after_multiline_when_entry = false
ktlint_code_style = android_studio
ktlint_function_naming_ignore_when_annotated_with = Composable
ktlint_standard_filename = disabled
ktlint_standard_function-expression-body = disabled
ktlint_standard_function-signature = disabled
ktlint_standard_trailing-comma-on-call-site = disabled
ktlint_standard_blank-line-between-when-conditions = disabled
max_line_length = 100
448 changes: 448 additions & 0 deletions AGENTS.md

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions CLAUDE.md
1 change: 1 addition & 0 deletions GEMINI.md
78 changes: 78 additions & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import dev.detekt.gradle.Detekt
import dev.detekt.gradle.DetektCreateBaselineTask
import java.io.FileInputStream
import java.util.Properties
import org.jetbrains.kotlin.gradle.tasks.KotlinJvmCompile

val keystorePropertiesFile = rootProject.file("keystore.properties")
val useKeystoreProperties = keystorePropertiesFile.canRead()
Expand All @@ -10,6 +13,64 @@ if (useKeystoreProperties) {

plugins {
alias(libs.plugins.android.application)
alias(libs.plugins.detekt)
alias(libs.plugins.hilt)
alias(libs.plugins.ksp)
}

detekt {
basePath.set(rootDir)
baseline = file("detekt-baseline.xml")
buildUponDefaultConfig = true
config.setFrom(rootProject.file("config/detekt/detekt.yml"))
ignoredBuildTypes = listOf("release")
parallel = true
}

// detekt's classpath convention is the compilation's dependencies and nothing else, so BuildConfig
// and androidxc/ resolve to nothing and every type-aware rule goes quiet instead of reporting. A
// Gradle convention cannot be appended to: `from` would discard it, hence `setFrom` with both.
fun addOwnClassesToDetektClasspath(
classpath: ConfigurableFileCollection,
variantName: String,
) {
classpath.setFrom(
tasks.named<KotlinJvmCompile>("compile${variantName}Kotlin").map { it.libraries },
tasks.named("compile${variantName}JavaWithJavac").map { it.outputs.files },
)
}

// Only the variants `check` gates on below. The plugin's other detekt tasks analyse a source set
// at a time without types and have no compilation to take a classpath from.
listOf("Debug", "DebugUnitTest", "DebugAndroidTest").forEach { variantName ->
tasks
.withType<Detekt>()
.matching { it.name == "detekt$variantName" }
.configureEach {
addOwnClassesToDetektClasspath(classpath, variantName)
}

tasks
.withType<DetektCreateBaselineTask>()
.matching { it.name == "detektBaseline$variantName" }
.configureEach {
addOwnClassesToDetektClasspath(classpath, variantName)
}
}

// The aggregate `detekt` task analyses every source set at once without type resolution, so it
// cannot see what the type-aware rules exist for. The debug variants cover the same sources with
// types, so `check` gates on those and the aggregate stays off.
tasks.named("check") {
dependsOn(
tasks.named("detektDebug"),
tasks.named("detektDebugUnitTest"),
tasks.named("detektDebugAndroidTest"),
)
}

tasks.named("detekt") {
enabled = false
}

java {
Expand Down Expand Up @@ -89,6 +150,14 @@ android {
androidResources {
localeFilters += listOf("en")
}

testOptions {
unitTests {
// Robolectric builds its application under test from the merged manifest and
// resources; without this it cannot start one.
isIncludeAndroidResources = true
}
}
}

dependencies {
Expand All @@ -97,10 +166,19 @@ dependencies {
implementation(libs.androidx.constraintlayout)
implementation(libs.androidx.core.ktx)

implementation(libs.kotlinx.coroutines.core)

implementation(libs.hilt.android)
ksp(libs.hilt.compiler)

implementation(libs.bundles.camerax)

implementation(libs.zxing.core)

testImplementation(libs.junit4)
testImplementation(libs.robolectric)
testImplementation(libs.androidx.test.core.ktx)

androidTestImplementation(libs.androidx.test.core.ktx)
androidTestImplementation(libs.androidx.test.ext.junit.ktx)
androidTestImplementation(libs.androidx.test.rules)
Expand Down
Loading