Skip to content

Missing file coverage for Kotlin files with package mismatch #913

Open
@IgnatBeresnev

Description

Describe the bug

In Kotlin it is possible to declare a class in a package that does not match file's actual location. For instance,

// File path: src/kover/reproducer/PackageMismatchFile.kt

package kover.reproducer.some.inner.pckg // some.inner.pckg has been added

class PackageMismatchClass {}

It will then result in the following JaCoCo-like XML report:

<package name="org/jetbrains/kover/reproducer/some/inner/pckg">

    <class name="org/jetbrains/kover/reproducer/some/inner/pckg/PackageMismatchClass"
           sourcefilename="PackageMismatchFile.kt">
        ...
    </class>
    <sourcefile name="PackageMismatchFile.kt">
        ...
    </sourcefile>
    ...
</package>

As you can see, the path is taken from the package statement within the file, not file's location.

This leads to codecov ignoring such files altogether. You can observe it in this report - the file should be present in the linked package, but it's not. GitHub link to the package

To Reproduce

See kover-reproducer project and its README.

Expected behavior

Codecov should calculate coverage for files in which package does not match the actual location.

Additional context

The report was generated by Kover: a Gradle plugin that calculates code coverage for Kotlin projects. It is maintained by the Kotlin team at JetBrains and is developed to analyze Kotlin code specifically.

Kover has the ability to generate xml reports that have the same structure as JaCoCo Java reports to enable compatibility with existing tools. At the moment, codecov's coverage for Kover's XML reports is inaccurate, some of the problems are Kover bugs, some are gray areas and some seem to be server-side codecov issues. Umbrella issue for codecov integration issues: Kotlin/kotlinx-kover#16. We're working on making the integration better for our users.

cc @shanshin @qwwdfsad (maintainers of Kover)

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions