Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Library/Homebrew/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ GEM
rspec-support (3.9.3)
rspec-wait (0.0.9)
rspec (>= 3, < 4)
rubocop (0.87.1)
rubocop (0.88.0)
parallel (~> 1.10)
parser (>= 2.7.1.1)
rainbow (>= 2.2.2, < 4.0)
Expand Down
5 changes: 3 additions & 2 deletions Library/Homebrew/build.rb
Original file line number Diff line number Diff line change
Expand Up @@ -208,11 +208,12 @@ def fixopt(f)
# BuildErrors are specific to build processes and not other
# children, which is why we create the necessary state here
# and not in Utils.safe_fork.
if error_hash["json_class"] == "BuildError"
case error_hash["json_class"]
when "BuildError"
error_hash["cmd"] = e.cmd
error_hash["args"] = e.args
error_hash["env"] = e.env
elsif error_hash["json_class"] == "ErrorDuringExecution"
when "ErrorDuringExecution"
error_hash["cmd"] = e.cmd
error_hash["status"] = e.status.exitstatus
error_hash["output"] = e.output
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/cask/artifact/abstract_artifact.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def <=>(other)
Manpage,
PostflightBlock,
Zap,
].each_with_index.flat_map { |classes, i| [*classes].map { |c| [c, i] } }.to_h
].each_with_index.flat_map { |classes, i| Array(classes).map { |c| [c, i] } }.to_h

(@@sort_order[self.class] <=> @@sort_order[other.class]).to_i
end
Expand Down
4 changes: 2 additions & 2 deletions Library/Homebrew/cask/artifact/abstract_uninstall.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def initialize(cask, directives)
directives.assert_valid_keys!(*ORDERED_DIRECTIVES)

super(cask)
directives[:signal] = [*directives[:signal]].flatten.each_slice(2).to_a
directives[:signal] = Array(directives[:signal]).flatten.each_slice(2).to_a
@directives = directives

return unless directives.key?(:kext)
Expand All @@ -49,7 +49,7 @@ def to_h
end

def summarize
to_h.flat_map { |key, val| [*val].map { |v| "#{key.inspect} => #{v.inspect}" } }.join(", ")
to_h.flat_map { |key, val| Array(val).map { |v| "#{key.inspect} => #{v.inspect}" } }.join(", ")
end

private
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/cask/dsl/conflicts_with.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class ConflictsWith < DelegateClass(Hash)
def initialize(**pairs)
pairs.assert_valid_keys!(*VALID_KEYS)

super(pairs.transform_values { |v| Set.new([*v]) })
super(pairs.transform_values { |v| Set.new(Array(v)) })

self.default = Set.new
end
Expand Down
8 changes: 6 additions & 2 deletions Library/Homebrew/cask/installer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -328,8 +328,12 @@ def collect_cask_and_formula_dependencies

def missing_cask_and_formula_dependencies
collect_cask_and_formula_dependencies.reject do |cask_or_formula|
(cask_or_formula.try(:installed?) || cask_or_formula.try(:any_version_installed?)) &&
(cask_or_formula.respond_to?(:opt_linked?) ? cask_or_formula.opt_linked? : true)
installed = if cask_or_formula.respond_to?(:any_version_installed?)
cask_or_formula.any_version_installed?
else
cask_or_formula.try(:installed?)
end
installed && (cask_or_formula.respond_to?(:opt_linked?) ? cask_or_formula.opt_linked? : true)
end
end

Expand Down
10 changes: 6 additions & 4 deletions Library/Homebrew/cli/parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -213,10 +213,11 @@ def max_named(count)
end

def min_named(count_or_type)
if count_or_type.is_a?(Integer)
case count_or_type
when Integer
@min_named_args = count_or_type
@min_named_type = nil
elsif count_or_type.is_a?(Symbol)
when Symbol
@min_named_args = 1
@min_named_type = count_or_type
else
Expand All @@ -225,10 +226,11 @@ def min_named(count_or_type)
end

def named(count_or_type)
if count_or_type.is_a?(Integer)
case count_or_type
when Integer
@max_named_args = @min_named_args = count_or_type
@min_named_type = nil
elsif count_or_type.is_a?(Symbol)
when Symbol
@max_named_args = @min_named_args = 1
@min_named_type = count_or_type
else
Expand Down
6 changes: 3 additions & 3 deletions Library/Homebrew/cmd/shellenv.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@
#: Consider adding evaluation of this command's output to your dotfiles (e.g. `~/.profile`, `~/.bash_profile`, or `~/.zprofile`) with: `eval $(brew shellenv)`

homebrew-shellenv() {
case "$SHELL" in
*/fish|fish)
case "$(/bin/ps -p $PPID -o comm=)" in
fish|-fish)
echo "set -gx HOMEBREW_PREFIX \"$HOMEBREW_PREFIX\";"
echo "set -gx HOMEBREW_CELLAR \"$HOMEBREW_CELLAR\";"
echo "set -gx HOMEBREW_REPOSITORY \"$HOMEBREW_REPOSITORY\";"
echo "set -q PATH; or set PATH ''; set -gx PATH \"$HOMEBREW_PREFIX/bin\" \"$HOMEBREW_PREFIX/sbin\" \$PATH;"
echo "set -q MANPATH; or set MANPATH ''; set -gx MANPATH \"$HOMEBREW_PREFIX/share/man\" \$MANPATH;"
echo "set -q INFOPATH; or set INFOPATH ''; set -gx INFOPATH \"$HOMEBREW_PREFIX/share/info\" \$INFOPATH;"
;;
*/csh|csh|*/tcsh|tcsh)
csh|-csh|tcsh|-tcsh)
echo "setenv HOMEBREW_PREFIX $HOMEBREW_PREFIX;"
echo "setenv HOMEBREW_CELLAR $HOMEBREW_CELLAR;"
echo "setenv HOMEBREW_REPOSITORY $HOMEBREW_REPOSITORY;"
Expand Down
5 changes: 3 additions & 2 deletions Library/Homebrew/cmd/update-report.rb
Original file line number Diff line number Diff line change
Expand Up @@ -199,10 +199,11 @@ def report

if paths.any? { |p| tap.cask_file?(p) }
# Currently only need to handle Cask deletion/migration.
if status == "D"
case status
when "D"
# Have a dedicated report array for deleted casks.
@report[:DC] << tap.formula_file_to_name(src)
elsif status == "M"
when "M"
# Report updated casks
@report[:MC] << tap.formula_file_to_name(src)
end
Expand Down
10 changes: 6 additions & 4 deletions Library/Homebrew/dev-cmd/bump-formula-pr.rb
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,8 @@ def bump_formula_pr
end

if forced_version && forced_version != "0"
if requested_spec == :stable
case requested_spec
when :stable
replacement_pairs << if File.read(formula.path).include?("version \"#{old_formula_version}\"")
[
old_formula_version.to_s,
Expand All @@ -291,19 +292,20 @@ def bump_formula_pr
"\\1\\2\\1version \"#{forced_version}\"\n",
]
end
elsif requested_spec == :devel
when :devel
replacement_pairs << [
/( devel do.+?version ")#{old_formula_version}("\n.+?end\n)/m,
"\\1#{forced_version}\\2",
]
end
elsif forced_version && forced_version == "0"
if requested_spec == :stable
case requested_spec
when :stable
replacement_pairs << [
/^ version "[\w.\-+]+"\n/m,
"",
]
elsif requested_spec == :devel
when :devel
replacement_pairs << [
/( devel do.+?)^ +version "[^\n]+"\n(.+?end\n)/m,
"\\1\\2",
Expand Down
5 changes: 3 additions & 2 deletions Library/Homebrew/dev-cmd/man.rb
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,11 @@ def convert_man_page(markup, target)
ronn.close_write
ronn_output = ronn.read
odie "Got no output from ronn!" if ronn_output.blank?
if format_flag == "--markdown"
case format_flag
when "--markdown"
ronn_output = ronn_output.gsub(%r{<var>(.*?)</var>}, "*`\\1`*")
.gsub(/\n\n\n+/, "\n\n")
elsif format_flag == "--roff"
when "--roff"
ronn_output = ronn_output.gsub(%r{<code>(.*?)</code>}, "\\fB\\1\\fR")
.gsub(%r{<var>(.*?)</var>}, "\\fI\\1\\fR")
.gsub(/(^\[?\\fB.+): /, "\\1\n ")
Expand Down
4 changes: 2 additions & 2 deletions Library/Homebrew/exceptions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ def initialize(cmd, status:, output: nil, secrets: [])
redacted_cmd = redact_secrets(cmd.shelljoin.gsub('\=', "="), secrets)
s = +"Failure while executing; `#{redacted_cmd}` exited with #{exitstatus}."

unless [*output].empty?
if Array(output).present?
format_output_line = lambda do |type_line|
type, line = *type_line
if type == :stderr
Expand All @@ -543,7 +543,7 @@ def initialize(cmd, status:, output: nil, secrets: [])
end

def stderr
[*output].select { |type,| type == :stderr }.map(&:last).join
Array(output).select { |type,| type == :stderr }.map(&:last).join
end
end

Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/language/java.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def self.java_home(version = nil)
f = find_openjdk_formula(version)
return f.opt_libexec if f

req = JavaRequirement.new [*version]
req = JavaRequirement.new Array(version)
raise UnsatisfiedRequirements, req.message unless req.satisfied?

req.java_home
Expand Down
4 changes: 2 additions & 2 deletions Library/Homebrew/language/python.rb
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ def create
# the contents of a `requirements.txt`.
# @return [void]
def pip_install(targets)
targets = [targets] unless targets.is_a? Array
targets = Array(targets)
targets.each do |t|
if t.respond_to? :stage
next if t.name == "homebrew-virtualenv"
Expand Down Expand Up @@ -292,7 +292,7 @@ def pip_install_and_link(targets)
private

def do_install(targets)
targets = [targets] unless targets.is_a? Array
targets = Array(targets)
@formula.system @venv_root/"bin/pip", "install",
"-v", "--no-deps", "--no-binary", ":all:",
"--ignore-installed", *targets
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/os/linux.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def full_version
end

def languages
@languages ||= [*ENV["LANG"]&.slice(/[a-z]+/)].uniq
@languages ||= Array(ENV["LANG"]&.slice(/[a-z]+/)).uniq
end

def language
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/requirements/macos_requirement.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def version_specified?
end

satisfy(build_env: false) do
next [*@version].any? { |v| MacOS.version.public_send(@comparator, v) } if version_specified?
next Array(@version).any? { |v| MacOS.version.public_send(@comparator, v) } if version_specified?
next true if OS.mac?
next true if @version

Expand Down
4 changes: 2 additions & 2 deletions Library/Homebrew/searchable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def simplify_string(string)
def search_regex(regex)
select do |*args|
args = yield(*args) if block_given?
args = [*args].compact
args = Array(args).compact
args.any? { |arg| arg.match?(regex) }
end
end
Expand All @@ -28,7 +28,7 @@ def search_string(string)
simplified_string = simplify_string(string)
select do |*args|
args = yield(*args) if block_given?
args = [*args].compact
args = Array(args).compact
args.any? { |arg| simplify_string(arg).include?(simplified_string) }
end
end
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/system_command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def initialize(executable, args: [], sudo: false, env: {}, input: [], must_succe
@executable = executable
@args = args
@sudo = sudo
@input = [*input]
@input = Array(input)
@print_stdout = print_stdout
@print_stderr = print_stderr
@verbose = verbose
Expand Down