From 4b1804f75739ea1162d24691934faf70d9bec63c Mon Sep 17 00:00:00 2001 From: Tobias Pfeiffer Date: Thu, 30 Jan 2020 10:56:22 +0100 Subject: [PATCH] Alternate way of solving our uneven problem to work on JRuby Works on all the rubies, or let's see what our CI says :) ref: jruby/jruby#6048 --- lib/simplecov/source_file.rb | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/lib/simplecov/source_file.rb b/lib/simplecov/source_file.rb index f17b01b4..af0922d9 100644 --- a/lib/simplecov/source_file.rb +++ b/lib/simplecov/source_file.rb @@ -162,12 +162,15 @@ def no_cov_chunks end def build_no_cov_chunks - no_cov_lines = src.map.with_index(1).select { |line, _index| LinesClassifier.no_cov_line?(line) } + no_cov_lines = src.map.with_index(1).select { |line_src, _index| LinesClassifier.no_cov_line?(line_src) } - no_cov_lines.each_slice(2).map do |(_line_start, index_start), (_line_end, index_end)| - # if we have an uneven number of nocovs we assume they go to the - # end of the file - index_end ||= src.size + # if we have an uneven number of nocovs we assume they go to the + # end of the file, the source doesn't really matter + # Can't deal with this within the each_slice due to differing + # behavior in JRuby: jruby/jruby#6048 + no_cov_lines << ["", src.size] if no_cov_lines.size.odd? + + no_cov_lines.each_slice(2).map do |(_line_src_start, index_start), (_line_src_end, index_end)| index_start..index_end end end