Repository navigation
Conversation
The SonarScanner for Gradle adds the Kotlin build scripts of the whole build to the sources of the root module. Kotlin scripts are never in a JaCoCo report, so a root module that inherits an XML report path matched nothing and raised a WARN and an analysis warning on every analysis. Kotlin scripts (.kts) no longer count as coverable files, so such a module gets the DEBUG log of modules without coverable files. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Code Review ✅ Approved🟡 Medium risk · Changing JaCoCo file eligibility for .kts modules alters whether unmatched-report warnings appear, potentially masking report/source mismatches in script-only modules. Excludes Kotlin scripts ( Verification Rules 2/2 met PRs 1 inspectedFunctional validation No results Rules 2 passed 1 not applicable
Broader impact PRs 1 inspectedCross-PR 1 PR inspected 0 open impactsAuto-approval Not enabledFor more verification details, comment OptionsAuto-apply is off → Gitar will not commit updates to this branch. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Gitar |
|
|
This PR is stale because it has been open 7 days with no activity. If there is no activity in the next 7 days it will be closed automatically |




JACOCO-241 Don't count Kotlin scripts (
.kts) as files coverable by JaCoCo, to remove a false "could not be matched" warning on the root module of Gradle Kotlin DSL builds.Problem
The SonarScanner for Gradle adds the build scripts of the whole build (
build.gradle.kts,settings.gradle.kts) to the sources of the root module. The Kotlin analyzer indexes them askotlinMAINfiles, soFileLocator.hasFilesCoverableByJacoco()returnedtrue. In most multi-module setups the root module also inheritssonar.coverage.jacoco.xmlReportPaths. A Gradle script never appears in a JaCoCo report, so nothing matched, and every analysis got:None of the N files in coverage report '...' could be matched to the analysed sources of '<root>'. No coverage was imported from this report.SensorUtils.NOTHING_MATCHED_ANALYSIS_WARNING, shown in the UI.Fix
FileLocator.isCoverableByJacoconow ignores files whose name ends with.kts(case-insensitive). The change only affects the coverable count used to choose between the WARN + analysis warning and the DEBUG log (introduced by JACOCO-175). Matching, importing and the indexing of the path tree are unchanged. A module whose only Kotlin files are scripts now gets the DEBUG log of modules without coverable files, and no analysis warning.Tests
FileLocatorTest: a locator with only.ktsKotlinMAINfiles (including an upper-case.KTS) has no coverable files. With a.ktfile next to them, it has some.SensorUtilsTest(realModuleFileLocator): a module with onlybuild.gradle.kts/settings.gradle.ktsthat imports a report matching nothing logs at DEBUG, with no WARN and no analysis warning. A module with a.ktfile still gets the WARN andNOTHING_MATCHED_ANALYSIS_WARNING.JacocoTest.should_not_warn_when_the_only_kotlin_files_are_gradle_scripts: newkotlin-gradle-scripts-projectfixture, analysed with SonarScanner CLI,sonar.sources=build.gradle.kts,settings.gradle.ktsandsonar.coverage.jacoco.xmlReportPaths=jacoco.xml. It checks that the DEBUG log is there, that there's no "could be matched" log, and thatapi/ce/analysis_statusreports no JaCoCo warning.ITs ran locally with
-Dsonar.runtimeVersion=LATEST_RELEASE: all 13 pass. Without the fix, the new IT fails as expected (it logsNone of the 2 files in coverage report ... could be matched)../gradlew buildpasses.🤖 Generated with Claude Code