Class: Overcommit::Hook::PreCommit::Flay
- Defined in:
- lib/overcommit/hook/pre_commit/flay.rb
Overview
Runs ‘flay` against any modified files.
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#run ⇒ Object
Flay prints two kinds of messages:.
Methods inherited from Base
#applicable_files, #command, #description, #enabled?, #execute, #execute_in_background, #flags, #in_path?, #included_files, #initialize, #name, #parallelize?, #processors, #quiet?, #required?, #required_executable, #required_libraries, #run?, #run_and_transform, #skip?
Constructor Details
This class inherits a constructor from Overcommit::Hook::Base
Instance Method Details
#run ⇒ Object
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'] = [] # 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? = results.join("\n").gsub(/^\d+\)\s*/, '') = Overcommit::Hook::Message.new(:error, nil, nil, ) << end end end |