Skip to content

Commit

Permalink
fix: remove jacoco incorrect line bug
Browse files Browse the repository at this point in the history
Jacoco has a bug where he put line coverage to line 65535, which is an error. The code snippet is extracted from https://medium.com/@theilacker/fixing-sonarqube-line-out-of-range-issue-when-using-jetpack-compose-5ba4c1f361f1
  • Loading branch information
Wylwi committed Oct 15, 2024
1 parent feb399e commit 7a2f072
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -240,4 +240,13 @@ tasks.register("jacocoTestReport", JacocoReport::class) {
include("outputs/code_coverage/debugAndroidTest/connected/*/coverage.ec")
})

// This is a fix for a bug in the Jacoco plugin that causes it to generate invalid XML files
// This issue is caused by the Jetpack Compose compiler plugin, which is managed by Google.
// See : https://medium.com/@theilacker/fixing-sonarqube-line-out-of-range-issue-when-using-jetpack-compose-5ba4c1f361f1
// See : https://issuetracker.google.com/issues/231616123
doLast {
val reportFile = reports.xml.outputLocation.asFile.get()
val newContent = reportFile.readText().replace("<line[^>]+nr=\"65535\"[^>]*>".toRegex(), "")
reportFile.writeText(newContent)
}
}

0 comments on commit 7a2f072

Please sign in to comment.