From a49282c3181833baaf49e6444600c51873a1fffb Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Fri, 4 Oct 2019 09:19:02 +0200 Subject: [PATCH] Simplify return value logic. --- Library/Homebrew/cmd/style.rb | 2 +- Library/Homebrew/style.rb | 6 +++--- Library/Homebrew/test/cmd/style_spec.rb | 2 +- Library/Homebrew/utils/gems.rb | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Library/Homebrew/cmd/style.rb b/Library/Homebrew/cmd/style.rb index 632ca9c181..77c9a0d67f 100644 --- a/Library/Homebrew/cmd/style.rb +++ b/Library/Homebrew/cmd/style.rb @@ -62,6 +62,6 @@ module Homebrew NewFormulaAudit] end - Homebrew.failed = Style.check_style_and_print(target, options) + Homebrew.failed = !Style.check_style_and_print(target, options) end end diff --git a/Library/Homebrew/style.rb b/Library/Homebrew/style.rb index a0b97c00b7..898883576f 100644 --- a/Library/Homebrew/style.rb +++ b/Library/Homebrew/style.rb @@ -102,7 +102,7 @@ module Homebrew raise "Invalid output_type for check_style_impl: #{output_type}" end - return !rubocop_success if files.present? || !has_non_formula + return rubocop_success if files.present? || !has_non_formula shellcheck = which("shellcheck") shellcheck ||= which("shellcheck", ENV["HOMEBREW_PATH"]) @@ -113,7 +113,7 @@ module Homebrew end unless shellcheck opoo "Could not find or install `shellcheck`! Not checking shell style." - return !rubocop_success + return rubocop_success end shell_files = [ @@ -125,7 +125,7 @@ module Homebrew # TODO: check, fix completions here too. # TODO: consider using ShellCheck JSON output shellcheck_success = system shellcheck, "--shell=bash", *shell_files - !rubocop_success || !shellcheck_success + rubocop_success && shellcheck_success end class RubocopResults diff --git a/Library/Homebrew/test/cmd/style_spec.rb b/Library/Homebrew/test/cmd/style_spec.rb index 7e42891345..d443afde92 100644 --- a/Library/Homebrew/test/cmd/style_spec.rb +++ b/Library/Homebrew/test/cmd/style_spec.rb @@ -79,7 +79,7 @@ describe "brew style" do rubocop_result = Homebrew::Style.check_style_and_print([target_file]) - expect(rubocop_result).to eq false + expect(rubocop_result).to eq true end end end diff --git a/Library/Homebrew/utils/gems.rb b/Library/Homebrew/utils/gems.rb index 2e86e4f51f..61b3f7f1f3 100644 --- a/Library/Homebrew/utils/gems.rb +++ b/Library/Homebrew/utils/gems.rb @@ -92,7 +92,7 @@ module Homebrew @bundle_installed ||= begin bundle = "#{gem_user_bindir}/bundle" bundle_check_output = `#{bundle} check 2>&1` - bundle_check_failed = !$CHILD_STATUS.exitstatus.zero? + bundle_check_failed = !$CHILD_STATUS.success? # for some reason sometimes the exit code lies so check the output too. if bundle_check_failed || bundle_check_output.include?("Install missing gems")