Skip to content

Commit 646d45e

Browse files
committed
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
1 parent 07bd076 commit 646d45e

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

lib/simplecov/source_file.rb

+8-5
Original file line numberDiff line numberDiff line change
@@ -162,12 +162,15 @@ def no_cov_chunks
162162
end
163163

164164
def build_no_cov_chunks
165-
no_cov_lines = src.map.with_index(1).select { |line, _index| LinesClassifier.no_cov_line?(line) }
165+
no_cov_lines = src.map.with_index(1).select { |line_src, _index| LinesClassifier.no_cov_line?(line_src) }
166166

167-
no_cov_lines.each_slice(2).map do |(_line_start, index_start), (_line_end, index_end)|
168-
# if we have an uneven number of nocovs we assume they go to the
169-
# end of the file
170-
index_end ||= src.size
167+
# if we have an uneven number of nocovs we assume they go to the
168+
# end of the file, the source doesn't really matter
169+
# Can't deal with this within the each_slice due to differing
170+
# behavior in JRuby: jruby/jruby#6048
171+
no_cov_lines << ["", src.size] if no_cov_lines.size.odd?
172+
173+
no_cov_lines.each_slice(2).map do |(_line_src_start, index_start), (_line_src_end, index_end)|
171174
index_start..index_end
172175
end
173176
end

0 commit comments

Comments
 (0)