Method: Overcommit::Hook::PreCommit::Flay#run

Defined in:
lib/overcommit/hook/pre_commit/flay.rb

#runObject

Flay prints two kinds of messages:

1) IDENTICAL code found in :defn (mass*2 = MASS) file_path_1.rb:LINE_1 file_path_2.rb:LINE_2

2) Similar code found in :defn (mass = MASS) file_path_1.rb:LINE_1 file_path_2.rb:LINE_2



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/overcommit/hook/pre_commit/flay.rb', line 19

def run
  command = ['flay', '--mass', @config['mass_threshold'].to_s, '--fuzzy', @config['fuzzy'].to_s]
  # Use a more liberal detection method
  command += ['--liberal'] if @config['liberal']
  messages = []
  # Run the command for each file
  applicable_files.each do |file|
    result = execute(command, args: [file])
    results = result.stdout.split("\n\n")
    results.shift
    unless results.empty?
      error_message = results.join("\n").gsub(/^\d+\)\s*/, '')
      message = Overcommit::Hook::Message.new(:error, nil, nil, error_message)
      messages << message
    end
  end
  messages
end