diff-coverage-gradle icon indicating copy to clipboard operation
diff-coverage-gradle copied to clipboard

There are two reasons for the error in the total instruction number:

Open skyevil12 opened this issue 2 years ago • 2 comments

  • The current method of ignoring instructions based on the number of code changes has issues. The current logic only ignores bytecode in LINENUMBER node blocks, leading to some unforeseen situations in Kotlin. I have submitted a pull request that ignores all Linenumber bytecode within a method that is not part of the code changes. This adjustment yields the desired result in the graph.

Before Screenshot 2024-01-17 110128

After Screenshot 2024-01-17 110307

  • The algorithm for determining the result line numbers of code changes also contributes to miscalculating the total line number. Applying the 'ignore space' differential strategy could prove beneficial in this scenario.

For example:

'git diff' default output is,

--- a/app/src/main/java/org/angmarch/jacococompose/ComposeComponent.kt +++ b/app/src/main/java/org/angmarch/jacococompose/ComposeComponent.kt @@ -16,4 +16,8 @@ fun ComposeComponent(text: String) {
     Surface {
         Text(text = text)
     }
+} <- this would cause wrong instruction being retained in pull request coverage report. 
+
+fun catchMeIfYouCan() {
+    println("I'm a testable function")
 }

A more favorable outcome could be achieved by issuing the command 'git diff -b' to ignore space changes.

--- a/app/src/main/java/org/angmarch/jacococompose/ComposeComponent.kt +++ b/app/src/main/java/org/angmarch/jacococompose/ComposeComponent.kt @@ -17,3 +17,7 @@ fun ComposeComponent(text: String) {
         Text(text = text)
     }
 }
+
+fun catchMeIfYouCan() {
+    println("I'm a testable function")
+}

skyevil12 avatar Jan 17 '24 03:01 skyevil12

Hi @skyevil12

I'm the author of this plugin. I have an independent fork of the plugin that is actively maintained. Could you please create the same PR in my repo?

SurpSG avatar Jan 17 '24 22:01 SurpSG

Sure, just create PR in another repo.

skyevil12 avatar Jan 18 '24 06:01 skyevil12