Codecov ignores files at Kotlin source root

In Kotlin projects, Codecov ignores all files directly under src/main/kotlin. It includes files in any subdirectory, such as src/main/kotlin/mydir/MyClass.kt, but ignores it if it’s src/main/kotlin/MyClass.kt.

Although Java projects include the full package name in the directory structure, the official Kotlin docs recommend not doing this.

In pure Kotlin projects, the recommended directory structure follows the package structure with the common root package omitted. For example, if all the code in the project is in the org.example.kotlin package and its subpackages, files with the org.example.kotlin package should be placed directly under the source root, and files in should be in the network/socket subdirectory of the source root.


Codecov should include files at the source root to comply with the official conventions.

Has anyone run into this and figured out a workaround?


Hi @JamesOwenHall

We include all files, the issue here is that the file path in the coverage report does not match the file path.

In this case, a path fix is needed to “move” the files in the report to their actual locations in the repo.

This has been confirmed working with at least one Kotlin repo, since it was private I can’t share an exact fix, but if you have trouble crafting it we will be happy to review what you have.

Hey @drazisil, thanks for the quick reply.
I’ve tried using the fixes clause as described in the docs but to no avail. I’ll share what I’ve tried.

Our project is structured like this.

├── Config.kt
├── avro
│   └── AvroDeserializer.kt
// …

The reason I think this is actually a bug with Codecov is that all files under the avro subdirectory, as well as any other subdirectory, show up in the Codecov UI. This suggests that Codecov has no issues finding these files without using the fixes clause.
Only the top-level Config.kt file is being ignored by Codecov.

In any case, I did try using the fixes clause in the codecov.yml.


  - mysubproject/src/main/kotlin::src/main/kotlin/com/mycompany/mysubproject

With this in my codecov.yml, the Codecov UI is updated to display all files other than Config.kt in src/main/kotlin/com/mycompany/mysubproject. Still the top-level Config.kt is ignored.

Do you think this is still a matter of mismatched paths? If so, why might all sub packages work?


Try flipping the order in the fixes line.

(Makes the docs clearer is on my backlog)

Can this be fixed automatically by codecov?

If I have a multimodule project with 100 projects, I have to fix all of them, and if I add a new one, I have to remember to fix it too. Or I have to create an algorithm to generate this YAML file.

I can understand in strange situations we should manually fix things, but an official code convention should be covered automatically, IHMO.

And I have a Kotlin Multiplatform project, so I can have thousands of lines easily if I have a lot of sourceSets per project:

  - module-one/src/commonMain/kotlin/com/javiersc/moduleOne::module-one/src/commonMain/kotlin
  - module-one/src/jvmMain/kotlin/com/javiersc/moduleOne::module-one/src/jvmMain/kotlin
  - ...
  - module-two/src/commonMain/kotlin/com/javiersc/moduleTwo::module-two/src/commonMain/kotlin
  - module-two/src/jvmMain/kotlin/com/javiersc/moduleTwo::module-two/src/jvmMain/kotlin
  - ...

I am trying to fix this problem manually, but even adding the codecov.yml file I can’t get it working.

This generic error doesn’t help a lot. How can I know what I am doing wrong?

@JavierSegoviaCordoba, can you please open a new ticket for this?