Method: Overcommit::Hook::PreCommit::Pep8#run

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

#runObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/overcommit/hook/pre_commit/pep8.rb', line 6

def run
  result = execute(command, args: applicable_files)
  output = result.stdout.chomp

  return :pass if result.success? && output.empty?

  # example message:
  #   path/to/file.py:88:5: E301 expected 1 blank line, found 0
  extract_messages(
    output.split("\n"),
    /^(?<file>(?:\w:)?[^:]+):(?<line>\d+):\d+:\s(?<type>E|W)/,
    lambda { |type| type.include?('W') ? :warning : :error }
  )
end