Sha256: d3ca5416b34bf1cdb6663d831241ecb7cbc057ccadcc65b4497907d77038a59c

Contents?: true

Size: 1 KB

Versions: 7

Compression:

Stored size: 1 KB

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
      @fasterer_config ||= ::Fasterer::Config.new
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
pronto-fasterer-0.11.3 lib/pronto/fasterer.rb
pronto-fasterer-0.11.2 lib/pronto/fasterer.rb
pronto-fasterer-0.11.1 lib/pronto/fasterer.rb
pronto-fasterer-0.11.0 lib/pronto/fasterer.rb
pronto-fasterer-0.10.0 lib/pronto/fasterer.rb
pronto-fasterer-0.9.0 lib/pronto/fasterer.rb
pronto-fasterer-0.8.1 lib/pronto/fasterer.rb