Class: NdrDevSupport::Rubocop::Executor
- Inherits:
-
Object
- Object
- NdrDevSupport::Rubocop::Executor
- Defined in:
- lib/ndr_dev_support/rubocop/executor.rb
Overview
This class filters the Rubocop report of a file to only the given lines.
Class Method Summary collapse
-
.target_files ⇒ Object
Use RuboCop to produce a list of all files that should be scanned.
Instance Method Summary collapse
-
#initialize(filenames) ⇒ Executor
constructor
A new instance of Executor.
- #offenses_by_file ⇒ Object
Constructor Details
#initialize(filenames) ⇒ Executor
Returns a new instance of Executor.
17 18 19 20 21 |
# File 'lib/ndr_dev_support/rubocop/executor.rb', line 17 def initialize(filenames) @filenames = Executor.target_files & filenames check_ruby_syntax end |
Class Method Details
.target_files ⇒ Object
Use RuboCop to produce a list of all files that should be scanned.
12 13 14 |
# File 'lib/ndr_dev_support/rubocop/executor.rb', line 12 def target_files @target_files ||= `rubocop -L 2>/dev/null`.each_line.map(&:strip) end |
Instance Method Details
#offenses_by_file ⇒ Object
23 24 25 26 27 28 29 30 31 |
# File 'lib/ndr_dev_support/rubocop/executor.rb', line 23 def offenses_by_file return [] if @filenames.empty? output = JSON.parse(`rubocop --format json #{escaped_paths.join(' ')} 2>/dev/null`) output['files'].each_with_object({}) do |file_output, result| result[file_output['path']] = file_output['offenses'] end end |