Open lawfulpepper opened 1 week ago
Unfortunately excluding @Composable functions are not excluded in the Sonar coverage report.
If ignored, the @Composable is not added to the Kover XML report.
Hi, do I understand correctly that the marked function is missing in the xml report, but it is still displayed in Sonar?
Hi shanshin, thanks for your reply!
Yes that's correct. Sonar interprets the absence of any report on a class as "Uncovered".
When I run the xmlReport for the following example:
@Composable
fun MyComposeTest() {
Text("some text")
}
MyComposeTest is not added to the reportDebug.xml file. This is what Sonar reports:
When I add the extra UIData class at the top:
data class UIData(
val someData: String
)
@Composable
fun MyComposeTest() {
Text("some text")
}
This is what the XML file report looks like:
<class name="com/abcd/xyz/tools/ui/UIData" sourcefilename="MyComposeTest.kt">
<method name="<init>" desc="(Ljava/lang/String;)V">
<counter type="INSTRUCTION" missed="7" covered="0"/>
<counter type="BRANCH" missed="0" covered="0"/>
<counter type="LINE" missed="2" covered="0"/>
</method>
When Sonar receives this report, it shows that everything else is ignored except for the UIData
data class.
Surprisingly, Jacoco's Generated
annotation is able to exclude code from Sonar.
Thank you for looking into this.
This is related to Issue https://github.com/Kotlin/kotlinx-kover/issues/576.
Applies to version 0.8.3 and 0.9.0-RC.
I have Kover XML reports setup with Sonar.
Unfortunately excluding
@Composable
functions are not excluded in the Sonar coverage report.If ignored, the
@Composable
is not added to the Kover XML report.However, adding a simple Data Class in the same file causes Sonar to understand that this function should be ignored. Adding the Data Class adds the file to the XML report because of the uncovered Data Class.
In the other issue, you had asked them if the XML report is used with Sonar. For us, yes, we are using the xml report path with Sonar.
Thanks!