Module: Saddler::Reporter::Github::Helper
- Included in:
- CommitComment, CommitReviewComment, PullRequestComment, PullRequestReviewComment
- Defined in:
- lib/saddler/reporter/github/helper.rb
Instance Method Summary collapse
Instance Method Details
#build_comments_with_patches(data, patches) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/saddler/reporter/github/helper.rb', line 21 def build_comments_with_patches(data, patches) comments = [] files = data['checkstyle']['file'] ||= [] files = [files] if files.is_a?(Hash) files.each do |file| errors = file['error'] ||= [] errors = [file['error']] if errors.is_a?(Hash) file_name = file['@name'] ||= '' patch = patches.find_patch_by_file(file_relative_path_string(file_name)) next unless patch errors.each do |error| line_no = error['@line'] && error['@line'].to_i next unless patch.changed_line_numbers.include?(line_no) severity = error['@severity'] && error['@severity'].upcase = error['@message'] position = patch.find_patch_position_by_line_number(line_no) comments << Comment.new(patch.secure_hash, [severity, ].compact.join(': '), patch.file, position) end end comments end |
#concat_body(data) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/saddler/reporter/github/helper.rb', line 5 def concat_body(data) buffer = [] files = data['checkstyle']['file'] ||= [] files = [files] if files.is_a?(Hash) files.each do |file| errors = file['error'] ||= [] errors = [file['error']] if errors.is_a?(Hash) errors.each do |error| severity = error['@severity'] && error['@severity'].upcase = error['@message'] buffer << [severity, ].compact.join(': ') end end buffer.join("\n") end |