Sha256: d029c818ee0ccc7dcb7623b99d3d791fd425ddfc9373b820108067c689f8cc80
Contents?: true
Size: 1.03 KB
Versions: 2
Compression:
Stored size: 1.03 KB
Contents
require 'pronto/swiftlint/wrapper' require 'pronto' module Pronto class SwiftlintRunner < Runner def run(patches, _) 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 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 def new_message(offence, line) path = line.patch.delta.new_file[:path] Message.new(path, line, offence[:level], offence[:message]) end def swift_file?(path) %w(.swift).include?(File.extname(path)) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
pronto-swiftlint-0.1.1 | lib/pronto/swiftlint_runner.rb |
pronto-swiftlint-0.1.0 | lib/pronto/swiftlint_runner.rb |