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

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

40 lines
1.1 KiB
Ruby
Raw Normal View History

2021-03-11 19:13:27 +05:30
# frozen_string_literal: true
module Gitlab
module Ci
module Reports
class CodequalityMrDiff
attr_reader :files
2021-06-08 01:23:25 +05:30
def initialize(new_errors)
@new_errors = new_errors
2021-03-11 19:13:27 +05:30
@files = {}
build_report!
end
private
def build_report!
2021-06-08 01:23:25 +05:30
codequality_files = @new_errors.each_with_object({}) do |degradation, codequality_files|
2021-03-11 19:13:27 +05:30
unless codequality_files[degradation.dig(:location, :path)].present?
codequality_files[degradation.dig(:location, :path)] = []
end
build_mr_diff_payload(codequality_files, degradation)
end
@files = codequality_files
end
def build_mr_diff_payload(codequality_files, degradation)
codequality_files[degradation.dig(:location, :path)] << {
line: degradation.dig(:location, :lines, :begin) || degradation.dig(:location, :positions, :begin, :line),
description: degradation[:description],
severity: degradation[:severity]
}
end
end
end
end
end