Sha256: 0eb4522f736bdd51fda5737fa07b6053773cb4b3194fc27e692932e3abb7b11c

Contents?: true

Size: 557 Bytes

Versions: 9

Compression:

Stored size: 557 Bytes

Contents

# frozen_string_literal: true

module Overcommit::Hook::PreCommit
  # Runs `fasterer` against any modified Ruby files.
  #
  # @see https://github.com/DamirSvrtan/fasterer
  class Fasterer < Base
    def run
      result = execute(command, args: applicable_files)
      output = result.stdout

      if extract_offense_num(output) == 0
        :pass
      else
        [:warn, output]
      end
    end

    private

    def extract_offense_num(raw_output)
      raw_output.scan(/(\d+) offense detected/).flatten.map(&:to_i).inject(0, :+)
    end
  end
end

Version data entries

9 entries across 9 versions & 2 rubygems

Version Path
overcommit-0.64.1 lib/overcommit/hook/pre_commit/fasterer.rb
overcommit-0.64.0 lib/overcommit/hook/pre_commit/fasterer.rb
overcommit-0.63.0 lib/overcommit/hook/pre_commit/fasterer.rb
overcommit-0.62.0 lib/overcommit/hook/pre_commit/fasterer.rb
overcommit-0.61.0 lib/overcommit/hook/pre_commit/fasterer.rb
overcommit-0.60.0 lib/overcommit/hook/pre_commit/fasterer.rb
overcommit-0.59.1 lib/overcommit/hook/pre_commit/fasterer.rb
overcommit-0.59.0 lib/overcommit/hook/pre_commit/fasterer.rb
overcommit-jeygeethanmedia-0.58.0 lib/overcommit/hook/pre_commit/fasterer.rb