Sha256: 9c988d7922f3bd6c667fc2aba253a0c0f680bc467ab57a739740ffc43e23d3fb

Contents?: true

Size: 599 Bytes

Versions: 1

Compression:

Stored size: 599 Bytes

Contents

require 'json'
require 'shellwords'

module NdrDevSupport
  module Rubocop
    # This class filters the Rubocop report of a file
    # to only the given lines.
    class Executor
      def initialize(filename, lines)
        @filename = filename
        @lines    = lines
      end

      def output
        offenses.select do |offense|
          @lines.include? offense['location']['line']
        end
      end

      private

      def offenses
        hash = JSON.parse(`rubocop --format json #{Shellwords.escape(@filename)}`)
        hash['files'].first['offenses']
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ndr_dev_support-1.1.1 lib/ndr_dev_support/rubocop/executor.rb