Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'lib/gitlab/ci/reports/accessibility_reports_comparer.rb')
-rw-r--r--lib/gitlab/ci/reports/accessibility_reports_comparer.rb55
1 files changed, 55 insertions, 0 deletions
diff --git a/lib/gitlab/ci/reports/accessibility_reports_comparer.rb b/lib/gitlab/ci/reports/accessibility_reports_comparer.rb
new file mode 100644
index 00000000000..fa6337166d5
--- /dev/null
+++ b/lib/gitlab/ci/reports/accessibility_reports_comparer.rb
@@ -0,0 +1,55 @@
+# frozen_string_literal: true
+
+module Gitlab
+ module Ci
+ module Reports
+ class AccessibilityReportsComparer
+ include Gitlab::Utils::StrongMemoize
+
+ STATUS_SUCCESS = 'success'
+ STATUS_FAILED = 'failed'
+
+ attr_reader :base_reports, :head_reports
+
+ def initialize(base_reports, head_reports)
+ @base_reports = base_reports || AccessibilityReports.new
+ @head_reports = head_reports
+ end
+
+ def status
+ head_reports.errors_count.positive? ? STATUS_FAILED : STATUS_SUCCESS
+ end
+
+ def existing_errors
+ strong_memoize(:existing_errors) do
+ base_reports.all_errors
+ end
+ end
+
+ def new_errors
+ strong_memoize(:new_errors) do
+ head_reports.all_errors - base_reports.all_errors
+ end
+ end
+
+ def resolved_errors
+ strong_memoize(:resolved_errors) do
+ base_reports.all_errors - head_reports.all_errors
+ end
+ end
+
+ def errors_count
+ head_reports.errors_count
+ end
+
+ def resolved_count
+ resolved_errors.size
+ end
+
+ def total_count
+ existing_errors.size + new_errors.size
+ end
+ end
+ end
+ end
+end