aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorMike McQuaid2017-03-08 17:05:24 +0000
committerGitHub2017-03-08 17:05:24 +0000
commit36296d3594fbe6e432db8711f221d0149e895761 (patch)
tree649e6455448e8b9f5b6238d03b1acbc7f5a5e50d /Library
parentef02414888ec332aa4220fe05428f24b9a4f035f (diff)
parentfe59fde8f8f76b324c86175796c6ea887f465e79 (diff)
downloadbrew-36296d3594fbe6e432db8711f221d0149e895761.tar.bz2
Merge pull request #2291 from MikeMcQuaid/style-rubocop-improve-errors
style: improve Rubocop error handling.
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/cmd/style.rb10
1 files changed, 7 insertions, 3 deletions
diff --git a/Library/Homebrew/cmd/style.rb b/Library/Homebrew/cmd/style.rb
index 3d12561c1..2a7f37031 100644
--- a/Library/Homebrew/cmd/style.rb
+++ b/Library/Homebrew/cmd/style.rb
@@ -70,10 +70,14 @@ module Homebrew
!$?.success?
when :json
json = Utils.popen_read_text("rubocop", "--format", "json", *args)
- # exit status of 1 just means violations were found; other numbers mean execution errors
+ # exit status of 1 just means violations were found; other numbers mean
+ # execution errors.
# 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
+ # native extension problems.
+ # JSON needs to be at least 2 characters.
+ if $?.exitstatus.nil? || $?.exitstatus > 1 || json.to_s.length < 2
+ raise "Error running `rubocop --format json #{args.join " "}`"
+ end
RubocopResults.new(JSON.parse(json))
else
raise "Invalid output_type for check_style_impl: #{output_type}"