aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/extend
diff options
context:
space:
mode:
authorMarkus Reiter2016-09-24 17:38:49 +0200
committerGitHub2016-09-24 17:38:49 +0200
commite2c7509065d8cd6fd76cd631f5c8d1068df49cad (patch)
tree03eee4f10d15a33674735be36d0939da964ab60c /Library/Homebrew/extend
parenteb3b94d94a7329d92171b75ea163f139cbf71aa6 (diff)
parent58e36c73193befb57d351344cea2a4a33fef850d (diff)
downloadbrew-e2c7509065d8cd6fd76cd631f5c8d1068df49cad.tar.bz2
Merge pull request #1113 from reitermarkus/rubocop-guardclause
RuboCop: Fix Style/GuardClause.
Diffstat (limited to 'Library/Homebrew/extend')
-rw-r--r--Library/Homebrew/extend/ARGV.rb6
-rw-r--r--Library/Homebrew/extend/ENV/shared.rb16
-rw-r--r--Library/Homebrew/extend/ENV/std.rb15
-rw-r--r--Library/Homebrew/extend/ENV/super.rb12
-rw-r--r--Library/Homebrew/extend/fileutils.rb7
-rw-r--r--Library/Homebrew/extend/os/mac/extend/ENV/std.rb63
-rw-r--r--Library/Homebrew/extend/os/mac/formula_cellar_checks.rb13
-rw-r--r--Library/Homebrew/extend/os/mac/utils/bottles.rb7
-rw-r--r--Library/Homebrew/extend/string.rb5
9 files changed, 67 insertions, 77 deletions
diff --git a/Library/Homebrew/extend/ARGV.rb b/Library/Homebrew/extend/ARGV.rb
index 92b4cb898..ecd50ce06 100644
--- a/Library/Homebrew/extend/ARGV.rb
+++ b/Library/Homebrew/extend/ARGV.rb
@@ -88,11 +88,11 @@ module HomebrewArgvExtension
Formulary.from_rack(rack)
end
- if (prefix = f.installed_prefix).directory?
- Keg.new(prefix)
- else
+ unless (prefix = f.installed_prefix).directory?
raise MultipleVersionsInstalledError, rack.basename
end
+
+ Keg.new(prefix)
end
rescue FormulaUnavailableError
raise <<-EOS.undent
diff --git a/Library/Homebrew/extend/ENV/shared.rb b/Library/Homebrew/extend/ENV/shared.rb
index 447e4dd29..909dc4f94 100644
--- a/Library/Homebrew/extend/ENV/shared.rb
+++ b/Library/Homebrew/extend/ENV/shared.rb
@@ -289,12 +289,11 @@ module SharedEnvExtension
EOS
end
- unless gcc_formula.opt_prefix.exist?
- raise <<-EOS.undent
- The requested Homebrew GCC was not installed. You must:
- brew install #{gcc_formula.full_name}
- EOS
- end
+ return if gcc_formula.opt_prefix.exist?
+ raise <<-EOS.undent
+ The requested Homebrew GCC was not installed. You must:
+ brew install #{gcc_formula.full_name}
+ EOS
end
def permit_arch_flags; end
@@ -328,9 +327,8 @@ module SharedEnvExtension
end
def check_for_compiler_universal_support
- if homebrew_cc =~ GNU_GCC_REGEXP
- raise "Non-Apple GCC can't build universal binaries"
- end
+ return unless homebrew_cc =~ GNU_GCC_REGEXP
+ raise "Non-Apple GCC can't build universal binaries"
end
def gcc_with_cxx11_support?(cc)
diff --git a/Library/Homebrew/extend/ENV/std.rb b/Library/Homebrew/extend/ENV/std.rb
index 68bc9499d..b56aa56f3 100644
--- a/Library/Homebrew/extend/ENV/std.rb
+++ b/Library/Homebrew/extend/ENV/std.rb
@@ -48,10 +48,9 @@ module Stdenv
send(compiler)
- if cc =~ GNU_GCC_REGEXP
- gcc_formula = gcc_version_formula($&)
- append_path "PATH", gcc_formula.opt_bin.to_s
- end
+ return unless cc =~ GNU_GCC_REGEXP
+ gcc_formula = gcc_version_formula($&)
+ append_path "PATH", gcc_formula.opt_bin.to_s
end
alias generic_setup_build_environment setup_build_environment
@@ -174,10 +173,10 @@ module Stdenv
append_to_cflags Hardware::CPU.universal_archs.as_arch_flags
append "LDFLAGS", Hardware::CPU.universal_archs.as_arch_flags
- if compiler != :clang && Hardware.is_32_bit?
- # Can't mix "-march" for a 32-bit CPU with "-arch x86_64"
- replace_in_cflags(/-march=\S*/, "-Xarch_#{Hardware::CPU.arch_32_bit} \\0")
- end
+ return if compiler == :clang
+ return unless Hardware.is_32_bit?
+ # Can't mix "-march" for a 32-bit CPU with "-arch x86_64"
+ replace_in_cflags(/-march=\S*/, "-Xarch_#{Hardware::CPU.arch_32_bit} \\0")
end
def cxx11
diff --git a/Library/Homebrew/extend/ENV/super.rb b/Library/Homebrew/extend/ENV/super.rb
index 1c0271685..a3837c695 100644
--- a/Library/Homebrew/extend/ENV/super.rb
+++ b/Library/Homebrew/extend/ENV/super.rb
@@ -276,12 +276,12 @@ module Superenv
self["HOMEBREW_ARCHFLAGS"] = Hardware::CPU.universal_archs.as_arch_flags
# GCC doesn't accept "-march" for a 32-bit CPU with "-arch x86_64"
- if compiler != :clang && Hardware::CPU.is_32_bit?
- self["HOMEBREW_OPTFLAGS"] = self["HOMEBREW_OPTFLAGS"].sub(
- /-march=\S*/,
- "-Xarch_#{Hardware::CPU.arch_32_bit} \\0"
- )
- end
+ return if compiler == :clang
+ return unless Hardware::CPU.is_32_bit?
+ self["HOMEBREW_OPTFLAGS"] = self["HOMEBREW_OPTFLAGS"].sub(
+ /-march=\S*/,
+ "-Xarch_#{Hardware::CPU.arch_32_bit} \\0"
+ )
end
def permit_arch_flags
diff --git a/Library/Homebrew/extend/fileutils.rb b/Library/Homebrew/extend/fileutils.rb
index b889f9ded..8b8d21da4 100644
--- a/Library/Homebrew/extend/fileutils.rb
+++ b/Library/Homebrew/extend/fileutils.rb
@@ -89,10 +89,9 @@ module FileUtils
# A version of mkdir that also changes to that folder in a block.
def mkdir(name, &_block)
old_mkdir(name)
- if block_given?
- chdir name do
- yield
- end
+ return unless block_given?
+ chdir name do
+ yield
end
end
module_function :mkdir
diff --git a/Library/Homebrew/extend/os/mac/extend/ENV/std.rb b/Library/Homebrew/extend/os/mac/extend/ENV/std.rb
index 8efbd3bc9..4853ecf0c 100644
--- a/Library/Homebrew/extend/os/mac/extend/ENV/std.rb
+++ b/Library/Homebrew/extend/os/mac/extend/ENV/std.rb
@@ -20,14 +20,13 @@ module Stdenv
# Leopard's ld needs some convincing that it's building 64-bit
# See: https://github.com/mistydemeo/tigerbrew/issues/59
- if MacOS.version == :leopard && MacOS.prefer_64_bit?
- append "LDFLAGS", "-arch #{Hardware::CPU.arch_64_bit}"
+ return unless MacOS.version == :leopard && MacOS.prefer_64_bit?
+ append "LDFLAGS", "-arch #{Hardware::CPU.arch_64_bit}"
- # Many, many builds are broken thanks to Leopard's buggy ld.
- # Our ld64 fixes many of those builds, though of course we can't
- # depend on it already being installed to build itself.
- ld64 if Formula["ld64"].installed?
- end
+ # Many, many builds are broken thanks to Leopard's buggy ld.
+ # Our ld64 fixes many of those builds, though of course we can't
+ # depend on it already being installed to build itself.
+ ld64 if Formula["ld64"].installed?
end
def homebrew_extra_pkg_config_paths
@@ -65,19 +64,18 @@ module Stdenv
delete("CPATH")
remove "LDFLAGS", "-L#{HOMEBREW_PREFIX}/lib"
- if (sdk = MacOS.sdk_path(version)) && !MacOS::CLT.installed?
- delete("SDKROOT")
- remove_from_cflags "-isysroot #{sdk}"
- remove "CPPFLAGS", "-isysroot #{sdk}"
- remove "LDFLAGS", "-isysroot #{sdk}"
- if HOMEBREW_PREFIX.to_s == "/usr/local"
- delete("CMAKE_PREFIX_PATH")
- else
- # It was set in setup_build_environment, so we have to restore it here.
- self["CMAKE_PREFIX_PATH"] = HOMEBREW_PREFIX.to_s
- end
- remove "CMAKE_FRAMEWORK_PATH", "#{sdk}/System/Library/Frameworks"
+ return unless (sdk = MacOS.sdk_path(version)) && !MacOS::CLT.installed?
+ delete("SDKROOT")
+ remove_from_cflags "-isysroot #{sdk}"
+ remove "CPPFLAGS", "-isysroot #{sdk}"
+ remove "LDFLAGS", "-isysroot #{sdk}"
+ if HOMEBREW_PREFIX.to_s == "/usr/local"
+ delete("CMAKE_PREFIX_PATH")
+ else
+ # It was set in setup_build_environment, so we have to restore it here.
+ self["CMAKE_PREFIX_PATH"] = HOMEBREW_PREFIX.to_s
end
+ remove "CMAKE_FRAMEWORK_PATH", "#{sdk}/System/Library/Frameworks"
end
def macosxsdk(version = MacOS.version)
@@ -89,20 +87,19 @@ module Stdenv
self["CPATH"] = "#{HOMEBREW_PREFIX}/include"
prepend "LDFLAGS", "-L#{HOMEBREW_PREFIX}/lib"
- if (sdk = MacOS.sdk_path(version)) && !MacOS::CLT.installed?
- # Extra setup to support Xcode 4.3+ without CLT.
- self["SDKROOT"] = sdk
- # Tell clang/gcc where system include's are:
- append_path "CPATH", "#{sdk}/usr/include"
- # The -isysroot is needed, too, because of the Frameworks
- append_to_cflags "-isysroot #{sdk}"
- append "CPPFLAGS", "-isysroot #{sdk}"
- # And the linker needs to find sdk/usr/lib
- append "LDFLAGS", "-isysroot #{sdk}"
- # Needed to build cmake itself and perhaps some cmake projects:
- append_path "CMAKE_PREFIX_PATH", "#{sdk}/usr"
- append_path "CMAKE_FRAMEWORK_PATH", "#{sdk}/System/Library/Frameworks"
- end
+ return unless (sdk = MacOS.sdk_path(version)) && !MacOS::CLT.installed?
+ # Extra setup to support Xcode 4.3+ without CLT.
+ self["SDKROOT"] = sdk
+ # Tell clang/gcc where system include's are:
+ append_path "CPATH", "#{sdk}/usr/include"
+ # The -isysroot is needed, too, because of the Frameworks
+ append_to_cflags "-isysroot #{sdk}"
+ append "CPPFLAGS", "-isysroot #{sdk}"
+ # And the linker needs to find sdk/usr/lib
+ append "LDFLAGS", "-isysroot #{sdk}"
+ # Needed to build cmake itself and perhaps some cmake projects:
+ append_path "CMAKE_PREFIX_PATH", "#{sdk}/usr"
+ append_path "CMAKE_FRAMEWORK_PATH", "#{sdk}/System/Library/Frameworks"
end
# Some configure scripts won't find libxml2 without help
diff --git a/Library/Homebrew/extend/os/mac/formula_cellar_checks.rb b/Library/Homebrew/extend/os/mac/formula_cellar_checks.rb
index b3f8250ee..8bc42ad35 100644
--- a/Library/Homebrew/extend/os/mac/formula_cellar_checks.rb
+++ b/Library/Homebrew/extend/os/mac/formula_cellar_checks.rb
@@ -64,13 +64,12 @@ module FormulaCellarChecks
keg = Keg.new(formula.prefix)
checker = LinkageChecker.new(keg, formula)
- if checker.broken_dylibs?
- audit_check_output <<-EOS.undent
- The installation was broken.
- Broken dylib links found:
- #{checker.broken_dylibs.to_a * "\n "}
- EOS
- end
+ return unless checker.broken_dylibs?
+ audit_check_output <<-EOS.undent
+ The installation was broken.
+ Broken dylib links found:
+ #{checker.broken_dylibs.to_a * "\n "}
+ EOS
end
def audit_installed
diff --git a/Library/Homebrew/extend/os/mac/utils/bottles.rb b/Library/Homebrew/extend/os/mac/utils/bottles.rb
index accfc6a59..0dd7341ea 100644
--- a/Library/Homebrew/extend/os/mac/utils/bottles.rb
+++ b/Library/Homebrew/extend/os/mac/utils/bottles.rb
@@ -31,10 +31,9 @@ module Utils
# sometimes a formula has just :tiger_altivec, other times it has
# :tiger_g4, :tiger_g5, etc.
def find_altivec_tag(tag)
- if tag.to_s =~ /(\w+)_(g4|g4e|g5)$/
- altivec_tag = "#{$1}_altivec".to_sym
- altivec_tag if key?(altivec_tag)
- end
+ return unless tag.to_s =~ /(\w+)_(g4|g4e|g5)$/
+ altivec_tag = "#{$1}_altivec".to_sym
+ altivec_tag if key?(altivec_tag)
end
# Allows a bottle tag to specify a specific OS or later,
diff --git a/Library/Homebrew/extend/string.rb b/Library/Homebrew/extend/string.rb
index bd5994fe1..162666d2d 100644
--- a/Library/Homebrew/extend/string.rb
+++ b/Library/Homebrew/extend/string.rb
@@ -59,9 +59,8 @@ module StringInreplaceExtension
# Looks for Makefile style variable defintions and replaces the
# value with "new_value", or removes the definition entirely.
def change_make_var!(flag, new_value)
- unless gsub!(/^#{Regexp.escape(flag)}[ \t]*=[ \t]*(.*)$/, "#{flag}=#{new_value}", false)
- errors << "expected to change #{flag.inspect} to #{new_value.inspect}"
- end
+ return if gsub!(/^#{Regexp.escape(flag)}[ \t]*=[ \t]*(.*)$/, "#{flag}=#{new_value}", false)
+ errors << "expected to change #{flag.inspect} to #{new_value.inspect}"
end
# Removes variable assignments completely.