| name | spotless-fix |
| description | Use when fixing code formatting errors, ktlint violations, or style issues. Run after generating or modifying Kotlin files. Triggered by phrases like "fix formatting", "spotless", "ktlint error", "formatting violation", "fix code style", "run spotless". |
Spotless Fix
Fix Commands
Fix all modules (run from project root):
./gradlew spotlessApply
Fix a specific module:
./gradlew :<module>:spotlessApply
# Examples:
./gradlew :app:spotlessApply
./gradlew :core:apps:spotlessApply
./gradlew :core:ui-library:spotlessApply
./gradlew :feature:apps:impl:spotlessApply
./gradlew :feature:app-detail:impl:spotlessApply
Check without fixing (see violations only):
./gradlew spotlessCheck
./gradlew :<module>:spotlessCheck
Spotless Configuration Summary
Configured in build-logic/convention/src/main/kotlin/sk/styk/martin/apkanalyzer/SpotlessPlugin.kt:
| Rule | Value |
|---|
| Multiline signatures | Forced when 3+ parameters |
| Compose CompositionLocal allowlist | Disabled |
| Compose lambda-param-in-effect | Disabled |
@Composable function naming | PascalCase allowed (ignored by ktlint) |
| Custom ruleset | io.nlopez.compose.rules:ktlint |
Common Violations and Manual Fixes
1. Multiline function signature (3+ parameters)
fun myFun(param1: String, param2: Int, param3: Boolean) {}
fun myFun(
param1: String,
param2: Int,
param3: Boolean,
) {}
Same rule applies to: constructor parameters, lambda parameters, function call arguments.
2. Wildcard imports
import kotlinx.coroutines.flow.*
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.stateIn
3. Missing trailing comma in multiline lists
fun myFun(
param1: String,
param2: Int
)
fun myFun(
param1: String,
param2: Int,
)
4. Callback naming (present tense, not past tense)
onClicked: () -> Unit
onItemSelected: (String) -> Unit
onBackPressed: () -> Unit
onClick: () -> Unit
onSelectItem: (String) -> Unit
onBack: () -> Unit
5. Modifier parameter position
@Composable
fun MyComponent(modifier: Modifier = Modifier, label: String) {}
@Composable
fun MyComponent(
label: String,
modifier: Modifier = Modifier,
) {}
After Running spotlessApply
If spotlessApply still fails or cannot auto-fix, manually verify:
- No wildcard imports in any file
- All 3+ parameter function signatures are multiline with trailing commas
- All preview functions are
private and suffixed with Preview
- No
data object is missing the data keyword in sealed hierarchies