Class: Gry::RubocopRunner

Inherits:
Object
  • Object
show all
Defined in:
lib/gry/rubocop_runner.rb

Overview

Run RuboCop with specific cops and config

Instance Method Summary collapse

Constructor Details

#initialize(cops, setting) ⇒ RubocopRunner

Returns a new instance of RubocopRunner.

Parameters:

  • cops (Array<String>)

    cop names. e.g.) [‘Style/EmptyElse’]

  • setting (Hash)

    e.g.) => {‘EnforcedStyle’ => ‘both’}



6
7
8
9
10
11
# File 'lib/gry/rubocop_runner.rb', line 6

def initialize(cops, setting)
  @cops = cops
  setting_base = RubocopAdapter.config_base
  @setting = setting_base.merge(setting)
  @tmp_setting_path = nil
end

Instance Method Details

#runObject



13
14
15
16
17
18
19
20
21
# File 'lib/gry/rubocop_runner.rb', line 13

def run
  prepare
  stdout, stderr = run_rubocop
  crashed_cops = parse_stderr(stderr)
  Gry.debug_log "Crashed cops: #{crashed_cops}"
  [JSON.parse(stdout), crashed_cops]
ensure
  clean
end