Sha256: b2ba21502f4a9aaf16ac1a57b01053adc2febd313b50d0729f60e5ed9251a231

Contents?: true

Size: 1017 Bytes

Versions: 3

Compression:

Stored size: 1017 Bytes

Contents

require 'pronto'
require 'fasterer'
require 'fasterer/config'

module Pronto
  class Fasterer < Runner
    def run
      valid_patches = ruby_patches.reject do |patch|
        config.ignored_files.include?(patch.delta.new_file[:path])
      end

      valid_patches.map { |patch| inspect(patch) }.flatten.compact
    end

    def inspect(patch)
      analyzer = ::Fasterer::Analyzer.new(patch.new_file_full_path)
      analyzer.scan

      errors = []
      analyzer.errors.each { |error| errors << error }

      errors
        .select { |error| !config.ignored_speedups.include?(error.name) }
        .flat_map do |error|
        patch.added_lines
          .select { |line| line.new_lineno == error.line }
          .map { |line| new_message(error, line) }
      end
    end

    def new_message(error, line)
      path = line.patch.delta.new_file[:path]
      Message.new(path, line, :warning, error.explanation, nil, self.class)
    end

    def config
      @config ||= ::Fasterer::Config.new
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
pronto-fasterer-0.8.0 lib/pronto/fasterer.rb
pronto-fasterer-0.7.0 lib/pronto/fasterer.rb
pronto-fasterer-0.6.1 lib/pronto/fasterer.rb