Kotlin / kotlinx-kover

Apache License 2.0
1.37k stars 53 forks source link

androidGeneratedClasses() can exclude fragments #626

Closed WildOrangutan closed 5 months ago

WildOrangutan commented 5 months ago

Describe the bug My company has a naming convention, that we add Fragment to all fragment classes. Using androidGeneratedClasses() can exclude fragments, if you're naming fragment classes like LoginFragment.kt, since it uses a filter classes(*Fragment).

I know this is maybe very debatable, but I think that androidGeneratedClasses() should only exclude classes from code coverage, that can be excluded with 100% certainty.

Reproducer

class LoginFragment : Fragment() {
}
kover {
    reports {
        filters {
            androidGeneratedClasses()
        }
    }
}

Environment

shanshin commented 5 months ago

Hi,

should only exclude classes from code coverage, that can be excluded with 100% certainty.

Unfortunately, we cannot be 100% sure that all other classes should be excluded in all projects. Somewhere, user classes can be named with the Activity postfix, nothing will prevent the user from creating a package named databinding.

That is why the documentation for the function indicates which classes it excludes from the report. It covers case for most of the user, but it cannot be applied to absolutely everyone, so for your project it is necessary to specify filters that are suitable only for you.

shanshin commented 5 months ago

If this function will causes misunderstanding among other users, then it would be better to remove it.

I will close the task, because it is even more dangerous to change its behavior.