debian-mirror-gitlab/lib/gitlab/ci/reports/coverage_report.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

48 lines
897 B
Ruby
Raw Normal View History

2020-04-08 14:13:33 +05:30
# frozen_string_literal: true
module Gitlab
module Ci
module Reports
2022-07-23 23:45:48 +05:30
class CoverageReport
2020-04-08 14:13:33 +05:30
attr_reader :files
def initialize
@files = {}
end
2022-07-23 23:45:48 +05:30
def empty?
@files.empty?
end
2020-04-08 14:13:33 +05:30
def pick(keys)
coverage_files = files.select do |key|
keys.include?(key)
end
{ files: coverage_files }
end
def add_file(name, line_coverage)
if files[name].present?
line_coverage.each { |line, hits| combine_lines(name, line, hits) }
else
files[name] = line_coverage
end
end
private
def combine_lines(name, line, hits)
if files[name][line].present?
files[name][line] += hits
else
files[name][line] = hits
end
end
end
end
end
end