Class: Gitlab::Ci::Reports::CodequalityReportsComparer

Inherits:
ReportsComparer show all
Defined in:
lib/gitlab/ci/reports/codequality_reports_comparer.rb

Constant Summary

Constants inherited from ReportsComparer

ReportsComparer::STATUS_FAILED, ReportsComparer::STATUS_NOT_FOUND, ReportsComparer::STATUS_SUCCESS

Instance Attribute Summary

Attributes inherited from ReportsComparer

#base_report, #head_report

Instance Method Summary collapse

Methods inherited from ReportsComparer

#not_found?, #status

Methods included from Utils::StrongMemoize

#clear_memoization, #strong_memoize, #strong_memoized?

Constructor Details

#initialize(base_report, head_report) ⇒ CodequalityReportsComparer

Returns a new instance of CodequalityReportsComparer.


7
8
9
10
11
12
13
14
15
# File 'lib/gitlab/ci/reports/codequality_reports_comparer.rb', line 7

def initialize(base_report, head_report)
  @base_report = base_report
  @head_report = head_report

  unless not_found?
    @base_report.sort_degradations!
    @head_report.sort_degradations!
  end
end

Instance Method Details

#existing_errorsObject


21
22
23
24
25
26
27
# File 'lib/gitlab/ci/reports/codequality_reports_comparer.rb', line 21

def existing_errors
  strong_memoize(:existing_errors) do
    next [] if not_found?

    base_report.all_degradations & head_report.all_degradations
  end
end

#new_errorsObject


29
30
31
32
33
34
35
36
# File 'lib/gitlab/ci/reports/codequality_reports_comparer.rb', line 29

def new_errors
  strong_memoize(:new_errors) do
    next [] if not_found?

    fingerprints = head_report.degradations.keys - base_report.degradations.keys
    head_report.degradations.fetch_values(*fingerprints)
  end
end

#resolved_countObject


47
48
49
# File 'lib/gitlab/ci/reports/codequality_reports_comparer.rb', line 47

def resolved_count
  resolved_errors.size
end

#resolved_errorsObject


38
39
40
41
42
43
44
45
# File 'lib/gitlab/ci/reports/codequality_reports_comparer.rb', line 38

def resolved_errors
  strong_memoize(:resolved_errors) do
    next [] if not_found?

    fingerprints = base_report.degradations.keys - head_report.degradations.keys
    base_report.degradations.fetch_values(*fingerprints)
  end
end

#success?Boolean

Returns:

  • (Boolean)

17
18
19
# File 'lib/gitlab/ci/reports/codequality_reports_comparer.rb', line 17

def success?
  head_report.degradations_count == 0
end

#total_countObject Also known as: errors_count


51
52
53
# File 'lib/gitlab/ci/reports/codequality_reports_comparer.rb', line 51

def total_count
  head_report.degradations_count
end