-
Notifications
You must be signed in to change notification settings - Fork 238
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
Don't generate line 0 in profdata_coverage_file.rb from line with error #387
Don't generate line 0 in profdata_coverage_file.rb from line with error #387
Conversation
…ting wrong report with line number 0
This prevents the test reporter from crashing when an invalid line number is detected in the cobertuna.xml coverage file. While this does not address the actual issue causing invalid line numbers, it does allow the test reporter to ignore the invalid lines. Related: SlatherOrg/slather#387 Addresses: #320
This prevents the test reporter from crashing when an invalid line number is detected in the cobertuna.xml coverage file. While this does not address the actual issue causing invalid line numbers, it does allow the test reporter to ignore the invalid lines. Related: SlatherOrg/slather#387 Addresses: #320
Is there any movement on this PR? |
Have you tried this PR to see if it fixes the problem you're running in to? I haven't tried this myself, but I can merge it if anyone who is running into the problem can confirm it fixes it. |
for me the issue is done. It's already working. |
Hey there, In answer to question posed by @ksuther :
The iOS team I'm on at Pelmorex Corp has been having issues with SONAR throwing an IllegalArgumentException on account of coverage values being generated for line 0. We have tried a version of Slather with this particular pull request (not the updated version from March) applied, and it has addressed the problem. Additional info: Branch with fix here: |
Merged the newer version from #449. Thank you for submitting this! |
I was able to reproduce issue #290 by having error in coverage processed using
profdata_coverage_file.rb
Problem description
When passing Cobertura XML format generated using
slather
tosonar-scanner
, it crashes on error like this:It makes sense since there is no "line 0" in source code (text file).
In my case there was line number 0 generated in Cobertura XML output like this:
I found it is because the source being passed to
ProfdataCoverageFile
contains error in following format:Implementation
This change just filters out these lines from
source_code_lines
and it fixes the issue in my case.It is implemented only in case of
self.line_numbers_first
because this case is easy and fast to detect and handle.Detecting the issue if
self.line_numbers_first == false
would require rather complex regex due to duplication of valid source line in the error listing.Solution
This change prevents the
0
line from appearing in XML coverage report.Tests
Not having good enough knowledge of
slather
andruby
, I didn't find simple / elegant solution to adjust tests for this case (tests are usingline_numbers_first = false
, while my fix is fortrue
case).Sorry about that.
Notes
I will appreciate any suggestion or better solution for this problem.
However I would appreciate some fix for this problem to be released in
slather
so I don't have to use fork or some XML text manipulation in production to workaround this problem.Thanks to everyone for your time to review!