Skip to content

Commit 97eaf04

Browse files
committed
Add ktlint & reformat kotlin code
Add ktlint gradle plugin to the Android project with Compose-friendly configuration: - Use android_studio code style with 120 char line length - Allow wildcard imports (common in Compose code) - Allow PascalCase function names for @composable functions - Exclude UniFFI-generated code from linting The ktlint plugin auto-formatted all Kotlin files (spaces to tabs per android_studio style). Prompts: - "is there a kotlin equivalent of cargo format" - "how would we install/configure/use each of these" - "go with ktlint" - "add it to lint.sh" - "just run lint.sh" Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> Claude kept making indentation errors. Easier to just run a standard formatter. Apparently there a few, picked this one as claude said it was popular and it seems to work.
1 parent bc7f507 commit 97eaf04

17 files changed

Lines changed: 1969 additions & 1963 deletions

File tree

android/.editorconfig

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[*.{kt,kts}]
2+
ktlint_code_style = android_studio
3+
max_line_length = 120
4+
# Allow wildcard imports (common in Compose)
5+
ktlint_standard_no-wildcard-imports = disabled
6+
# Allow PascalCase for @Composable functions (Compose convention)
7+
ktlint_function_naming_ignore_when_annotated_with = Composable
8+
9+
# Disable ktlint for generated UniFFI bindings
10+
[app/src/main/java/uniffi/**/*.kt]
11+
ktlint_standard = disabled

android/app/build.gradle.kts

Lines changed: 72 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1,85 +1,91 @@
11
plugins {
2-
alias(libs.plugins.android.application)
3-
alias(libs.plugins.kotlin.android)
4-
alias(libs.plugins.kotlin.compose)
2+
alias(libs.plugins.android.application)
3+
alias(libs.plugins.kotlin.android)
4+
alias(libs.plugins.kotlin.compose)
5+
alias(libs.plugins.ktlint)
56
}
67

78
android {
8-
namespace = "co.rustworkshop.markdownneuraxis"
9-
compileSdk = 35
9+
namespace = "co.rustworkshop.markdownneuraxis"
10+
compileSdk = 35
1011

11-
val keystorePath = System.getenv("ANDROID_KEYSTORE_PATH")
12-
val keystorePassword = System.getenv("ANDROID_KEYSTORE_PASSWORD")
13-
val hasSigningConfig = keystorePath != null && keystorePassword != null
12+
val keystorePath = System.getenv("ANDROID_KEYSTORE_PATH")
13+
val keystorePassword = System.getenv("ANDROID_KEYSTORE_PASSWORD")
14+
val hasSigningConfig = keystorePath != null && keystorePassword != null
1415

15-
if (hasSigningConfig) {
16-
signingConfigs {
17-
create("release") {
18-
storeFile = file(keystorePath!!)
19-
storePassword = keystorePassword
20-
keyAlias = "mdnx-gh-apk-signing"
21-
keyPassword = keystorePassword
22-
}
23-
}
24-
}
16+
if (hasSigningConfig) {
17+
signingConfigs {
18+
create("release") {
19+
storeFile = file(keystorePath!!)
20+
storePassword = keystorePassword
21+
keyAlias = "mdnx-gh-apk-signing"
22+
keyPassword = keystorePassword
23+
}
24+
}
25+
}
2526

26-
defaultConfig {
27-
applicationId = "co.rustworkshop.markdownneuraxis"
28-
minSdk = 29
29-
targetSdk = 35
30-
versionCode = 1
31-
versionName = "0.1.0"
27+
defaultConfig {
28+
applicationId = "co.rustworkshop.markdownneuraxis"
29+
minSdk = 29
30+
targetSdk = 35
31+
versionCode = 1
32+
versionName = "0.1.0"
3233

33-
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
34-
}
34+
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
35+
}
3536

36-
buildTypes {
37-
release {
38-
isMinifyEnabled = false
39-
proguardFiles(
40-
getDefaultProguardFile("proguard-android-optimize.txt"),
41-
"proguard-rules.pro"
42-
)
43-
if (hasSigningConfig) {
44-
signingConfig = signingConfigs.getByName("release")
45-
}
46-
}
47-
}
37+
buildTypes {
38+
release {
39+
isMinifyEnabled = false
40+
proguardFiles(
41+
getDefaultProguardFile("proguard-android-optimize.txt"),
42+
"proguard-rules.pro"
43+
)
44+
if (hasSigningConfig) {
45+
signingConfig = signingConfigs.getByName("release")
46+
}
47+
}
48+
}
4849

49-
compileOptions {
50-
sourceCompatibility = JavaVersion.VERSION_11
51-
targetCompatibility = JavaVersion.VERSION_11
52-
}
50+
compileOptions {
51+
sourceCompatibility = JavaVersion.VERSION_11
52+
targetCompatibility = JavaVersion.VERSION_11
53+
}
5354

54-
kotlinOptions {
55-
jvmTarget = "11"
56-
}
55+
kotlinOptions {
56+
jvmTarget = "11"
57+
}
5758

58-
buildFeatures {
59-
compose = true
60-
}
59+
buildFeatures {
60+
compose = true
61+
}
6162

62-
lint {
63-
// Generated UniFFI bindings use APIs not available at minSdk — safe at runtime via JNA
64-
lintConfig = file("lint.xml")
65-
}
63+
lint {
64+
// Generated UniFFI bindings use APIs not available at minSdk — safe at runtime via JNA
65+
lintConfig = file("lint.xml")
66+
}
6667
}
6768

68-
6969
dependencies {
70-
implementation(libs.androidx.core.ktx)
71-
implementation(libs.androidx.lifecycle.runtime.ktx)
72-
implementation(libs.androidx.activity.compose)
73-
implementation(platform(libs.androidx.compose.bom))
74-
implementation(libs.androidx.ui)
75-
implementation(libs.androidx.ui.graphics)
76-
implementation(libs.androidx.ui.tooling.preview)
77-
implementation(libs.androidx.material3)
78-
implementation(libs.androidx.material.icons.extended)
79-
implementation(libs.androidx.documentfile)
70+
implementation(libs.androidx.core.ktx)
71+
implementation(libs.androidx.lifecycle.runtime.ktx)
72+
implementation(libs.androidx.activity.compose)
73+
implementation(platform(libs.androidx.compose.bom))
74+
implementation(libs.androidx.ui)
75+
implementation(libs.androidx.ui.graphics)
76+
implementation(libs.androidx.ui.tooling.preview)
77+
implementation(libs.androidx.material3)
78+
implementation(libs.androidx.material.icons.extended)
79+
implementation(libs.androidx.documentfile)
80+
81+
// JNA for UniFFI runtime
82+
implementation(libs.jna) { artifact { type = "aar" } }
8083

81-
// JNA for UniFFI runtime
82-
implementation(libs.jna) { artifact { type = "aar" } }
84+
debugImplementation(libs.androidx.ui.tooling)
85+
}
8386

84-
debugImplementation(libs.androidx.ui.tooling)
87+
ktlint {
88+
filter {
89+
exclude { it.file.path.contains("/uniffi/") }
90+
}
8591
}

0 commit comments

Comments
 (0)