Sha256: 9ba34b4721d2585ba423464e13c9042ef2620a6de1ca3769bf11b5cdfbc7da61

Contents?: true

Size: 546 Bytes

Versions: 2

Compression:

Stored size: 546 Bytes

Contents

module Overcommit::Hook::PreCommit
  # Runs `ruby-lint` against any modified Ruby files.
  #
  # @see https://github.com/YorickPeterse/ruby-lint
  class RubyLint < 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>[^:]+):(?<type>[^:]+):(?<line>\d+)/,
        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/ruby_lint.rb
overcommit-0.26.0 lib/overcommit/hook/pre_commit/ruby_lint.rb