fix: address kotlin doc review feedback

This commit is contained in:
Affaan Mustafa
2026-03-12 23:47:17 -07:00
parent 135eb4c98d
commit e692a2886c
3 changed files with 25 additions and 20 deletions

View File

@@ -9,13 +9,16 @@ alwaysApply: false
## Formatting
- **ktfmt** or **ktlint** are mandatory for consistent formatting
- Auto-formatting via **ktfmt** or **ktlint** (configured in `kotlin-hooks.md`)
- Use trailing commas in multiline declarations
## Immutability
- `val` over `var` always
- Immutable collections by default (`List`, `Map`, `Set`)
The global immutability requirement is enforced in the common coding style rule.
For Kotlin specifically:
- Prefer `val` over `var`
- Use immutable collection types (`List`, `Map`, `Set`)
- Use `data class` with `copy()` for immutable updates
## Null Safety

View File

@@ -27,14 +27,16 @@ Use `/kotlin-build` when:
```bash
# Primary build check
./gradlew build
./gradlew build 2>&1
# Static analysis
./gradlew detekt
./gradlew ktlintCheck
./gradlew detekt 2>&1 || echo "detekt not configured"
./gradlew ktlintCheck 2>&1 || echo "ktlint not configured"
# Dependency issues
./gradlew dependencies --configuration runtimeClasspath
./gradlew dependencies --configuration runtimeClasspath 2>/dev/null | head -100
# Optional deep refresh when caches or dependency metadata are suspect
./gradlew build --refresh-dependencies
```

View File

@@ -38,7 +38,7 @@ The following sections contain detailed, runnable examples for each testing patt
- **Coverage** — Kover configuration and commands in [Kover Coverage](#kover-coverage)
- **Ktor testing** — testApplication setup in [Ktor testApplication Testing](#ktor-testapplication-testing)
## TDD Workflow for Kotlin
### TDD Workflow for Kotlin
### The RED-GREEN-REFACTOR Cycle
@@ -105,7 +105,7 @@ fun validateEmail(email: String): Result<String> {
// Step 6: Refactor if needed, verify tests still pass
```
## Kotest Spec Styles
### Kotest Spec Styles
### StringSpec (Simplest)
@@ -222,7 +222,7 @@ class UserValidatorTest : DescribeSpec({
})
```
## Kotest Matchers
### Kotest Matchers
### Core Matchers
@@ -287,7 +287,7 @@ fun beActiveUser() = object : Matcher<User> {
user should beActiveUser()
```
## MockK
### MockK
### Basic Mocking
@@ -380,7 +380,7 @@ test("spy on real object") {
}
```
## Coroutine Testing
### Coroutine Testing
### runTest for Suspend Functions
@@ -485,7 +485,7 @@ class DispatcherTest : FunSpec({
})
```
## Property-Based Testing
### Property-Based Testing
### Kotest Property Testing
@@ -551,7 +551,7 @@ val moneyArb: Arb<Money> = Arb.bind(
}
```
## Data-Driven Testing
### Data-Driven Testing
### withData in Kotest
@@ -583,7 +583,7 @@ class ParserTest : FunSpec({
})
```
## Test Lifecycle and Fixtures
### Test Lifecycle and Fixtures
### BeforeTest / AfterTest
@@ -654,7 +654,7 @@ class UserRepositoryTest : FunSpec({
})
```
## Kover Coverage
### Kover Coverage
### Gradle Configuration
@@ -711,7 +711,7 @@ kover {
| General code | 80%+ |
| Generated / config code | Exclude |
## Ktor testApplication Testing
### Ktor testApplication Testing
```kotlin
class ApiRoutesTest : FunSpec({
@@ -748,7 +748,7 @@ class ApiRoutesTest : FunSpec({
})
```
## Testing Commands
### Testing Commands
```bash
# Run all tests
@@ -776,7 +776,7 @@ class ApiRoutesTest : FunSpec({
./gradlew test --continuous
```
## Best Practices
### Best Practices
**DO:**
- Write tests FIRST (TDD)
@@ -795,7 +795,7 @@ class ApiRoutesTest : FunSpec({
- Test private functions directly
- Ignore flaky tests
## Integration with CI/CD
### Integration with CI/CD
```yaml
# GitHub Actions example