square/kotlinpoet
60.7
Adequate · 25 September 2026
7.6k
lines of production code
Kotlin
primary language
4
measurements over time
What this system is
KotlinPoet is a Kotlin API for generating Kotlin source code, providing a programmatic way to construct and emit structured code files. The system has evolved to support Kotlin Multiplatform targets, including JVM, JS, and Wasm, while introducing dedicated interop modules for seamless integration with KSP and Kotlin metadata inspection. These capabilities allow developers to generate code directly from compiler symbols or existing class metadata, with built-in support for incremental compilation tracking and JVM-specific annotation helpers.
How it got here
2013–2021 — KSP interop and multiplatform support
6 changes.
The project established its foundational structure and documentation while progressively upgrading its build infrastructure to support modern Kotlin versions. A significant addition was the introduction of a KSP interop module, enabling seamless conversion between KSP symbols and KotlinPoet types for code generation. This period also included comprehensive testing infrastructure to validate the new interop capabilities across complex Kotlin constructs.
2022–2023 — KSP interop and KMP migration
5 changes.
This period focused on stabilizing Kotlin Symbol Processing (KSP) interop APIs and enabling incremental compilation support through originating file tracking. Concurrently, core KotlinPoet components were migrated to Kotlin Multiplatform, expanding the public API to support new language features like context parameters and improving cross-platform compatibility.
2024 — Kotlin metadata interop and multi-platform support
7 changes.
This period focused on introducing a new Kotlin metadata interop module that enables reading class metadata from bytecode and generating corresponding code structures. Concurrently, the project expanded its multi-platform capabilities by adding Kotlin/JS and Kotlin/Wasm JS implementations for core utility functions and reorganizing the JVM source layout.
Features
Add Kotlin/JS and Kotlin/Wasm JS platform implementations for code point and utility functions
This change introduces platform-specific implementations for \CodePoint\ and \Util\ in the \kotlinpoet\ library, enabling support for Kotlin/JS and Kotlin/Wasm JS targets. The diff adds new source files in \jsMain\, \nonJvmMain\, and \wasmJsMain\ that provide \actual\ implementations for functions such as \codePointAt\, \isLowerCase\, \isUpperCase\, \isIdentifier\, and immutable collection conversions. These implementations bridge JVM-specific character handling and utility methods to non-JVM environments using JavaScript interop (e.g., \String.codePointAt\, \RegExp\) and standard Kotlin collections, ensuring consistent behavior across supported platforms.
kotlinpoet/src/jsMain, kotlinpoet/src/nonJvmMain, kotlinpoet/src/wasmJsMain · high confidence
Initial KSP interop support for KotlinPoet
This release introduces the \interop/ksp\ module, providing extension functions to convert KSP symbols (such as \KSAnnotation\, \KSType\, \KSClassDeclaration\, and \Modifier\) into KotlinPoet types (\AnnotationSpec\, \TypeName\, \ClassName\, and \KModifier\). This enables users to generate Kotlin code using KotlinPoet directly from KSP analysis results, including support for type aliases, generic type parameters, and annotation arguments.
interop/ksp · high confidence
Initial project scaffolding and documentation site setup
The repository is initialized with essential configuration and documentation files. This includes an .editorconfig for consistent code formatting (2-space indentation, UTF-8, trailing whitespace trimming), .gitattributes for line-ending normalization, and a .gitignore for build artifacts and IDE files. A standard Apache 2.0 LICENSE.txt is added, along with a README.md introducing KotlinPoet and a RELEASING.md guide for version management. The project also sets up a MkDocs-based documentation website (mkdocs.yml) featuring a Material theme with dark mode support, navigation for API docs and interop modules, and includes Gradle wrapper scripts (gradlew, gradlew.bat) to ensure consistent build execution.
(repo-wide) · high confidence
KotlinPoet API surface expanded with new interfaces and methods
The public API for code generation has been extended to support more granular control and new language features. Users can now add comments directly to code blocks via the new \addComment\ method on \CodeBlock.Builder\ and the \CodeBlockHolder\ interface. Support for Kotlin's context parameters and context receivers has been introduced through new \ContextParameter\, \ContextParameterizable\, and \ContextReceivable\ types, allowing builders to define and manage these constructs. Additionally, the API exposes new builder interfaces for annotatable and documentable constructs, facilitating better extensibility for custom code generation logic.
kotlinpoet/api · high confidence
New JVM-specific annotation helpers for KotlinPoet
Added a new \JvmAnnotations.kt\ file in the JVM source set that provides extension functions for \FileSpec\, \TypeSpec\, \FunSpec\, \PropertySpec\, and \TypeName\ builders. These helpers allow users to easily add JVM-specific annotations such as \@JvmName\, \@JvmStatic\, \@JvmOverloads\, \@JvmSuppressWildcards\, \@JvmInline\, \@JvmRecord\, \@Throws\, \@Synchronized\, \@Strictfp\, \@JvmField\, \@Transient\, and \@Volatile\ to generated code. The file also includes deprecated stubs for \jvmDefault\ to maintain API compatibility while the underlying compiler flag support is updated.
kotlinpoet/src/jvmMain/kotlin/com/squareup/kotlinpoet/jvm · high confidence
New Kotlin metadata interop module for reading Kotlin class metadata
A new \kotlin-metadata\ interop module has been added to KotlinPoet, enabling the reading of Kotlin class metadata from compiled bytecode. This module introduces a \ClassInspector\ interface with two implementations: \ElementsClassInspector\ for use with the Java Compiler API and \ReflectiveClassInspector\ for runtime reflection. It provides utilities to convert Kotlin metadata (KmClass, KmType, etc.) into KotlinPoet's \TypeSpec\ and \FileSpec\ representations, allowing users to generate code that mirrors the structure of existing Kotlin classes based on their metadata annotations.
interop/kotlin-metadata/src/main · high confidence
New class-inspector data models for Kotlin metadata
The kotlin-metadata interop module introduces a new set of data classes and utilities to represent parsed Kotlin metadata for the ClassInspector. This includes ContainerData, ClassData, FileData, EnumEntryData, ConstructorData, MethodData, PropertyData, and FieldData, which collectively model classes, file facades, constructors, methods, properties, and fields along with their annotations and modifiers. Supporting utilities in ClassInspectorUtil handle annotation filtering, literal code generation, and JVM field inference, while a lightweight Optional wrapper supports non-null collections. These changes provide a structured, spec-based representation of Kotlin metadata that the ClassInspector can consume.
kotlin-metadata · high confidence
Support for KSP incremental processing via originating file tracking
Added new KotlinPoet APIs to support KSP incremental compilation. The \OriginatingKSFiles\ interface and associated extension functions (\originatingKSFiles\, \addOriginatingKSFile\) allow users to tag generated code with the source files that produced it. Additionally, \FileSpec.writeTo\ now accepts a \CodeGenerator\ and optional originating files to correctly register dependencies, ensuring that KSP can properly invalidate caches when source inputs change.
ksp · high confidence
API
Stable KSP interop APIs and Kotlin Metadata ABI definitions
The KSP interop module now exposes stable public APIs for converting Kotlin Symbol Processing (KSP) types to KotlinPoet types, including functions to transform annotations, class declarations, types, type parameters, modifiers, and visibility. It also provides utilities to manage originating KSP files on builders and write generated code directly to the KSP code generator. Additionally, the kotlin-metadata module publishes its public API surface, defining the contract for class inspectors and data models used to inspect Kotlin metadata.
interop · high confidence
Behavioural changes
KotlinPoet JVM source files restructured into new package layout
The JVM-specific implementation files for KotlinPoet (including core types like CodeBlock, ClassName, FunSpec, and FileSpec, along with supporting interfaces and utilities) have been moved into the com.squareup.kotlinpoet package under the jvmMain source set. This change reorganizes the existing JVM codebase into a new directory structure without altering the public API or behavior of the library.
kotlinpoet/src/jvmMain/kotlin/com/squareup/kotlinpoet · high confidence
Migrate core KotlinPoet components to Kotlin Multiplatform
KotlinPoet has migrated several core internal and public components from JVM-only to common code, enabling usage across Kotlin Multiplatform targets. This change introduces common implementations for \LineWrapper\ (including support for the new \♢\ modifier for wrapping spaces), \NameAllocator\ (with added \contains\ API for checking allocated tags), \KModifier\, \KOperator\, \Import\, and utility classes like \CodePoint\ and \Util\. Additionally, delicate and experimental API markers (\DelicateKotlinPoetApi\, \ExperimentalKotlinPoetApi\) are now available in common, and string literal generation now correctly preserves carriage returns and raw-string newlines.
kotlinpoet/src/commonMain · high confidence
Test coverage
Added JVM test coverage for Java annotation arrays and type names; Added KSP interop test coverage for type resolution and annotation processing; Added KSP test processor infrastructure; Added test coverage for Kotlin metadata specs and class inspectors; Migrate test suite to AssertK.
Dependencies
Upgrade Gradle wrapper to version 9.8.0
The project's Gradle wrapper has been updated to use Gradle 9.8.0 (bin distribution). This change ensures that builds are executed with the specified version and includes configuration for SHA-256 checksum validation and network timeout settings to improve build reliability and security.
gradle · high confidence
Upgrade to Kotlin 2.4 and KSP 2.3 with multiplatform support
The build system has been upgraded to Kotlin 2.4.20 and KSP 2.3.12, enabling the main KotlinPoet library to target JVM, JS, and WasmJs platforms. This change also updates the KSP interop module to use KSP 2.3.12 and adopts Gradle version catalogs for dependency management, while configuring the project to publish to the Sonatype Central Portal.
(dependencies) · high confidence
Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.
How this codebase got here
This is the PUBLIC form of this artifact. Findings are listed in full, but the details of SECURITY findings — which rule fired, in which file, on which line, and how to fix it — are deliberately withheld, and any secret-scanner results are excluded entirely. Where detail is absent here it was REMOVED FOR PUBLICATION; it is not missing from the analysis. The complete artifact is available from the repository owner.
Score
- CAI 42 → 61 (+18.8)
- Rubric changed (rubric-2026.08.15 → rubric-2026.09.15) — scores are not directly comparable.
Lenses
- Code Health 95 → 90 (-5.5)
- Architecture 94 → 100 (+5.9)
- Maturity 45 → 51 (+5.5)
- Readiness 25 → 56 (+31.1)
- Security 49 → 75 (+26.7)
Resolved (35)
- Coverage not measured — test suite did not build
- Dimension evaluation failed
- Duplicated block (15 lines × 2) (kotlinpoet/src/jvmMain/kotlin/com/squareup/kotlinpoet/TypeSpec.kt)
- High CVE: [GHSA redacted] (kotlin-js-store/yarn.lock)
- High CVE: [GHSA redacted] (kotlin-js-store/yarn.lock)
- High CVE: [GHSA redacted] (kotlin-js-store/yarn.lock)
- High CVE: [GHSA redacted] (kotlin-js-store/yarn.lock)
- High CVE: [GHSA redacted] (kotlin-js-store/yarn.lock)
- High CVE: [GHSA redacted] (kotlin-js-store/yarn.lock)
- High CVE: [GHSA redacted] (kotlin-js-store/yarn.lock)
- High CVE: [GHSA redacted] (kotlin-js-store/yarn.lock)
- High CVE: [GHSA redacted] (kotlin-js-store/yarn.lock)
- High CVE: [GHSA redacted] (kotlin-js-store/yarn.lock)
- High: security finding (details withheld)
- High: security finding (details withheld)
- High: security finding (details withheld)
- High: security finding (details withheld)
- High: security finding (details withheld)
- High: security finding (details withheld)
- High: security finding (details withheld)
- …and 15 more
New (70)
- Builder.add (cognitive 28) (kotlinpoet/src/jvmMain/kotlin/com/squareup/kotlinpoet/CodeBlock.kt)
- Builder.add (cyclomatic 16) (kotlinpoet/src/jvmMain/kotlin/com/squareup/kotlinpoet/CodeBlock.kt)
- ClassTooLong: CodeWriter (kotlinpoet/src/jvmMain/kotlin/com/squareup/kotlinpoet/CodeWriter.kt)
- CodeBlock.trim (cognitive 73) (kotlinpoet/src/jvmMain/kotlin/com/squareup/kotlinpoet/CodeBlock.kt)
- CodeBlock.trim (cyclomatic 49) (kotlinpoet/src/jvmMain/kotlin/com/squareup/kotlinpoet/CodeBlock.kt)
- CodeWriter.emit (cognitive 38) (kotlinpoet/src/jvmMain/kotlin/com/squareup/kotlinpoet/CodeWriter.kt)
- CodeWriter.emit (cyclomatic 19) (kotlinpoet/src/jvmMain/kotlin/com/squareup/kotlinpoet/CodeWriter.kt)
- CodeWriter.emitCode (cognitive 56) (kotlinpoet/src/jvmMain/kotlin/com/squareup/kotlinpoet/CodeWriter.kt)
- CodeWriter.emitCode (cyclomatic 30) (kotlinpoet/src/jvmMain/kotlin/com/squareup/kotlinpoet/CodeWriter.kt)
- Dependency hygiene PARTLY measured — Maven/Gradle declarations read, no dependency graph resolved
- Documentation: no installation or build instructions (README.md)
- Documentation: no installation or build instructions (docs/index.md)
- Documentation: no licence statement (docs/contributing.md)
- Documentation: no project overview (README.md)
- Duplicated block (16 lines × 2) (interop/kotlin-metadata/src/main/kotlin/com/squareup/kotlinpoet/metadata/classinspectors/ElementsClassInspector.kt)
- Duplicated block (5 lines × 2) (interop/kotlin-metadata/src/main/kotlin/com/squareup/kotlinpoet/metadata/classinspectors/ElementsClassInspector.kt)
- ElementsClassInspector.containerData (cognitive 30) (interop/kotlin-metadata/src/main/kotlin/com/squareup/kotlinpoet/metadata/classinspectors/ElementsClassInspector.kt)
- ElementsClassInspector.containerData (cyclomatic 24) (interop/kotlin-metadata/src/main/kotlin/com/squareup/kotlinpoet/metadata/classinspectors/ElementsClassInspector.kt)
- FileTooLong: kotlinpoet/CodeWriter.kt (kotlinpoet/src/jvmMain/kotlin/com/squareup/kotlinpoet/CodeWriter.kt)
- High CVE: [GHSA redacted] (kotlin-js-store/yarn.lock)
- …and 50 more
Changes since last survey
- 33 commits — 33 feature/other, 0 fixes
By area
- .github/workflows — 11 commits
- gradle/libs.versions.toml — 8 commits
- kotlinpoet/src — 5 commits
- (root) — 3 commits
- gradle/wrapper — 3 commits
- interop/ksp — 2 commits
- docs/contributing.md — 1 commit
Notable commits
- change: Add a warning about missing PR checklist to contributing.md
- change: Don't leak an expression body's indent into later declarations (#2365)
- change: Don't special-case varargs in KSAnnotation.toAnnotationSpec (#2360)
- change: Don't throw when toTypeName() hits type parameters with EMPTY resolver (#2368)
- change: Emit brackets instead of arrayOf for annotation args (#2361)
- change: Emit context parameters after annotations in FunSpec and PropertySpec (#2374)
- change: Keep carriage returns and raw-string newlines in emitted string literals
- change: Keep the package slot for default-package classes in Class.asClassName() (#2382)
- change: Prepare for release 2.4.0.
- change: Prepare next development version.
- change: Update Gradle to v9.7.0 (#2357)
- change: Update Gradle to v9.7.1 (#2367)
- change: Update Gradle to v9.8.0
- change: Update actions/setup-java action to v6 (#2370)
- change: Update dependency Pygments to v2.21.0 (#2364)
- change: Update dependency click to v8.5.0 (#2371)
- change: Update dependency com.google.jimfs:jimfs to v1.3.2
- change: Update dependency java to v27
- change: Update dependency pymdown-extensions to v11.0.2 (#2369)
- change: Update dependency pymdown-extensions to v12 (#2385)
- …and 13 more
Architecture
- Containers 0 added · 0 removed · contexts 3 added · 0 removed · edges 2 added · 0 removed
Added bounded contexts (3)
- kotlin-metadata
- kotlinpoet
- ksp
Added dependency edges (2)
- kotlin-metadata → kotlinpoet
- ksp → kotlinpoet
Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.
Survey your own repository
square/kotlinpoet was measured the same way every project in this corpus was: the same rubric, at a pinned commit, with the result published in full. Point a surveyor at a repository you know and see whether you agree with it.
About this page
- The score is its most recent published measurement, taken on 25 September 2026 at a pinned commit. It is not a live figure and does not change until the project is measured again.
- Measured at commit 57073846d05b9d7cd4be0c918c3175e7aa4e347c — the exact code this score is about.
- Scored under rubric-2026.09.15 — the same rubric and the same method as every other entry in this index.
- Measured by watchdog.canine.dev using codehealth-analyzer preprod-9630dbd8b4f7.