mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
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:
parent
6c18a106ef
commit
41e94afda5
@ -32,7 +32,7 @@ module Homebrew
|
|||||||
|
|
||||||
if args.syntax? && args.no_named?
|
if args.syntax? && args.no_named?
|
||||||
scan_files = "#{HOMEBREW_LIBRARY_PATH}/**/*.rb"
|
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)
|
Homebrew.failed = true unless Readall.valid_ruby_syntax?(ruby_files)
|
||||||
end
|
end
|
||||||
|
@ -168,12 +168,12 @@ module Homebrew
|
|||||||
|
|
||||||
unless OS.mac?
|
unless OS.mac?
|
||||||
bundle_args << "--tag" << "~needs_macos" << "--tag" << "~cask"
|
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
|
end
|
||||||
|
|
||||||
unless OS.linux?
|
unless OS.linux?
|
||||||
bundle_args << "--tag" << "~needs_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
|
end
|
||||||
|
|
||||||
puts "Randomized with seed #{seed}"
|
puts "Randomized with seed #{seed}"
|
||||||
|
@ -217,12 +217,12 @@ module Superenv
|
|||||||
rescue FormulaUnavailableError
|
rescue FormulaUnavailableError
|
||||||
nil
|
nil
|
||||||
else
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
paths << keg_only_deps.map(&:opt_lib)
|
paths << keg_only_deps.map(&:opt_lib)
|
||||||
paths << HOMEBREW_PREFIX/"lib"
|
paths << (HOMEBREW_PREFIX/"lib")
|
||||||
|
|
||||||
paths += homebrew_extra_library_paths
|
paths += homebrew_extra_library_paths
|
||||||
PATH.new(paths).existing
|
PATH.new(paths).existing
|
||||||
|
@ -95,7 +95,7 @@ class Keg
|
|||||||
links = file.method(linkage_type)
|
links = file.method(linkage_type)
|
||||||
.call
|
.call
|
||||||
.uniq
|
.uniq
|
||||||
.reject { |fn| fn =~ /^@(loader_|executable_|r)path/ }
|
.grep_v(/^@(loader_|executable_|r)path/)
|
||||||
links.each(&block)
|
links.each(&block)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -82,7 +82,7 @@ module RuboCop
|
|||||||
|
|
||||||
offending_node(hash)
|
offending_node(hash)
|
||||||
problem "Align bottle tags" do |corrector|
|
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)
|
corrector.replace(hash.source_range, new_line)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -118,7 +118,7 @@ module RuboCop
|
|||||||
|
|
||||||
offending_node(hash)
|
offending_node(hash)
|
||||||
problem "Align bottle digests" do |corrector|
|
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)
|
corrector.replace(hash.source_range, new_line)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -416,7 +416,7 @@ class Tap
|
|||||||
|
|
||||||
# Path to the directory of all {Formula} files for this {Tap}.
|
# Path to the directory of all {Formula} files for this {Tap}.
|
||||||
def formula_dir
|
def formula_dir
|
||||||
@formula_dir ||= potential_formula_dirs.find(&:directory?) || path/"Formula"
|
@formula_dir ||= potential_formula_dirs.find(&:directory?) || (path/"Formula")
|
||||||
end
|
end
|
||||||
|
|
||||||
def potential_formula_dirs
|
def potential_formula_dirs
|
||||||
|
@ -138,7 +138,7 @@ describe Cask::Cmd::Uninstall, :cask do
|
|||||||
|
|
||||||
saved_caskfile.dirname.mkpath
|
saved_caskfile.dirname.mkpath
|
||||||
|
|
||||||
IO.write saved_caskfile, <<~RUBY
|
File.write saved_caskfile, <<~RUBY
|
||||||
cask 'ive-been-renamed' do
|
cask 'ive-been-renamed' do
|
||||||
version :latest
|
version :latest
|
||||||
|
|
||||||
|
@ -315,8 +315,8 @@ describe Homebrew::Cleanup do
|
|||||||
it "cleans up VCS checkout directories with modified time < prune time" do
|
it "cleans up VCS checkout directories with modified time < prune time" do
|
||||||
foo = (HOMEBREW_CACHE/"--foo")
|
foo = (HOMEBREW_CACHE/"--foo")
|
||||||
foo.mkpath
|
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(: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(:mtime).and_return(Time.now - (2 * 60 * 60 * 24))
|
||||||
described_class.new(days: 1).cleanup_cache
|
described_class.new(days: 1).cleanup_cache
|
||||||
expect(foo).not_to exist
|
expect(foo).not_to exist
|
||||||
end
|
end
|
||||||
|
@ -8,7 +8,7 @@ cask "with-uninstall-script-app" do
|
|||||||
app "MyFancyApp/MyFancyApp.app"
|
app "MyFancyApp/MyFancyApp.app"
|
||||||
|
|
||||||
postflight do
|
postflight do
|
||||||
IO.write "#{appdir}/MyFancyApp.app/uninstall.sh", <<~SH
|
File.write "#{appdir}/MyFancyApp.app/uninstall.sh", <<~SH
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
/bin/rm -r "#{appdir}/MyFancyApp.app"
|
/bin/rm -r "#{appdir}/MyFancyApp.app"
|
||||||
SH
|
SH
|
||||||
|
@ -8,7 +8,7 @@ cask "with-uninstall-script-user-relative" do
|
|||||||
app "MyFancyApp/MyFancyApp.app", target: "~/MyFancyApp.app"
|
app "MyFancyApp/MyFancyApp.app", target: "~/MyFancyApp.app"
|
||||||
|
|
||||||
postflight do
|
postflight do
|
||||||
IO.write "#{ENV["HOME"]}/MyFancyApp.app/uninstall.sh", <<~SH
|
File.write "#{ENV["HOME"]}/MyFancyApp.app/uninstall.sh", <<~SH
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
/bin/rm -r "#{ENV["HOME"]}/MyFancyApp.app"
|
/bin/rm -r "#{ENV["HOME"]}/MyFancyApp.app"
|
||||||
SH
|
SH
|
||||||
|
@ -95,7 +95,7 @@ describe "globally-scoped helper methods" do
|
|||||||
let(:shell) { dir/"myshell" }
|
let(:shell) { dir/"myshell" }
|
||||||
|
|
||||||
it "starts an interactive shell session" do
|
it "starts an interactive shell session" do
|
||||||
IO.write shell, <<~SH
|
File.write shell, <<~SH
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
echo called > "#{dir}/called"
|
echo called > "#{dir}/called"
|
||||||
SH
|
SH
|
||||||
|
@ -98,7 +98,7 @@ module Formatter
|
|||||||
rows = (objects.count + cols - 1) / cols
|
rows = (objects.count + cols - 1) / cols
|
||||||
cols = (objects.count + rows - 1) / rows # avoid empty trailing columns
|
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)
|
gap_string = "".rjust(gap_size)
|
||||||
|
|
||||||
|
@ -65,7 +65,7 @@ module Repology
|
|||||||
last_package = response.keys.last
|
last_package = response.keys.last
|
||||||
|
|
||||||
page_no += 1
|
page_no += 1
|
||||||
break if limit && outdated_packages.size >= limit || response.size <= 1
|
break if (limit && outdated_packages.size >= limit) || response.size <= 1
|
||||||
end
|
end
|
||||||
|
|
||||||
puts "#{outdated_packages.size} outdated #{package_term.pluralize(outdated_packages.size)} found"
|
puts "#{outdated_packages.size} outdated #{package_term.pluralize(outdated_packages.size)} found"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user