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