Skip to content

Commit

Permalink
Alternate way of solving our uneven problem to work on JRuby
Browse files Browse the repository at this point in the history
Works on all the rubies, or let's see what our CI says :)
ref: jruby/jruby#6048
  • Loading branch information
PragTob committed Jan 31, 2020
1 parent 0de1984 commit 4b1804f
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions lib/simplecov/source_file.rb
Expand Up @@ -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
Expand Down

0 comments on commit 4b1804f

Please sign in to comment.