class Linterbot::PullRequestAnalyzer
Attributes
linter_report[RW]
pull_request[RW]
Public Class Methods
new(linter_report, pull_request)
click to toggle source
# File lib/linterbot/pull_request_analyzer.rb, line 8 def initialize(linter_report, pull_request) @pull_request = pull_request @linter_report = linter_report end
Public Instance Methods
analyze(base_path)
click to toggle source
# File lib/linterbot/pull_request_analyzer.rb, line 13 def analyze(base_path) comments = hints_in_pull_request(base_path) .each_pair .reduce([]) do |comments, (filename, hints)| comments + generate_comments(filename, hints) end PullRequestAnalysisResult.new(comments) end
Private Instance Methods
added_and_modified_files()
click to toggle source
# File lib/linterbot/pull_request_analyzer.rb, line 33 def added_and_modified_files pull_request.added_and_modified_files end
analyze_file?(filename)
click to toggle source
# File lib/linterbot/pull_request_analyzer.rb, line 29 def analyze_file?(filename) added_and_modified_files.include?(filename) end
generate_comments(filename, hints)
click to toggle source
# File lib/linterbot/pull_request_analyzer.rb, line 37 def generate_comments(filename, hints) pull_request_file_patch = pull_request.patch_for_file(filename) commits = pull_request.commits_for_file(filename) commits.map do |commit| CommentGenerator.new(filename, commit, pull_request_file_patch, commits.length) .generate_comments(hints) end.flatten end
hints_in_pull_request(base_path)
click to toggle source
# File lib/linterbot/pull_request_analyzer.rb, line 24 def hints_in_pull_request(base_path) linter_report.hints_by_file(base_path) .select { |filename, hints| analyze_file?(filename) } end