class Pronto::LuacheckRunner

Public Class Methods

new(_, __ = nil) click to toggle source
Calls superclass method
# File lib/pronto/luacheck_runner.rb, line 7
def initialize(_, __ = nil)
  super

  @inspector = ::Pronto::Luacheck::Wrapper.new
end

Public Instance Methods

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

  @patches.select { |patch| valid_patch?(patch) }
          .map { |patch| inspect(patch) }
          .flatten
          .compact
end

Private Instance Methods

inspect(patch) click to toggle source
# File lib/pronto/luacheck_runner.rb, line 34
def inspect(patch)
  offences = @inspector.run(patch.new_file_full_path.to_s)
  offences.map do |offence|
    patch.added_lines
         .select { |line| line.new_lineno == offence[:line] }
         .map { |line| new_message(offence, line) }
  end
end
lua_file?(patch) click to toggle source
# File lib/pronto/luacheck_runner.rb, line 30
def lua_file?(patch)
  patch.new_file_full_path.to_s.end_with?('.lua')
end
new_message(offence, line) click to toggle source
# File lib/pronto/luacheck_runner.rb, line 43
def new_message(offence, line)
  path = line.patch.delta.new_file[:path]
  Message.new(path, line, offence[:level], offence[:message], nil, self.class)
end
valid_patch?(patch) click to toggle source
# File lib/pronto/luacheck_runner.rb, line 24
def valid_patch?(patch)
  return false if patch.additions < 1

  lua_file?(patch)
end