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

47 lines
957 B
Ruby
Raw Normal View History

2020-05-24 23:13:21 +05:30
# frozen_string_literal: true
module Gitlab
module Ci
module Reports
class AccessibilityReports
attr_reader :urls, :error_message
def initialize
@urls = {}
@error_message = nil
end
def add_url(url, data)
if url.empty?
set_error_message("Empty URL detected in gl-accessibility.json")
else
urls[url] = data
end
end
def scans_count
@urls.size
end
def passes_count
@urls.count { |url, errors| errors.empty? }
end
# rubocop: disable CodeReuse/ActiveRecord
def errors_count
@urls.sum { |url, errors| errors.size }
end
# rubocop: enable CodeReuse/ActiveRecord
def set_error_message(error)
@error_message = error
end
def all_errors
@urls.values.flatten
end
end
end
end
end