Fix brew style

Fixes for https://github.com/Homebrew/brew/pull/12152.

Extracted into a separate PR so this can be merged immediately.
This commit is contained in:
Mike McQuaid 2021-09-30 10:13:43 +01:00
parent 6c18a106ef
commit 41e94afda5
No known key found for this signature in database
GPG Key ID: 3338A31AFDB1D829
13 changed files with 17 additions and 17 deletions

View File

@ -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

View File

@ -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}"

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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)

View File

@ -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"