fix: classify Gradle/KMP test source sets as test zone for Kotlin - #677
Open
tallclouds wants to merge 1 commit into
Open
fix: classify Gradle/KMP test source sets as test zone for Kotlin#677tallclouds wants to merge 1 commit into
tallclouds wants to merge 1 commit into
Conversation
The Kotlin plugin declared no zone_rules, so it fell back to the common rules, which look for a '/test/' or '/tests/' path segment. Kotlin projects are laid out by Gradle source set instead, and Kotlin Multiplatform names every test source set '<target>Test': shared/src/commonTest/kotlin/... sync/src/jvmTest/kotlin/... composeApp/src/androidUnitTest/kotlin/... None contain '/test/', so every test file was zoned production. On a KMP project that put all 241 files in the production zone, with 64 test files reported as orphaned (a test file has no importers by definition) and hardcoded test credentials raised as production security findings. Adds desloppify/languages/kotlin/_zones.py covering KMP and plain Gradle/Android test source sets, marking Gradle build scripts as config, and wires it into the plugin via zone_rules.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The Kotlin plugin passes no
zone_rules, so it falls back toCOMMON_ZONE_RULES, whose test rule is:Kotlin projects aren't laid out that way. Gradle organises by source set, and Kotlin Multiplatform names every test source set
<target>Test:None of these contain a
/test/segment, so every test file is classified as production. On the KMP project I was scanning:Two concrete consequences:
orphaned— "zero importers, not an entry point". A test file has no importers by definition; the test runner is its entry point. This was 28% of the orphaned findings.securityfindings — 6 of the 7 security findings were stub tokens in*Test.kt/ live-validation harnesses.Plain Gradle JVM/Android layouts (
src/test/java) happen to work by accident, since they contain/test/.src/androidTest/andsrc/testFixtures/do not.Fix
Adds
desloppify/languages/kotlin/_zones.pyand wires it in viazone_rules=KOTLIN_ZONE_RULES:/src/test/,/src/androidTest/,/src/testFixtures/, and the KMP source-set suffixesTest/kotlin/,Test/java/,Test/resources/— which covercommonTest,jvmTest,iosTest,androidUnitTest,nativeTest, and any other<target>Test.build.gradle.kts,settings.gradle.kts,gradle.properties,gradle/libs.versions.toml.The suffix form (
Test/kotlin/rather thanTest/) is deliberate: it requires the source-set directory shape, so a production package that merely ends in "Test" isn't swept up.Verification
desloppify/tests/lang/common/test_kotlin_zones.py(18 cases: KMP + Gradle test source sets classify as TEST,*Mainsource sets stay PRODUCTION, build scripts classify as CONFIG).5834 passed, 4 skipped.🤖 Generated with Claude Code
https://claude.ai/code/session_01PCWKUYMUFfgPFW9brzaPVn