Measure with line 0 for file x must be > 0

269 views
Skip to first unread message

appien...@gmail.com

unread,
May 24, 2016, 9:47:26 AM5/24/16
to SonarQube
Hi,

I'm getting the following error when I evaluate my source code.

Caused by: java.lang.IllegalStateException: Measure with line 0 for file '/var/lib/jenkins/workspace/Development - Sonar/app/csr/src/main/groovy/MyEnum.groovy' must be > 0
at org.sonar.batch.sensor.coverage.CoverageExclusions.validatePositiveLine(CoverageExclusions.java:166)
at org.sonar.batch.sensor.coverage.CoverageExclusions.validate(CoverageExclusions.java:128)
at org.sonar.batch.deprecated.DeprecatedSensorContext.saveMeasure(DeprecatedSensorContext.java:204)
at org.sonar.plugins.groovy.cobertura.CoberturaReportParser.handleFileMeasures(CoberturaReportParser.java:126)
at org.sonar.plugins.groovy.cobertura.CoberturaReportParser.collectPackageMeasures(CoberturaReportParser.java:118)
at org.sonar.plugins.groovy.cobertura.CoberturaReportParser.access$200(CoberturaReportParser.java:49)
at org.sonar.plugins.groovy.cobertura.CoberturaReportParser$2.stream(CoberturaReportParser.java:108)
at org.sonar.api.utils.StaxParser.parse(StaxParser.java:113)
at org.sonar.api.utils.StaxParser.parse(StaxParser.java:93)
at org.sonar.api.utils.StaxParser.parse(StaxParser.java:83)
at org.sonar.plugins.groovy.cobertura.CoberturaReportParser.parsePackages(CoberturaReportParser.java:111)
at org.sonar.plugins.groovy.cobertura.CoberturaReportParser.parseReport(CoberturaReportParser.java:68)
at org.sonar.plugins.groovy.cobertura.CoberturaSensor.analyse(CoberturaSensor.java:65)
at org.sonar.batch.phases.SensorsExecutor.executeSensor(SensorsExecutor.java:58)
at org.sonar.batch.phases.SensorsExecutor.execute(SensorsExecutor.java:50)
at org.sonar.batch.phases.PhaseExecutor.execute(PhaseExecutor.java:102)
at org.sonar.batch.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:185

Do you guys have any idea how to fix this?


Michael Gumowski

unread,
May 24, 2016, 10:25:19 AM5/24/16
to appien...@gmail.com, SonarQube
Hello,

Thank you for your feedback. According to this issue on cobertura github repository, the cobertura coverage file may contain lines marked as being as zero. It will indeed make the analysis fail. Line numbers being zeros are not supported by the Groovy plugin. I created the following JIRA ticket to handle the issue and ignore these lines: https://jira.sonarsource.com/browse/SONARGROOV-51

As a temporary solution, removing the lines marked as being zero from the coverage report (<line number="0") will allow the analysis to continue. 

By curiosity, can you provide the versions of your SonarQube instance, as well as the Java and Groovy plugins?

Regards,

Michael GUMOWSKI | SonarSource
Software Developer @ Language Team
http://sonarsource.com

--
You received this message because you are subscribed to the Google Groups "SonarQube" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sonarqube+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sonarqube/1602037a-99bd-4e24-993b-5dcef8cf180a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

appien...@gmail.com

unread,
May 25, 2016, 4:17:43 PM5/25/16
to SonarQube, appien...@gmail.com
Thanks for your explanation. I am using SonarQube 5.4 , Java Plugin 3.13.1 and Groovy plugin 1.3.1.

Also thanks for your workaround, however sonar analysis are in CI setup, so I can not manually remove the 0 lines entries all the time. Any idea when the fix will be ready \? May be I can install some nightly build if its ready? Or maybe you can I try to find the fix by myself and do a pull request?

Op dinsdag 24 mei 2016 16:25:19 UTC+2 schreef Michael Gumowski:

Michael Gumowski

unread,
May 26, 2016, 4:13:29 AM5/26/16
to Albert van Veen, SonarQube
Hello,

There is currently no on-going sprint on the Groovy plugin, and we have nothing planned yet. So I can't provide any insight about a potential fix date.

If you want to try fixing the issue, feel free to provide a Pull Request on the groovy plugin repository (https://github.com/SonarSource/sonar-groovy). Just prefix your commits comment with the associated JIRA ticket (SONARGROOV-51). Don't forget unit tests to validate your changes. Once submitted, I'll review it and eventually merge it with master. It will then be possible to provide a potential nightly build/milestone.

I didn't investigate the issue, but the implementation of fix will probably be to simply ignore lines being zeros in the Cobertura report parser (CoberturaReportParser.java#L198)

I would however be interested to know why those lines are appearing in the report in the first place...

Cheers,

Michael GUMOWSKI | SonarSource
Software Developer @ Language Team
http://sonarsource.com

Reply all
Reply to author
Forward
0 new messages