audit: prevent crash from nil exitstatus (#532)

If rubocop invocation from brew audit exits with nil exitstatus,
brew audit fails with 'undefined method `>' for nil:NilClass'.
This commit is contained in:
Margaret Lewicka 2016-07-16 21:58:47 +01:00 committed by Martin Afanasjew
parent 242508fca4
commit b512834243

View File

@ -63,8 +63,10 @@ module Homebrew
!$?.success? !$?.success?
when :json when :json
json = Utils.popen_read_text("rubocop", "--format", "json", *args) json = Utils.popen_read_text("rubocop", "--format", "json", *args)
# exit status of 1 just means violations were found; others are errors # exit status of 1 just means violations were found; other numbers mean execution errors
raise "Error while running rubocop" if $?.exitstatus > 1 # exitstatus can also be nil if RuboCop process crashes, e.g. due to
# native extension problems
raise "Error while running RuboCop" if $?.exitstatus.nil? || $?.exitstatus > 1
RubocopResults.new(Utils::JSON.load(json)) RubocopResults.new(Utils::JSON.load(json))
else else
raise "Invalid output_type for check_style_impl: #{output_type}" raise "Invalid output_type for check_style_impl: #{output_type}"