Sha256: d0bd1979082b616b7332e0c7c25759629416405b9e6e4c50266b68e7be12ff90
Contents?: true
Size: 882 Bytes
Versions: 25
Compression:
Stored size: 882 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 class << self # Use RuboCop to produce a list of all files that should be scanned. def target_files @target_files ||= `rubocop -L`.each_line.map(&:strip) end end def initialize(filenames) @filenames = Executor.target_files & filenames end def offenses_by_file return [] if @filenames.empty? escaped_paths = @filenames.map { |path| Shellwords.escape(path) } output = JSON.parse(`rubocop --format json #{escaped_paths.join(' ')}`) output['files'].each_with_object({}) do |file_output, result| result[file_output['path']] = file_output['offenses'] end end end end end
Version data entries
25 entries across 25 versions & 1 rubygems