diff --git a/Library/ENV/4.3/cc b/Library/ENV/4.3/cc index f388e00bfb..1fb6d82075 100755 --- a/Library/ENV/4.3/cc +++ b/Library/ENV/4.3/cc @@ -21,7 +21,7 @@ class Cmd end def mode - if @arg0 == "cpp" or @arg0 == "ld" + if @arg0 == "cpp" || @arg0 == "ld" @arg0.to_sym elsif @args.include? "-c" if @arg0 =~ /(?:c|g|clang)\+\+/ @@ -61,7 +61,7 @@ class Cmd end def args - if @args.length == 1 and @args[0] == "-v" + if @args.length == 1 && @args[0] == "-v" # Don't add linker arguments if -v passed as sole option. This stops gcc # -v with no other arguments from outputting a linker error. Some # software uses gcc -v (wrongly) to sniff the GCC version. diff --git a/Library/ENV/scm/git b/Library/ENV/scm/git index 06a04b7f16..0c768403ce 100755 --- a/Library/ENV/scm/git +++ b/Library/ENV/scm/git @@ -17,7 +17,7 @@ when "git" then %W[HOMEBREW_GIT GIT] when "svn" then %W[HOMEBREW_SVN] else [] end.each do |key| - exec ENV[key], *ARGV if ENV[key] and File.executable? ENV[key] + exec ENV[key], *ARGV if ENV[key] && File.executable?(ENV[key]) end brew_version = File.expand_path("#{D}/../../../bin/#{F}") diff --git a/Library/Homebrew/bottles.rb b/Library/Homebrew/bottles.rb index 5b0073d3b2..2686f2468d 100644 --- a/Library/Homebrew/bottles.rb +++ b/Library/Homebrew/bottles.rb @@ -63,12 +63,12 @@ end class Bintray def self.package(formula_name) - formula_name.to_s.gsub "+", "x" + formula_name.to_s.tr("+", "x") end def self.repository(tap = nil) return "bottles" if tap.nil? || tap == "Homebrew/homebrew" - "bottles-#{tap.sub(/^homebrew\/(homebrew-)?/i, "")}" + "bottles-#{tap.sub(%r{^homebrew/(homebrew-)?}i, "")}" end end diff --git a/Library/Homebrew/caveats.rb b/Library/Homebrew/caveats.rb index 59e15ebbc0..3eab3722b9 100644 --- a/Library/Homebrew/caveats.rb +++ b/Library/Homebrew/caveats.rb @@ -149,8 +149,11 @@ class Caveats def plist_caveats s = [] if f.plist || (keg && keg.plist_installed?) - destination = f.plist_startup ? "/Library/LaunchDaemons" \ - : "~/Library/LaunchAgents" + destination = if f.plist_startup + "/Library/LaunchDaemons" + else + "~/Library/LaunchAgents" + end plist_filename = if f.plist f.plist_path.basename diff --git a/Library/Homebrew/cmd/aspell-dictionaries.rb b/Library/Homebrew/cmd/aspell-dictionaries.rb index f610ecfbd6..754b6614ed 100644 --- a/Library/Homebrew/cmd/aspell-dictionaries.rb +++ b/Library/Homebrew/cmd/aspell-dictionaries.rb @@ -16,7 +16,7 @@ module Homebrew fields = line.split('"') lang = fields[1] path = fields[3] - lang.gsub!("-", "_") + lang.tr!("-", "_") languages[lang] = path end end diff --git a/Library/Homebrew/cmd/audit.rb b/Library/Homebrew/cmd/audit.rb index 7390b8a86f..84a93859f9 100644 --- a/Library/Homebrew/cmd/audit.rb +++ b/Library/Homebrew/cmd/audit.rb @@ -360,7 +360,7 @@ class FormulaAuditor EOS end - if desc =~ %r[([Cc]ommand ?line)] + if desc =~ /([Cc]ommand ?line)/ problem "Description should use \"command-line\" instead of \"#{$1}\"" end end diff --git a/Library/Homebrew/cmd/list.rb b/Library/Homebrew/cmd/list.rb index 53985d1135..068f268355 100644 --- a/Library/Homebrew/cmd/list.rb +++ b/Library/Homebrew/cmd/list.rb @@ -136,7 +136,7 @@ class PrettyListing root.children.sort.each do |pn| if pn.directory? dirs << pn - elsif block_given? and yield pn + elsif block_given? && yield(pn) puts pn other = "other " else diff --git a/Library/Homebrew/cmd/test-bot.rb b/Library/Homebrew/cmd/test-bot.rb index 8e9e3c239b..6dcd301aab 100644 --- a/Library/Homebrew/cmd/test-bot.rb +++ b/Library/Homebrew/cmd/test-bot.rb @@ -793,7 +793,7 @@ module Homebrew bottle_args << "--tap=#{tap}" if tap safe_system "brew", "bottle", *bottle_args - remote_repo = tap ? tap.gsub("/", "-") : "homebrew" + remote_repo = tap ? tap.tr("/", "-") : "homebrew" remote = "git@github.com:BrewTestBot/#{remote_repo}.git" tag = pr ? "pr-#{pr}" : "testing-#{number}" diff --git a/Library/Homebrew/config.rb b/Library/Homebrew/config.rb index bd8e3e53c8..57cf19283d 100644 --- a/Library/Homebrew/config.rb +++ b/Library/Homebrew/config.rb @@ -5,7 +5,7 @@ def cache # we do this for historic reasons, however the cache *should* be the same # directory whichever user is used and whatever instance of brew is executed home_cache = Pathname.new("~/Library/Caches/Homebrew").expand_path - if home_cache.directory? and home_cache.writable_real? + if home_cache.directory? && home_cache.writable_real? home_cache else Pathname.new("/Library/Caches/Homebrew").extend Module.new { diff --git a/Library/Homebrew/debrew.rb b/Library/Homebrew/debrew.rb index 3f21094be4..7b1b507359 100644 --- a/Library/Homebrew/debrew.rb +++ b/Library/Homebrew/debrew.rb @@ -53,7 +53,7 @@ module Debrew menu.entries.each_with_index { |e, i| puts "#{i+1}. #{e.name}" } print menu.prompt unless menu.prompt.nil? - input = $stdin.gets or exit + input = $stdin.gets || exit input.chomp! i = input.to_i diff --git a/Library/Homebrew/extend/ENV/super.rb b/Library/Homebrew/extend/ENV/super.rb index 9116029194..a5892d122b 100644 --- a/Library/Homebrew/extend/ENV/super.rb +++ b/Library/Homebrew/extend/ENV/super.rb @@ -121,7 +121,7 @@ module Superenv when "gcc-4.2" begin apple_gcc42 = Formulary.factory("apple-gcc42") - rescue FormulaUnavailableError + rescue FormulaUnavailableError end paths << apple_gcc42.opt_bin.to_s if apple_gcc42 when GNU_GCC_REGEXP diff --git a/Library/Homebrew/formula_cellar_checks.rb b/Library/Homebrew/formula_cellar_checks.rb index 0c62687acc..071b3f4ddd 100644 --- a/Library/Homebrew/formula_cellar_checks.rb +++ b/Library/Homebrew/formula_cellar_checks.rb @@ -152,7 +152,7 @@ module FormulaCellarChecks object files were linked against system openssl These object files were linked against the deprecated system OpenSSL. Adding `depends_on "openssl"` to the formula may help. - #{system_openssl * "\n "} + #{system_openssl * "\n "} EOS end diff --git a/Library/Homebrew/formulary.rb b/Library/Homebrew/formulary.rb index 9999ce8dd2..b684519c64 100644 --- a/Library/Homebrew/formulary.rb +++ b/Library/Homebrew/formulary.rb @@ -43,7 +43,7 @@ class Formulary def self.class_s(name) class_name = name.capitalize class_name.gsub!(/[-_.\s]([a-zA-Z0-9])/) { $1.upcase } - class_name.gsub!("+", "x") + class_name.tr!("+", "x") class_name end diff --git a/Library/Homebrew/os/mac/hardware.rb b/Library/Homebrew/os/mac/hardware.rb index 11cf0142ae..db4fe58758 100644 --- a/Library/Homebrew/os/mac/hardware.rb +++ b/Library/Homebrew/os/mac/hardware.rb @@ -62,7 +62,7 @@ module MacCPUs when 100 # This is the only 64-bit PPC CPU type, so it's useful # to distinguish in `brew config` output and in bottle tags - MacOS.prefer_64_bit? ? :g5_64 : :g5 # PowerPC 970 + MacOS.prefer_64_bit? ? :g5_64 : :g5 # PowerPC 970 else :dunno end diff --git a/Library/Homebrew/resource.rb b/Library/Homebrew/resource.rb index 0c3184180f..202b457744 100644 --- a/Library/Homebrew/resource.rb +++ b/Library/Homebrew/resource.rb @@ -57,7 +57,7 @@ class Resource # to be used as resource names without confusing software that # interacts with download_name, e.g. github.com/foo/bar def escaped_name - name.gsub("/", "-") + name.tr("/", "-") end def download_name diff --git a/Library/Homebrew/sandbox.rb b/Library/Homebrew/sandbox.rb index 835ed8a25d..0f4881b416 100644 --- a/Library/Homebrew/sandbox.rb +++ b/Library/Homebrew/sandbox.rb @@ -79,7 +79,6 @@ class Sandbox end def exec(*args) - seatbelt = Tempfile.new(["homebrew", ".sb"], HOMEBREW_TEMP) seatbelt.write(@profile.dump) seatbelt.close @@ -105,7 +104,6 @@ class Sandbox ] quiet_system "syslog #{syslog_args * " "} | grep deny > #{@log}" end - end private diff --git a/Library/Homebrew/test/test_inreplace.rb b/Library/Homebrew/test/test_inreplace.rb index 7b0dfe64d1..d9c4c1ab7b 100644 --- a/Library/Homebrew/test/test_inreplace.rb +++ b/Library/Homebrew/test/test_inreplace.rb @@ -85,7 +85,7 @@ class InreplaceTest < Homebrew::TestCase s.sub!("f", "b") assert_equal "boo", s - s.gsub!("o", "e") + s.tr!("o", "e") assert_equal "bee", s end @@ -99,7 +99,7 @@ class InreplaceTest < Homebrew::TestCase end assert_raises(Utils::InreplaceError) do - inreplace("test") { |s| s.gsub! "d", "f" } + inreplace("test") { |s| s.tr!("d", "f") } end assert_raises(Utils::InreplaceError) do diff --git a/Library/Homebrew/version.rb b/Library/Homebrew/version.rb index 5c9030cd70..d3f0417b01 100644 --- a/Library/Homebrew/version.rb +++ b/Library/Homebrew/version.rb @@ -299,7 +299,7 @@ class Version # e.g. boost_1_39_0 m = /((?:\d+_)+\d+)$/.match(stem) - return m.captures.first.gsub("_", ".") unless m.nil? + return m.captures.first.tr("_", ".") unless m.nil? # e.g. foobar-4.5.1-1 # e.g. unrtf_0.20.4-1