Status Update
Comments
vi...@shiftkey.com <vi...@shiftkey.com> #2
Triage notes: Still P3, still a real issue. Compat issue.
ga...@gmail.com <ga...@gmail.com> #3
do...@gmail.com <do...@gmail.com> #4
ch...@google.com <ch...@google.com>
ka...@fmr.com <ka...@fmr.com> #5
sa...@box.com <sa...@box.com> #6
ga...@gmail.com <ga...@gmail.com> #7
br...@gmail.com <br...@gmail.com> #8
ra...@gmail.com <ra...@gmail.com> #9
he...@gmail.com <he...@gmail.com> #10
st...@gmail.com <st...@gmail.com> #11
st...@gmail.com <st...@gmail.com> #12
This workaround did help on my latest project:
First I included the Jacoco Version from this PR:
Second I updated our Jacoco Gradle Task with the following lines:
doLast {
def reportFile = file(rootProject.projectDir.absolutePath + '/build/reports/jacoco/rootCodeCoverageReport/rootCodeCoverageReport.xml')
def reportText = reportFile.text
def newReportText = reportText.replaceAll(/<line[^>]+nr="65535"[^>]*>/, '')
reportFile.text = newReportText
project.logger.lifecycle("Wrote summarized jacoco test coverage report xml to $reportFile.absolutePath")
}
This alters the report file: The RegEx removes the whole invalid line element.
te...@gmail.com <te...@gmail.com> #13
Above fix works for me as well, thanks
th...@gmail.com <th...@gmail.com> #14
Thanks for sharing this workaround!
To improve the suggested code from Project
object in doLast
will
doLast {
val reportFile = reports.xml.outputLocation.asFile.get()
val newContent = reportFile.readText().replace("<line[^>]+nr=\"65535\"[^>]*>".toRegex(), "")
reportFile.writeText(newContent)
logger.quiet("Wrote summarized jacoco test coverage report xml to $reportFile.absolutePath}")
}
st...@gmail.com <st...@gmail.com> #15
Nice! Thx for the update!
al...@google.com <al...@google.com> #16
Note from triage, it seems like Compose is generating an invalid line number. Keeping this open for investigation.
al...@google.com <al...@google.com> #17
Triage notes: Needs investigation, moving to Inbox.
Description
Jetpack Compose component used: Card, Column etc
Android Studio Build: Bumblebee | 2021.1.1 Patch 2 | Build #AI-211.7628.21.2111.8193401, built on February 17, 2022
Kotlin version: 1.6.10
Steps to Reproduce or Code Sample to Reproduce:
1. Attaching reproducer project which has jacoco code coverage tasks configured to run on "app" module.
2. Run "gradle debugTestCoverage" to generate coverage reports in the "app" module directory.
3. Examine the generated XML file to see line numbers with "65535", which fail when consumed by the SonarCloud scanner process.
There are 3 classes in the code sample, all of them using compose. The generated bytecode seems to contain lines which we do not expect to see. I had opened an issue with the Jacoco team with the sample project and reports and they are thinking that this is an issue is with the compose or the kotlin compiler:
This issue happens in a bunch of our classes which has compose code in them. So this might be something directly related to the compose compiler, not very sure about it though. We have a lot more classes in our actual project and they do not have this issue.
Since these classes have the invalid lines in the coverage report, the sonarcloud scanner process fails to read coverage data for these classes.
Please find the sample project and the coverage data reports attached. Would like to know if there is anything we can do to fix this issue.
Thanks for taking a look.