class Pronto::AndroidLintRunner

Public Instance Methods

run() click to toggle source
# File lib/pronto/android_lint_runner.rb, line 6
def run
  paths = ENV["PRONTO_ANDROID_LINT_RESULT_PATHS"]
  return [] unless @patches && paths

  offences = paths.split(",")
    .map{ |path| AndroidLint::OutputParser.new(path).parse }
    .flatten
    .compact

  @patches.select { |p| p.additions > 0 }
    .map { |p| inspect(p, offences) }
    .flatten
    .compact
end

Private Instance Methods

inspect(patch, offences) click to toggle source
# File lib/pronto/android_lint_runner.rb, line 23
def inspect(patch, offences)
  patch_path = patch.delta.new_file[:path]

  messages = []

  offences.select { |offence| offence[:path].end_with?(patch_path) }
    .each do |offence|
      messages += patch.added_lines
        .select { |line| line.new_lineno == offence[:line] }
        .map{ |line| new_message(offence, line) }
  end

  messages.compact
end
new_message(offence, line) click to toggle source
# File lib/pronto/android_lint_runner.rb, line 38
def new_message(offence, line)
  path = line.patch.delta.new_file[:path]

  Message.new(path, line, offence[:level], offence[:message])
end