Skip to content

Commit 460a370

Browse files
Merge pull request #667 from pennlabs/add-ktlint-gradle
Add ktlint gradle
2 parents 8b019ee + 1a50a2f commit 460a370

File tree

6 files changed

+41
-13
lines changed

6 files changed

+41
-13
lines changed

.editorconfig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
root = true
2+
3+
[*.{kt,kts}]
4+
ktlint_function_naming_ignore_when_annotated_with = Composable

PennMobile/build.gradle

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ plugins {
33
alias(libs.plugins.kotlin.android)
44
alias(libs.plugins.google.services)
55
alias(libs.plugins.firebase.crashlytics)
6+
alias(libs.plugins.ktlint)
67
// Removed problematic compose compiler alias for Kotlin 1.9.x compatibility
78
id 'jacoco'
89
id 'kotlin-parcelize'
@@ -11,24 +12,24 @@ plugins {
1112
}
1213

1314
android {
14-
namespace 'com.pennapps.labs.pennmobile'
15+
namespace = 'com.pennapps.labs.pennmobile'
1516

1617
buildFeatures {
1718
buildConfig = true
18-
viewBinding true
19-
compose true
19+
viewBinding = true
20+
compose = true
2021
}
2122

2223
buildTypes {
2324
debug {
2425
matchingFallbacks = ['qa', 'release']
25-
enableUnitTestCoverage true
26-
enableAndroidTestCoverage true
26+
enableUnitTestCoverage = true
27+
enableAndroidTestCoverage = true
2728
}
2829
release {}
2930
}
3031

31-
compileSdk 35
32+
compileSdk = 35
3233

3334
composeOptions {
3435
// Matches Kotlin 1.9.24 defined in your libs.versions.toml
@@ -43,7 +44,7 @@ android {
4344
minSdkVersion 26
4445
targetSdkVersion 35
4546
vectorDrawables.useSupportLibrary = true
46-
multiDexEnabled true
47+
multiDexEnabled = true
4748
buildConfigField ("String", "PLATFORM_REDIRECT_URI", getPlatformRedirectUri())
4849
buildConfigField ("String", "PLATFORM_CLIENT_ID", getPlatformClientID())
4950
}
@@ -56,13 +57,29 @@ android {
5657
}
5758
}
5859

60+
ktlint {
61+
version.set("1.8.0")
62+
android.set(true)
63+
ignoreFailures.set(false)
64+
verbose.set(true)
65+
outputToConsole.set(true)
66+
coloredOutput.set(true)
67+
68+
filter {
69+
exclude("**/build/**")
70+
exclude("**/generated/**")
71+
}
72+
}
73+
5974
dependencies {
6075
implementation fileTree(include: ['*.jar'], dir: 'libs')
6176
// If you want the foundation layout, use the bundle or the specific activity compose you have defined
6277
implementation libs.androidx.activity.compose
6378
implementation libs.androidx.material3.android
6479
// implementation libs.androidx.foundation.layout
6580

81+
ktlintRuleset libs.ktlint
82+
6683
androidTestImplementation libs.androidx.espresso.core
6784
androidTestImplementation libs.androidx.junit
6885
androidTestImplementation libs.kaspresso

PennMobile/src/main/java/com/pennapps/labs/pennmobile/di/CampusExpressModule.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import javax.inject.Singleton
1414
@Module
1515
@InstallIn(SingletonComponent::class)
1616
object CampusExpressModule {
17-
1817
@Provides
1918
@Singleton
2019
@Named("CampusExpressRetrofit") // Tag this specific instance
@@ -25,9 +24,10 @@ object CampusExpressModule {
2524
.addConverterFactory(GsonConverterFactory.create())
2625
.build()
2726

27+
// Tell Hilt to use the tagged instance
2828
@Provides
2929
@Singleton
3030
fun provideCampusExpress(
31-
@Named("CampusExpressRetrofit") retrofit: Retrofit // Tell Hilt to use the tagged instance
31+
@Named("CampusExpressRetrofit") retrofit: Retrofit,
3232
): CampusExpress = retrofit.create(CampusExpress::class.java)
33-
}
33+
}

PennMobile/src/main/java/com/pennapps/labs/pennmobile/dining/composables/components/DiningBalancesCard.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ private fun BalanceItem(
106106
text = label,
107107
style = MaterialTheme.typography.labelMedium,
108108
color = MaterialTheme.colorScheme.onSurface,
109-
fontWeight = FontWeight.W900
109+
fontWeight = FontWeight.W900,
110110
)
111111

112112
Text(
@@ -117,7 +117,7 @@ private fun BalanceItem(
117117
// fontSize = 16.sp
118118
),
119119
modifier = Modifier.align(Alignment.CenterHorizontally),
120-
fontWeight = FontWeight.W900
120+
fontWeight = FontWeight.W900,
121121
)
122122

123123
Spacer(modifier = Modifier.height(4.dp))
@@ -136,6 +136,7 @@ private fun BalanceItem(
136136
.align(Alignment.BottomEnd),
137137
)
138138
}
139+
139140
BalanceIconType.SWIPE -> {
140141
Icon(
141142
imageVector = Icons.Filled.CreditCard,
@@ -147,6 +148,7 @@ private fun BalanceItem(
147148
.align(Alignment.BottomEnd),
148149
)
149150
}
151+
150152
BalanceIconType.GUEST -> {
151153
Icon(
152154
imageVector = Icons.Filled.Group,

gradle/libs.versions.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ kotlin = "1.9.24"
3636
kotlinKSP = "1.9.24-1.0.20"
3737
junitVersion = "4.13.2"
3838
kotlinxCoroutinesCore = "1.7.3"
39+
ktlintVersion = "0.5.6"
3940
leakcanaryAndroid = "3.0-alpha-1"
4041
legacySupportV4 = "1.0.0"
4142
library = "1.2.0"
@@ -62,6 +63,8 @@ rxandroidVersion = "1.2.1"
6263
rxjava1 = "1.3.8"
6364
rxJavaCoroutineConverter = "1.8.0"
6465
testng = "7.8.0"
66+
ktlint = "14.0.1"
67+
6568

6669
[libraries]
6770
adapter-rxjava = { module = "com.squareup.retrofit2:adapter-rxjava", version.ref = "adapterRxjava" }
@@ -123,6 +126,7 @@ jsoup = { module = "org.jsoup:jsoup", version.ref = "jsoup" }
123126
junit = { module = "junit:junit", version.ref = "junitVersion" }
124127
kaspresso = { module = "com.kaspersky.android-components:kaspresso", version.ref = "kaspresso" }
125128
kotlinx-coroutines-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "kotlinxCoroutinesCore" }
129+
ktlint = { module = "io.nlopez.compose.rules:ktlint", version.ref = "ktlintVersion" }
126130
leakcanary-android = { module = "com.squareup.leakcanary:leakcanary-android", version.ref = "leakcanaryAndroid" }
127131
library = { module = "com.daimajia.swipelayout:library", version.ref = "library" }
128132
logging-interceptor = { module = "com.squareup.okhttp3:logging-interceptor", version.ref = "loggingInterceptor" }
@@ -148,6 +152,7 @@ ksp = { id = "com.google.devtools.ksp", version.ref = "kotlinKSP"}
148152
hilt = { id = "com.google.dagger.hilt.android", version.ref = "hiltAndroid" }
149153
# Added this to match the accessor in build.gradle
150154
compose-compiler = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }
155+
ktlint = { id = "org.jlleitschuh.gradle.ktlint", version.ref = "ktlint" }
151156

152157

153158
[bundles]

settings.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ dependencyResolutionManagement {
1212
google()
1313
mavenCentral()
1414
maven {
15-
url "https://www.jitpack.io"
15+
url = "https://www.jitpack.io"
1616
}
1717
}
1818
}

0 commit comments

Comments
 (0)