Class: Gry::PilotStudy

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

Instance Method Summary collapse

Constructor Details

#initialize(cops, process:) ⇒ PilotStudy

Returns a new instance of PilotStudy.

Parameters:

  • cops (Array<String>)

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



4
5
6
7
# File 'lib/gry/pilot_study.rb', line 4

def initialize(cops, process:)
  @cops = cops
  @process = process == 1 ? 0 : process
end

Instance Method Details

#analyzeObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/gry/pilot_study.rb', line 9

def analyze
  configs = @cops.map{|cop_name| cop_configs(cop_name)}
  max = configs.max_by(&:size).size
  configs.each do |c|
    c.fill(nil, c.size..(max-1))
  end

  rubocop_args = configs.transpose.map do |conf_set|
    compacted = conf_set.compact
    setting = compacted.inject({}) do |a, b|
      a.merge(b)
    end
    cops = setting.keys

    [cops, setting]
  end

  execute_rubocop(rubocop_args)
end