Sha256: ca9e8b9d718b3fe2dfe8b9fdd848ce8521cf93d9e932d2479f47d308c71685a3

Contents?: true

Size: 711 Bytes

Versions: 9

Compression:

Stored size: 711 Bytes

Contents

module Overcommit::Hook::PreCommit
  # Runs `phpstan` against any modified PHP files.
  # For running `phpstan` with Laravel, it requires setup with `ide_helper`.
  #
  # References:
  # https://github.com/phpstan/phpstan/issues/239
  # https://gist.github.com/edmondscommerce/89695c9cd2584fefdf540fb1c528d2c2
  class PhpStan < Base
    MESSAGE_REGEX = /^(?<file>.+)\:(?<line>\d+)\:(?<message>.+)/

    def run
      messages = []

      result = execute(command, args: applicable_files)

      unless result.success?
        messages += result.stdout.lstrip.split("\n")
      end

      return :pass if messages.empty?

      extract_messages(
        messages,
        MESSAGE_REGEX
      )
    end
  end
end

Version data entries

9 entries across 7 versions & 2 rubygems

Version Path
config_gems_initialization_aim-0.1.4 vendor/bundle/ruby/2.5.0/gems/overcommit-0.46.0/lib/overcommit/hook/pre_commit/php_stan.rb
config_gems_initialization_aim-0.1.4 vendor/bundle/ruby/2.5.0/gems/config_gems_initialization_aim-0.1.1/vendor/bundle/ruby/2.5.0/gems/overcommit-0.46.0/lib/overcommit/hook/pre_commit/php_stan.rb
config_gems_initialization_aim-0.1.3 vendor/bundle/ruby/2.5.0/gems/config_gems_initialization_aim-0.1.1/vendor/bundle/ruby/2.5.0/gems/overcommit-0.46.0/lib/overcommit/hook/pre_commit/php_stan.rb
config_gems_initialization_aim-0.1.3 vendor/bundle/ruby/2.5.0/gems/overcommit-0.46.0/lib/overcommit/hook/pre_commit/php_stan.rb
overcommit-0.46.0 lib/overcommit/hook/pre_commit/php_stan.rb
overcommit-0.45.0 lib/overcommit/hook/pre_commit/php_stan.rb
overcommit-0.44.0 lib/overcommit/hook/pre_commit/php_stan.rb
overcommit-0.43.0 lib/overcommit/hook/pre_commit/php_stan.rb
overcommit-0.42.0 lib/overcommit/hook/pre_commit/php_stan.rb