Skip to content

Conversation

@skyevil12
Copy link

  • 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")
+}

- 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.

- The algorithm for determining the result line numbers of code changes also contributes to miscalculating the total line number. I am currently investigating JGit to explore if we can employ an algorithm similar to 'git diff' to select the most suitable method for calculating the code change results. If JGit solution is not found, the alternative would be to instruct the user to run the diff command separately and input the diff result to generate the report.

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")
+}
@SurpSG
Copy link
Contributor

SurpSG commented Jan 17, 2024

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?

@skyevil12
Copy link
Author

Sure, just create PR in another repo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants