Skip to content

The ktlint gate stops at the compiler/ build boundary: 0 of 3 compiler modules linted, including both published coordinates (52 violations measured) #234

Description

@monkopedia-coder

Code-health suggestion (proactive — staged for your review)

Category: inconsistency

Where: build.gradle.kts:10-11 (subprojects { apply(plugin = "org.jlleitschuh.gradle.ktlint") }) vs compiler/build.gradle.kts (no ktlint at all)

Current:

The repo has one style gate and it is applied at the root build:

subprojects {
    apply(plugin = "org.jlleitschuh.gradle.ktlint")
    ...
}

compiler/ is deliberately a separate Gradle build, not an includeBuild (compiler-check.yml:4-7 explains why), so root tasks never reach it — the same structural fact that #210 found had left the published modules' tests unrun. The lint gate has the same hole and it is still open: compiler/ applies no ktlint, and ./gradlew -p compiler check runs no ktlint task.

$ git grep -ln 'ktlint' -- .
build.gradle.kts
compiler/plugin/src/main/kotlin/com/monkopedia/kplusplus/compiler/fir/KPlusPlusDiagnostics.kt   <- unrelated (a diagnostic name)
docs/campaigns/self-hosting.md
docs/clang-runbook.md
.editorconfig
.github/workflows/root-build.yml
gradle/libs.versions.toml
krapper/src/nativeTest/kotlin/FullKotlinTests.kt
# denominator: 535 tracked files. No hit in any compiler/*/build.gradle.kts.

So the instrument covers 5 of 5 root modules and 0 of 3 compiler modules — including both of the two coordinates this repo actually publishes. (Same question shape as "which coordinates has each instrument been pointed at": apiCheck here is correctly scoped to the two published modules; ktlint reaches neither.)

.editorconfig is repo-root (root = true, max_line_length = 100, ktlint_code_style = android_studio), so the rules are already declared for these files — nothing runs them.

Measured, not assumed. I temporarily applied libs.plugins.ktlint to compiler/'s projects with the catalog's own ktlint-cli version and ran -p compiler ktlintCheck --continue, then restored the file with git checkout --:

$ ./gradlew -p compiler ktlintCheck --no-daemon --continue      # with ktlint temporarily applied
$ for f in $(find compiler -path '*/reports/ktlint/*' -name '*.txt'); do ... done
13  compiler/gradle/build/reports/ktlint/ktlintMainSourceSetCheck/...    <- published
11  compiler/plugin/build/reports/ktlint/ktlintMainSourceSetCheck/...    <- published
11  compiler/native/build/reports/ktlint/ktlintMainSourceSetCheck/...
12  compiler/gradle/build/reports/ktlint/ktlintKotlinScriptCheck/...
 4  compiler/plugin/build/reports/ktlint/ktlintKotlinScriptCheck/...
 1  compiler/native/build/reports/ktlint/ktlintKotlinScriptCheck/...
 0  compiler/gradle/build/reports/ktlint/ktlintTestSourceSetCheck/...
 0  compiler/plugin/build/reports/ktlint/ktlintTestSourceSetCheck/...
# 52 violations across the three modules

(compiler/build.gradle.kts's own script report is excluded from that total — the probe edited that file, so its count is contaminated. Every number above is from a file the probe did not touch.)

All 52 are ordinary formatting, nothing structural — a representative slice:

compiler/gradle/src/main/kotlin/.../KPlusPlusCompilerGradlePlugin.kt:544:52: Unnecessary trailing comma before ")" (standard:trailing-comma-on-call-site)
compiler/gradle/src/main/kotlin/.../KrapperSession.kt:227:1: Unexpected blank line(s) before "}" (standard:no-blank-line-before-rbrace)
compiler/plugin/src/main/kotlin/.../CppVectorIrExtension.kt:3:1: Imports must be ordered in lexicographic order ... (standard:import-ordering)
compiler/plugin/src/main/kotlin/.../CppVectorIrExtension.kt:38:17: Property name should start with a lowercase letter and use camel case (standard:property-naming)
compiler/plugin/src/main/kotlin/.../KPlusPlusCommandLineProcessor.kt:35:1: Add a blank line between all when-conditions ... (standard:blank-line-between-when-conditions)

Note plugin and native report 11 each — the identical count is the synced source duplication showing through (Refs #233).

Proposed: apply the ktlint plugin in compiler/build.gradle.kts the way the root build does — alias(libs.plugins.ktlint) at the included-build root plus a subprojects { apply(...) } block pinning libs.versions.ktlint.cli and android.set(true) — then run ktlintFormat once to clear the 52. compiler/'s Kotlin is hand-written with no generated source sets, so it needs none of the root build's krapped/krapped-cpp/klinker exclusion filtering. ktlintCheck hangs off check, so compiler-check.yml and release.yml's gate pick it up with no workflow edit.

Two riders from this repo's own history: a green/cached ktlintCheck lies, so verify with ktlintFormat plus a clean git status; and if the fix lands, a follow-up PR should confirm the gate is live by breaking it once (e.g. a stray import) rather than by reading the task list.

Why: the repo's declared style is currently enforced on 100% of the code consumers never see and 0% of the code they do. It is also the last remaining instrument that stops at the compiler/ build boundary — #210 closed the test hole and #222 closed the release-gate hole; this is the same boundary a third time.

Effort: mechanical

Filed by the nightly code-health pass. To act on it: relabel agent-workable (it'll flow into triage→work). To decline: close it — it won't be suggested again.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    health-suggestionProactive code-health suggestion from the nightly analysis pass (staged for review)needs-decisionRequires user input on direction, scope, or design

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions