class Overcommit::Hook::PreCommit::Pylint

Runs `pylint` against any modified Python files.

@see www.pylint.org/

Constants

MESSAGE_REGEX
MESSAGE_TYPE_CATEGORIZER

Classify 'E' and 'F' message codes as errors, everything else as warnings.

http://pylint.readthedocs.org/en/latest/tutorial.html#getting-started

Public Instance Methods

run() click to toggle source
# File lib/overcommit/hook/pre_commit/pylint.rb, line 17
def run
  result = execute(command, args: applicable_files)
  return :pass if result.success?

  output = result.stdout.chomp

  # example message:
  #   path/to/file.py:64:C: Missing function docstring (missing-docstring)
  extract_messages(
    output.split("\n").grep(MESSAGE_REGEX),
    MESSAGE_REGEX,
    MESSAGE_TYPE_CATEGORIZER
  )
end