From kotlinsense
Common Kotlin diagnostics from the language server and how to fix them. Use when the LSP reports Kotlin errors or warnings, or when diagnosing compilation failures in a Kotlin or Android project.
npx claudepluginhub sudarshanchaudhari/kotlinsense --plugin kotlinsenseThis skill uses the workspace's default tool permissions.
```
Guides Next.js Cache Components and Partial Prerendering (PPR) with cacheComponents enabled. Implements 'use cache', cacheLife(), cacheTag(), revalidateTag(), static/dynamic optimization, and cache debugging.
Migrates code, prompts, and API calls from Claude Sonnet 4.0/4.5 or Opus 4.1 to Opus 4.5, updating model strings on Anthropic, AWS, GCP, Azure platforms.
Automates semantic versioning and release workflow for Claude Code plugins: bumps versions in package.json, marketplace.json, plugin.json; verifies builds; creates git tags, GitHub releases, changelogs.
error: unresolved reference: 'FooClass'
Fixes:
import com.example.FooClassbuild.gradle.kts (implementation(...))./gradlew build if the class is generated (Room, Hilt, etc.)error: type mismatch: inferred type is String but Int was expected
Fixes:
str.toInt(), num.toString(), num.toLong()when for sealed class branches to satisfy exhaustivenesserror: only safe (?.) or non-null asserted (!!.) calls are allowed on a nullable receiver
Fixes (prefer in this order):
// 1. Safe call — returns null if receiver is null
nullableObj?.method()
// 2. Elvis operator — provide a default
nullableObj?.property ?: defaultValue
// 3. Let block — operate only when non-null
nullableObj?.let { obj ->
obj.method()
}
// 4. Non-null assertion — only if you're certain it can't be null
nullableObj!!.method() // crashes with NullPointerException if null
error: val cannot be reassigned
Fix: Change val to var if reassignment is needed. Prefer val (immutable) by default.
error: 'foo' hides member of supertype and needs 'override' modifier
Fix: Add the override keyword:
override fun foo() { ... }
override val bar: String = "value"
error: suspend function 'collect' should be called only from a coroutine or another suspend function
Fix: Call from a coroutine scope:
// In ViewModel
viewModelScope.launch {
repository.flow.collect { value -> ... }
}
// In Fragment/Activity
viewLifecycleOwner.lifecycleScope.launch {
viewModel.uiState.collect { state -> render(state) }
}
error: a 'return' expression required in a function with a block body
Fixes:
// Option 1: add explicit return
fun foo(): String {
return "value"
}
// Option 2: use expression body (preferred for simple functions)
fun foo(): String = "value"
warning: GlobalScope usage is strongly discouraged
Fix: Replace with structured concurrency:
// In ViewModel
viewModelScope.launch { ... }
// In Fragment/Activity
lifecycleScope.launch { ... }
// In a suspend function — use coroutineScope { } for fan-out
coroutineScope {
launch { ... }
launch { ... }
}
error: type mismatch: inferred type is View? but View was expected
Fix: Migrate to View Binding or Jetpack Compose. If using XML temporarily:
val button = findViewById<Button>(R.id.myButton) ?: return
Fix: Hoist state reads into restartable composables, or use remember:
val count by remember { mutableStateOf(0) }