diff --git a/Library/Homebrew/cmd/readall.rb b/Library/Homebrew/cmd/readall.rb index 3468d0036f..7c64d8eb09 100644 --- a/Library/Homebrew/cmd/readall.rb +++ b/Library/Homebrew/cmd/readall.rb @@ -32,7 +32,7 @@ module Homebrew if args.syntax? && args.no_named? scan_files = "#{HOMEBREW_LIBRARY_PATH}/**/*.rb" - ruby_files = Dir.glob(scan_files).reject { |file| file =~ %r{/(vendor)/} } + ruby_files = Dir.glob(scan_files).grep_v(%r{/(vendor)/}) Homebrew.failed = true unless Readall.valid_ruby_syntax?(ruby_files) end diff --git a/Library/Homebrew/dev-cmd/tests.rb b/Library/Homebrew/dev-cmd/tests.rb index 63f8d4dc2e..010c7c2f78 100644 --- a/Library/Homebrew/dev-cmd/tests.rb +++ b/Library/Homebrew/dev-cmd/tests.rb @@ -168,12 +168,12 @@ module Homebrew unless OS.mac? bundle_args << "--tag" << "~needs_macos" << "--tag" << "~cask" - files = files.reject { |p| p =~ %r{^test/(os/mac|cask)(/.*|_spec\.rb)$} } + files = files.grep_v(%r{^test/(os/mac|cask)(/.*|_spec\.rb)$}) end unless OS.linux? bundle_args << "--tag" << "~needs_linux" - files = files.reject { |p| p =~ %r{^test/os/linux(/.*|_spec\.rb)$} } + files = files.grep_v(%r{^test/os/linux(/.*|_spec\.rb)$}) end puts "Randomized with seed #{seed}" diff --git a/Library/Homebrew/extend/ENV/super.rb b/Library/Homebrew/extend/ENV/super.rb index acd68e8358..40ef42a4b4 100644 --- a/Library/Homebrew/extend/ENV/super.rb +++ b/Library/Homebrew/extend/ENV/super.rb @@ -217,12 +217,12 @@ module Superenv rescue FormulaUnavailableError nil else - paths << f.opt_lib/"gcc"/f.version.major if f.any_version_installed? + paths << (f.opt_lib/"gcc"/f.version.major) if f.any_version_installed? end end paths << keg_only_deps.map(&:opt_lib) - paths << HOMEBREW_PREFIX/"lib" + paths << (HOMEBREW_PREFIX/"lib") paths += homebrew_extra_library_paths PATH.new(paths).existing diff --git a/Library/Homebrew/extend/os/mac/keg_relocate.rb b/Library/Homebrew/extend/os/mac/keg_relocate.rb index a0abdb0ab9..e190ccaec2 100644 --- a/Library/Homebrew/extend/os/mac/keg_relocate.rb +++ b/Library/Homebrew/extend/os/mac/keg_relocate.rb @@ -95,7 +95,7 @@ class Keg links = file.method(linkage_type) .call .uniq - .reject { |fn| fn =~ /^@(loader_|executable_|r)path/ } + .grep_v(/^@(loader_|executable_|r)path/) links.each(&block) end diff --git a/Library/Homebrew/rubocops/bottle.rb b/Library/Homebrew/rubocops/bottle.rb index e1e4cd01c5..fd69556cb6 100644 --- a/Library/Homebrew/rubocops/bottle.rb +++ b/Library/Homebrew/rubocops/bottle.rb @@ -82,7 +82,7 @@ module RuboCop offending_node(hash) problem "Align bottle tags" do |corrector| - new_line = " " * (max_tag_column - tag_column) + hash.source + new_line = (" " * (max_tag_column - tag_column)) + hash.source corrector.replace(hash.source_range, new_line) end end @@ -118,7 +118,7 @@ module RuboCop offending_node(hash) problem "Align bottle digests" do |corrector| - new_line = " " * (max_digest_column - digest_column) + hash.source + new_line = (" " * (max_digest_column - digest_column)) + hash.source corrector.replace(hash.source_range, new_line) end end diff --git a/Library/Homebrew/tap.rb b/Library/Homebrew/tap.rb index 6aba948771..23b61b2c91 100644 --- a/Library/Homebrew/tap.rb +++ b/Library/Homebrew/tap.rb @@ -416,7 +416,7 @@ class Tap # Path to the directory of all {Formula} files for this {Tap}. def formula_dir - @formula_dir ||= potential_formula_dirs.find(&:directory?) || path/"Formula" + @formula_dir ||= potential_formula_dirs.find(&:directory?) || (path/"Formula") end def potential_formula_dirs diff --git a/Library/Homebrew/test/cask/cmd/uninstall_spec.rb b/Library/Homebrew/test/cask/cmd/uninstall_spec.rb index 80578667e7..527675b6fa 100644 --- a/Library/Homebrew/test/cask/cmd/uninstall_spec.rb +++ b/Library/Homebrew/test/cask/cmd/uninstall_spec.rb @@ -138,7 +138,7 @@ describe Cask::Cmd::Uninstall, :cask do saved_caskfile.dirname.mkpath - IO.write saved_caskfile, <<~RUBY + File.write saved_caskfile, <<~RUBY cask 'ive-been-renamed' do version :latest diff --git a/Library/Homebrew/test/cleanup_spec.rb b/Library/Homebrew/test/cleanup_spec.rb index 0f98f539db..477de25fcd 100644 --- a/Library/Homebrew/test/cleanup_spec.rb +++ b/Library/Homebrew/test/cleanup_spec.rb @@ -315,8 +315,8 @@ describe Homebrew::Cleanup do it "cleans up VCS checkout directories with modified time < prune time" do foo = (HOMEBREW_CACHE/"--foo") foo.mkpath - allow_any_instance_of(Pathname).to receive(:ctime).and_return(Time.now - 2 * 60 * 60 * 24) - allow_any_instance_of(Pathname).to receive(:mtime).and_return(Time.now - 2 * 60 * 60 * 24) + allow_any_instance_of(Pathname).to receive(:ctime).and_return(Time.now - (2 * 60 * 60 * 24)) + allow_any_instance_of(Pathname).to receive(:mtime).and_return(Time.now - (2 * 60 * 60 * 24)) described_class.new(days: 1).cleanup_cache expect(foo).not_to exist end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-script-app.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-script-app.rb index 1b768b25da..22735487d2 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-script-app.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-script-app.rb @@ -8,7 +8,7 @@ cask "with-uninstall-script-app" do app "MyFancyApp/MyFancyApp.app" postflight do - IO.write "#{appdir}/MyFancyApp.app/uninstall.sh", <<~SH + File.write "#{appdir}/MyFancyApp.app/uninstall.sh", <<~SH #!/bin/sh /bin/rm -r "#{appdir}/MyFancyApp.app" SH diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-script-user-relative.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-script-user-relative.rb index fbe786abb3..1908663b4c 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-script-user-relative.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-script-user-relative.rb @@ -8,7 +8,7 @@ cask "with-uninstall-script-user-relative" do app "MyFancyApp/MyFancyApp.app", target: "~/MyFancyApp.app" postflight do - IO.write "#{ENV["HOME"]}/MyFancyApp.app/uninstall.sh", <<~SH + File.write "#{ENV["HOME"]}/MyFancyApp.app/uninstall.sh", <<~SH #!/bin/sh /bin/rm -r "#{ENV["HOME"]}/MyFancyApp.app" SH diff --git a/Library/Homebrew/test/utils_spec.rb b/Library/Homebrew/test/utils_spec.rb index c54a886574..f92d0bbcde 100644 --- a/Library/Homebrew/test/utils_spec.rb +++ b/Library/Homebrew/test/utils_spec.rb @@ -95,7 +95,7 @@ describe "globally-scoped helper methods" do let(:shell) { dir/"myshell" } it "starts an interactive shell session" do - IO.write shell, <<~SH + File.write shell, <<~SH #!/bin/sh echo called > "#{dir}/called" SH diff --git a/Library/Homebrew/utils/formatter.rb b/Library/Homebrew/utils/formatter.rb index 7835e93f28..1d88df0540 100644 --- a/Library/Homebrew/utils/formatter.rb +++ b/Library/Homebrew/utils/formatter.rb @@ -98,7 +98,7 @@ module Formatter rows = (objects.count + cols - 1) / cols cols = (objects.count + rows - 1) / rows # avoid empty trailing columns - col_width = (console_width + gap_size) / cols - gap_size + col_width = ((console_width + gap_size) / cols) - gap_size gap_string = "".rjust(gap_size) diff --git a/Library/Homebrew/utils/repology.rb b/Library/Homebrew/utils/repology.rb index 32f817c420..9250acc4a6 100644 --- a/Library/Homebrew/utils/repology.rb +++ b/Library/Homebrew/utils/repology.rb @@ -65,7 +65,7 @@ module Repology last_package = response.keys.last page_no += 1 - break if limit && outdated_packages.size >= limit || response.size <= 1 + break if (limit && outdated_packages.size >= limit) || response.size <= 1 end puts "#{outdated_packages.size} outdated #{package_term.pluralize(outdated_packages.size)} found"