You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Erroneous red flagging of blank lines when merging covered file results with uncovered file results #444
SimpleCov 0.11.1: This error occurs when using rspec and cucumber in two different runs and expecting them to be properly merged and an accurate map displayed. I'm confident it occurs in similar situations as well.
To reproduce:
Run rspec tests using SimpleCov such that it will flag some of the lines in a ruby file as having been executed.
Run cucumber using SimpleCov such that that same ruby file is covered, but no lines in it are actually executed.
Note that in .resultset.json the rspec section for this ruby file consists of nil, 0 and 1 values, while the cucumber section for this file consists of all 0's.
Note that the resultant report, showing the merged results, highlights all non-executed lines of code in red, including blank and comment lines. Obviously the file and project test coverage stats are also wrong.
I believe this is because of faulty logic in line 7 of lib/simplecov/merge_helpers.rb. It reads
if element.nil? && new_array[i].nil?
when it should read
if element.nil? || new_array[i].nil?
The original logic (see context) allows a 0 to wipe out the nil which serves as a comment indicator, erroneously replacing it with a 0, resulting in erroneous red highlighting of comments and blank lines.
You can create a logic table to see why the original code is faulty and this fix corrects it.
When I make this change the error goes away.
If I get time I'll make this correction and submit a PR. But I wanted others to know about this in case they need a quick fix before I can get to it.
You can just edit the code in place for a quick fix. You can do a "gem which simplecov" on your console to find the code location.
Activity
danishsatkut commentedon Jan 12, 2016
This is definitely an issue and the provided solution works. Thanks 💯
chriskottom commentedon Feb 17, 2016
+1 for this fix. It seems to have worked in my env - Ruby 2.2.3, SimpleCov 0.11.2.
Ensure blank lines aren't reported as uncovered, related issue simple…
rdunlop commentedon Mar 11, 2016
I suspect that this is fixed by #441
fighterii commentedon Mar 24, 2016
I can confirm that the fix suggested did it for me
Code coverage with merging results from all tests into one report
Point simplecov to master
PragTob commentedon Jan 29, 2017
Seems this was fixed by #441 - thanks! :)