Sha256: 2ef70294443bf6641aeeca23c7da82cdf14008bc55bdc5639822f09bf8d99f54

Contents?: true

Size: 534 Bytes

Versions: 2

Compression:

Stored size: 534 Bytes

Contents

module Overcommit::Hook::PreCommit
  # Runs `rubocop` against any modified Ruby files.
  #
  # @see http://batsov.com/rubocop/
  class RuboCop < Base
    MESSAGE_TYPE_CATEGORIZER = lambda do |type|
      type.include?('W') ? :warning : :error
    end

    def run
      result = execute(command + applicable_files)
      return :pass if result.success?

      extract_messages(
        result.stdout.split("\n"),
        /^(?<file>[^:]+):(?<line>\d+):[^ ]+ (?<type>[^ ]+)/,
        MESSAGE_TYPE_CATEGORIZER,
      )
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
overcommit-0.27.0 lib/overcommit/hook/pre_commit/rubo_cop.rb
overcommit-0.26.0 lib/overcommit/hook/pre_commit/rubo_cop.rb