lib/undercover/result.rb in undercover-0.4.7 vs lib/undercover/result.rb in undercover-0.5.0
- old
+ new
@@ -52,11 +52,11 @@
lines[ln] = 0 if branch_cov.zero?
elsif block_or_line_cov.zero?
lines[ln] = 0
end
end
- return 1.0 if lines.keys.size.zero?
+ return 1.0 if lines.keys.empty?
(lines.values.sum.to_f / lines.keys.size).round(4)
end
# rubocop:enable Metrics/AbcSize, Metrics/MethodLength
@@ -82,11 +82,11 @@
# TODO: move to formatter interface instead!
def pretty_print
pad = node.last_line.to_s.length
pretty_print_lines.map do |covered, (num, line)|
formatted_line = "#{num.to_s.rjust(pad)}: #{line}"
- if line.strip.length.zero?
+ if line.strip.empty?
Rainbow(formatted_line).darkgray.dark
elsif covered.nil?
Rainbow(formatted_line).darkgray.dark + \
Rainbow(' hits: n/a').italic.darkgray.dark
elsif covered.positive?
@@ -105,22 +105,22 @@
def file_path_with_lines
"#{file_path}:#{first_line}:#{last_line}"
end
def inspect
- "#<Undercover::Report::Result:#{object_id}" \
- " name: #{node.name}, coverage: #{coverage_f}>"
+ "#<Undercover::Report::Result:#{object_id} " \
+ "name: #{node.name}, coverage: #{coverage_f}>"
end
alias to_s inspect
private
# rubocop:disable Metrics/AbcSize
def count_covered_branches(line_number)
branches = coverage.select { |cov| cov.size == 4 && cov[0] == line_number }
count_covered = branches.count { |cov| cov[3].positive? }
- return '' if branches.size.zero?
+ return '' if branches.empty?
if count_covered < branches.size
Rainbow(' branches: ').italic.darkgray.dark + \
Rainbow("#{count_covered}/#{branches.size}").italic.red
else