Sha256: 612e128381d31efcce615081818ff60248487299f44306b2b66162ca8792a779

Contents?: true

Size: 900 Bytes

Versions: 1

Compression:

Stored size: 900 Bytes

Contents

module Pronto
  module ProntoSimplecov
    class Runner < Runner
      def run
        return [] unless @patches
        return [] if coverage.empty?
        @patches.map { |patch| process(patch) }
                .flatten.compact
      end

      def process(patch)
        file_coverage = coverage[patch.new_file_full_path.to_s]
        return unless file_coverage
        patch.added_lines
          .select { |line| file_coverage.line(line.new_lineno).missed? unless file_coverage.line(line.new_lineno).nil? }
             .map { |line| message(line) }
      end

      def message(line)
        path = line.patch.delta.new_file[:path]
        Message.new(path, line, :error, 'This change has no test coverage', nil, self.class)
      end

      def coverage
        @coverage ||= Hash[SimpleCov::ResultMerger.merged_result.files.map { |file| [file.filename, file] }]
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pronto-simplecov-0.1.1 lib/pronto/pronto_simplecov/runner.rb