Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Report issues on line numbers that are out of range in the file and throwing errors #1591

Open
myedla1 opened this issue Mar 13, 2024 · 3 comments
Labels
reproducer required Further information is requested type: bug 🐛 Something isn't working

Comments

@myedla1
Copy link

myedla1 commented Mar 13, 2024

THIS IS A BUG TRACKER ONLY. FOR QUESTIONS PLEASE CHECK FAQ OR USE FORUM:

http://www.jacoco.org/jacoco/trunk/doc/faq.html

https://groups.google.com/forum/?fromgroups=#!forum/jacoco

Please understand that
ISSUES WITHOUT FOLLOWING INFORMATION WILL BE CLOSED WITHOUT COMMENTS!
Thank you for filing a useful bug report!

Steps to reproduce

  • JaCoCo version: 0.8.8
  • Operating system: Ubuntu 22.0
  • Tool integration: Maven
  • Complete executable reproducer: GitHub
  • Steps: After analyzing the code with SonarCloud, it reported the following issues. Upon checking with the Sonar community, they indicated that the issue stems from Jacoco report generation.

Could you please assist us with resolving this matter?

Expected behaviour

Issues should not be reported in the lines which doesn't exist.

Actual behaviour

Issues are reported in the lines which doesn't exist.

===========
Sonar is reporting issues on line numbers that are out of range in the file, and it’s generating the following errors.

For example, below mentioned file has 140 lines, but sonar reporting issues at 142 line.
r4e-report/src/main/java/com/reputation/report/utils/ReportUtils.java

[ERROR] Cannot import coverage information for file 'r4e-report/src/main/java/com/reputation/report/utils/ReportUtils.java', coverage data is invalid. Error: {}
java.lang.IllegalStateException: Line 142 is out of range in the file r4e-report/src/main/java/com/reputation/report/utils/ReportUtils.java (lines: 141)
at org.sonar.api.utils.Preconditions.checkState(Preconditions.java:61)
at org.sonar.api.batch.sensor.coverage.internal.DefaultCoverage.validateLine(DefaultCoverage.java:67)
at org.sonar.api.batch.sensor.coverage.internal.DefaultCoverage.lineHits(DefaultCoverage.java:55)
at org.sonar.plugins.jacoco.ReportImporter.importCoverage(ReportImporter.java:45)
at org.sonar.plugins.jacoco.JacocoSensor.importReport(JacocoSensor.java:81

==========

@myedla1 myedla1 added the type: bug 🐛 Something isn't working label Mar 13, 2024
@marchof
Copy link
Member

marchof commented Mar 13, 2024

There can be many reasons. Somehow the class file does not match the source file. To investigate please provide the file ReportUtils.java and the corresponding class files.

@marchof marchof added the feedback pending Further information is requested label Mar 13, 2024
@Godin Godin added reproducer required Further information is requested and removed feedback pending Further information is requested labels Mar 14, 2024
@myedla1
Copy link
Author

myedla1 commented Mar 18, 2024

@marchof This issue occurred in multiple files, not only in ReportUtils.java file.

@marchof
Copy link
Member

marchof commented Mar 18, 2024

Please add at least one example (java source + compiled class file) so that we can investigate the problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
reproducer required Further information is requested type: bug 🐛 Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants