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 ## 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 - Use trailing commas in multiline declarations
## Immutability ## Immutability
- `val` over `var` always The global immutability requirement is enforced in the common coding style rule.
- Immutable collections by default (`List`, `Map`, `Set`) For Kotlin specifically:
- Prefer `val` over `var`
- Use immutable collection types (`List`, `Map`, `Set`)
- Use `data class` with `copy()` for immutable updates - Use `data class` with `copy()` for immutable updates
## Null Safety ## Null Safety

View File

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