class Pronto::DialyxirRunner

Public Class Methods

new(_, _) click to toggle source
Calls superclass method
# File lib/pronto/dialyxir.rb, line 8
def initialize(_, _)
  super
end

Public Instance Methods

run() click to toggle source
# File lib/pronto/dialyxir.rb, line 12
def run
  return [] unless @patches

  wrapper = Dialyxir::Wrapper.new

  @patches.select { |p| p.additions > 0 }
      .select { |p| elixir_file?(p.new_file_full_path) }
      .map { |p| inspect(p, wrapper) }
      .flatten
      .compact
end

Private Instance Methods

elixir_file?(path) click to toggle source
# File lib/pronto/dialyxir.rb, line 46
def elixir_file?(path)
  %w(.ex .exs).include?(File.extname(path))
end
inspect(patch, wrapper) click to toggle source
# File lib/pronto/dialyxir.rb, line 26
def inspect(patch, wrapper)
  offences = wrapper.lint(patch)
  messages = []

  offences.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/dialyxir.rb, line 41
def new_message(offence, line)
  path = line.patch.delta.new_file[:path]
  Message.new(path, line, offence[:level], offence[:message])
end