class Pronto::SwiftlintRunner
Public Instance Methods
run()
click to toggle source
# File lib/pronto/swiftlint_runner.rb, line 6 def run return [] unless @patches offences = Swiftlint::Wrapper.new.lint @patches.select { |p| p.additions > 0 } .select { |p| swift_file?(p.new_file_full_path) } .map { |p| inspect(p, offences) } .flatten .compact end
Private Instance Methods
inspect(patch, offences)
click to toggle source
# File lib/pronto/swiftlint_runner.rb, line 20 def inspect(patch, offences) messages = [] offences_in_file = offences[patch.new_file_full_path.to_s] return unless offences_in_file offences_in_file.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/swiftlint_runner.rb, line 35 def new_message(offence, line) path = line.patch.delta.new_file[:path] Message.new(path, line, offence[:level], offence[:message], nil, self.class) end
swift_file?(path)
click to toggle source
# File lib/pronto/swiftlint_runner.rb, line 40 def swift_file?(path) %w(.swift).include?(File.extname(path)) end