rubocop: fix Style/NegatedIfElseCondition

This commit is contained in:
Jonathan Chang 2020-11-09 20:09:16 +11:00
parent 5ce561c4d1
commit ab7b757400
8 changed files with 28 additions and 28 deletions

View File

@ -511,10 +511,10 @@ module Homebrew
arg1 = "--#{arg1.tr("_", "-")}" arg1 = "--#{arg1.tr("_", "-")}"
arg2 = "--#{arg2.tr("_", "-")}" arg2 = "--#{arg2.tr("_", "-")}"
message = if !missing message = if missing
"`#{arg1}` and `#{arg2}` should be passed together."
else
"`#{arg2}` cannot be passed without `#{arg1}`." "`#{arg2}` cannot be passed without `#{arg1}`."
else
"`#{arg1}` and `#{arg2}` should be passed together."
end end
super message super message
end end

View File

@ -113,9 +113,7 @@ module Homebrew
updated = true updated = true
end end
if !updated if updated
puts "Already up-to-date." if !args.preinstall? && !ENV["HOMEBREW_UPDATE_FAILED"]
else
if hub.empty? if hub.empty?
puts "No changes to formulae." puts "No changes to formulae."
else else
@ -128,6 +126,8 @@ module Homebrew
end end
end end
puts if args.preinstall? puts if args.preinstall?
else
puts "Already up-to-date." if !args.preinstall? && !ENV["HOMEBREW_UPDATE_FAILED"]
end end
Commands.rebuild_commands_completion_list Commands.rebuild_commands_completion_list

View File

@ -101,13 +101,13 @@ module Homebrew
def extract def extract
args = extract_args.parse args = extract_args.parse
if args.named.first !~ HOMEBREW_TAP_FORMULA_REGEX if args.named.first =~ HOMEBREW_TAP_FORMULA_REGEX
name = args.named.first.downcase
source_tap = CoreTap.instance
else
name = Regexp.last_match(3).downcase name = Regexp.last_match(3).downcase
source_tap = Tap.fetch(Regexp.last_match(1), Regexp.last_match(2)) source_tap = Tap.fetch(Regexp.last_match(1), Regexp.last_match(2))
raise TapFormulaUnavailableError.new(source_tap, name) unless source_tap.installed? raise TapFormulaUnavailableError.new(source_tap, name) unless source_tap.installed?
else
name = args.named.first.downcase
source_tap = CoreTap.instance
end end
destination_tap = Tap.fetch(args.named.second) destination_tap = Tap.fetch(args.named.second)

View File

@ -758,14 +758,14 @@ module Homebrew
def check_for_unlinked_but_not_keg_only def check_for_unlinked_but_not_keg_only
unlinked = Formula.racks.reject do |rack| unlinked = Formula.racks.reject do |rack|
if !(HOMEBREW_LINKED_KEGS/rack.basename).directory? if (HOMEBREW_LINKED_KEGS/rack.basename).directory?
true
else
begin begin
Formulary.from_rack(rack).keg_only? Formulary.from_rack(rack).keg_only?
rescue FormulaUnavailableError, TapFormulaAmbiguityError, TapFormulaWithOldnameAmbiguityError rescue FormulaUnavailableError, TapFormulaAmbiguityError, TapFormulaWithOldnameAmbiguityError
false false
end end
else
true
end end
end.map(&:basename) end.map(&:basename)
return if unlinked.empty? return if unlinked.empty?

View File

@ -933,9 +933,7 @@ class GitHubGitDownloadStrategy < GitDownloadStrategy
def commit_outdated?(commit) def commit_outdated?(commit)
@last_commit ||= github_last_commit @last_commit ||= github_last_commit
if !@last_commit if @last_commit
super
else
return true unless commit return true unless commit
return true unless @last_commit.start_with?(commit) return true unless @last_commit.start_with?(commit)
@ -945,6 +943,8 @@ class GitHubGitDownloadStrategy < GitDownloadStrategy
version.update_commit(commit) version.update_commit(commit)
false false
end end
else
super
end end
end end
end end

View File

@ -22,10 +22,10 @@ module SystemConfig
def describe_homebrew_ruby def describe_homebrew_ruby
s = describe_homebrew_ruby_version s = describe_homebrew_ruby_version
if !RUBY_PATH.to_s.match?(%r{^/System/Library/Frameworks/Ruby\.framework/Versions/[12]\.[089]/usr/bin/ruby}) if RUBY_PATH.to_s.match?(%r{^/System/Library/Frameworks/Ruby\.framework/Versions/[12]\.[089]/usr/bin/ruby})
"#{s} => #{RUBY_PATH}"
else
s s
else
"#{s} => #{RUBY_PATH}"
end end
end end

View File

@ -71,9 +71,7 @@ module OS
def sdk_paths def sdk_paths
@sdk_paths ||= begin @sdk_paths ||= begin
# Bail out if there is no SDK prefix at all # Bail out if there is no SDK prefix at all
if !File.directory? sdk_prefix if File.directory? sdk_prefix
{}
else
paths = {} paths = {}
Dir[File.join(sdk_prefix, "MacOSX*.sdk")].each do |sdk_path| Dir[File.join(sdk_prefix, "MacOSX*.sdk")].each do |sdk_path|
@ -82,6 +80,8 @@ module OS
end end
paths paths
else
{}
end end
end end
end end
@ -130,10 +130,10 @@ module OS
# return nil SDKs for Xcode 9 and older. # return nil SDKs for Xcode 9 and older.
def sdk_prefix def sdk_prefix
@sdk_prefix ||= begin @sdk_prefix ||= begin
if !CLT.provides_sdk? if CLT.provides_sdk?
""
else
"#{CLT::PKG_PATH}/SDKs" "#{CLT::PKG_PATH}/SDKs"
else
""
end end
end end
end end

View File

@ -77,11 +77,11 @@ class Sandbox
def deny_write_homebrew_repository def deny_write_homebrew_repository
deny_write HOMEBREW_BREW_FILE deny_write HOMEBREW_BREW_FILE
if HOMEBREW_PREFIX.to_s != HOMEBREW_REPOSITORY.to_s if HOMEBREW_PREFIX.to_s == HOMEBREW_REPOSITORY.to_s
deny_write_path HOMEBREW_REPOSITORY
else
deny_write_path HOMEBREW_LIBRARY deny_write_path HOMEBREW_LIBRARY
deny_write_path HOMEBREW_REPOSITORY/".git" deny_write_path HOMEBREW_REPOSITORY/".git"
else
deny_write_path HOMEBREW_REPOSITORY
end end
end end