Kotlin Code Analysis
Deep analysis of Kotlin applications, Android apps, Ktor services, and Kotlin Multiplatform projects
What Axiom Refract Analyzes in Kotlin
Package and Import Resolution
Resolves Kotlin import statements including star imports, type aliases, and extension function imports. Maps dependencies across Kotlin source sets in multiplatform projects.
Coroutine Flow Analysis
Traces coroutine launch sites, structured concurrency hierarchies, and Flow/Channel communication patterns. Identifies architectural patterns in concurrent Kotlin code.
Android Component Mapping
Maps Android Activity/Fragment hierarchies, ViewModel dependencies, Hilt/Dagger injection graphs, and Compose UI component trees. Identifies coupling between Android framework components and business logic.
Extension Function Dependency Tracking
Kotlin extension functions can create hidden dependencies between packages. Axiom maps extension function definitions and their call sites to reveal coupling that is invisible in standard import analysis.
Data Class and Sealed Hierarchy Analysis
Maps data class usage patterns and sealed class/interface hierarchies. Identifies when exhaustive when expressions create coupling between modules that share sealed type definitions.
How It Works
Kotlin is parsed using a hand-hardened Tree-sitter grammar supporting Kotlin 1.7 through 2.0 syntax, including context receivers, value classes, K2 compiler features, and Compose compiler plugin annotations. The parser handles Kotlin/JVM, Kotlin/JS, and Kotlin/Native source sets in multiplatform projects. Gradle Kotlin DSL build files are parsed for dependency and plugin configuration.
Common Findings in Kotlin Codebases
ViewModel Coupling
Android ViewModel classes frequently accumulate business logic, repository dependencies, and UI state management. Axiom identifies ViewModels with high dependency counts that indicate decomposition is needed.
Compose Recomposition Risk
Jetpack Compose composable functions with unstable parameters trigger unnecessary recompositions. Axiom identifies composable functions with high coupling to mutable state objects.
Multiplatform Source Set Leakage
Kotlin Multiplatform projects can develop coupling between platform-specific and common source sets. Axiom detects expect/actual declaration mismatches and platform-specific code in common source sets.
Polyglot Support
Kotlin is one of 145+ languages Axiom Refract supports through Tree-sitter AST parsing. Kotlin analysis covers build.gradle.kts, build.gradle, settings.gradle.kts, Kotlin Multiplatform source set configurations, and Android-specific manifests. Both Gradle and Maven build systems are supported. Your entire codebase is analyzed in a single scan — regardless of how many languages it contains.