kotlinx-kover icon indicating copy to clipboard operation
kotlinx-kover copied to clipboard

Add a way to exclude generated classes implementing an annotated interface

Open NinoDLC opened this issue 2 years ago • 4 comments

What is your use-case and why do you need this feature? On Android, Room uses DAO interfaces to generate SQL related code at compile time. Example:

ProjectDao.kt (source code)

package fr.delcey.todok.data.dao

// imports...

@Dao
interface ProjectDao {
    // code
}

ProjectDao_Impl.java (generated)

package fr.delcey.todok.data.dao;

// imports...

@SuppressWarnings({"unchecked", "deprecation"})
public final class ProjectDao_Impl implements ProjectDao {
  // generated code...
}

Describe the solution you'd like I don't really know, maybe add a way to exclude classes that implement an annotated interface (@Dao in this case) ?

Another solution would be to be able to ignore every class in the generated folder but I guess Kover doesn't have this kind of information available. Another solution would be to update Room in order to annotate their generated classes with @Generated, but I don't know if it's common for this kind of lib.

NinoDLC avatar Mar 31 '23 14:03 NinoDLC

Hi, is it acceptable for you to add an exclusion filter like *Dao_Impl?

An exception by inheritance can be added, but this will require a more flexible way of writing filters, which may be added sometime in the future.

shanshin avatar Apr 11 '23 17:04 shanshin

Yes I was mainly basing my excludes with suffixes but it's not 100% resilient (typo, rename, new architecture convention, etc).

This is not a huge issue ATM, and if the DSL to configure is too hard to maintain / configure, this may be a bad idea.

But would a more flexible way to add filters be considered, I hope "filtering by heritance of annotated interface" will make it.

NinoDLC avatar Apr 12 '23 14:04 NinoDLC

Relates #454

shanshin avatar Sep 20 '23 14:09 shanshin