Sha256: 6fabd9b66edc511a034636da43c5a0767c8002f2d2b65da64c13533b810295e8
Contents?: true
Size: 920 Bytes
Versions: 19
Compression:
Stored size: 920 Bytes
Contents
# frozen_string_literal: true module Overcommit::Hook::PreCommit # Runs `pylint` against any modified Python files. # # @see http://www.pylint.org/ class Pylint < Base MESSAGE_REGEX = /^(?<file>(?:\w:)?.+):(?<line>\d+):(?<type>[CEFRW])/ # Classify 'E' and 'F' message codes as errors, # everything else as warnings. # http://pylint.readthedocs.org/en/latest/tutorial.html#getting-started MESSAGE_TYPE_CATEGORIZER = lambda do |type| 'EF'.include?(type) ? :error : :warning end 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 end end
Version data entries
19 entries across 19 versions & 2 rubygems