From 59583e3460f37c0c8c763ab89dd6faaaf0dfa8c3 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Mon, 13 Jul 2020 12:24:00 +0000 Subject: [PATCH 1/2] build(deps): bump rubocop from 0.87.1 to 0.88.0 in /Library/Homebrew Bumps [rubocop](https://github.com/rubocop-hq/rubocop) from 0.87.1 to 0.88.0. - [Release notes](https://github.com/rubocop-hq/rubocop/releases) - [Changelog](https://github.com/rubocop-hq/rubocop/blob/master/CHANGELOG.md) - [Commits](https://github.com/rubocop-hq/rubocop/compare/v0.87.1...v0.88.0) Signed-off-by: dependabot-preview[bot] --- Library/Homebrew/Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Library/Homebrew/Gemfile.lock b/Library/Homebrew/Gemfile.lock index 509fec4d25..5ad1e5f241 100644 --- a/Library/Homebrew/Gemfile.lock +++ b/Library/Homebrew/Gemfile.lock @@ -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) From 76709d82c510231e82acdefa8ce9feb8fd7e2b4b Mon Sep 17 00:00:00 2001 From: Jonathan Chang Date: Mon, 13 Jul 2020 22:48:53 +1000 Subject: [PATCH 2/2] Fix `brew style`. --- Library/Homebrew/build.rb | 5 +++-- Library/Homebrew/cask/artifact/abstract_artifact.rb | 2 +- Library/Homebrew/cask/artifact/abstract_uninstall.rb | 4 ++-- Library/Homebrew/cask/dsl/conflicts_with.rb | 2 +- Library/Homebrew/cli/parser.rb | 10 ++++++---- Library/Homebrew/cmd/update-report.rb | 5 +++-- Library/Homebrew/dev-cmd/bump-formula-pr.rb | 10 ++++++---- Library/Homebrew/dev-cmd/man.rb | 5 +++-- Library/Homebrew/exceptions.rb | 4 ++-- Library/Homebrew/language/java.rb | 2 +- Library/Homebrew/language/python.rb | 4 ++-- Library/Homebrew/os/linux.rb | 2 +- Library/Homebrew/requirements/macos_requirement.rb | 2 +- Library/Homebrew/searchable.rb | 4 ++-- Library/Homebrew/system_command.rb | 2 +- 15 files changed, 35 insertions(+), 28 deletions(-) diff --git a/Library/Homebrew/build.rb b/Library/Homebrew/build.rb index bd1a68614c..0d3dece199 100644 --- a/Library/Homebrew/build.rb +++ b/Library/Homebrew/build.rb @@ -208,11 +208,12 @@ rescue Exception => e # rubocop:disable Lint/RescueException # 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 diff --git a/Library/Homebrew/cask/artifact/abstract_artifact.rb b/Library/Homebrew/cask/artifact/abstract_artifact.rb index 241a2c3b14..4d3f86d85a 100644 --- a/Library/Homebrew/cask/artifact/abstract_artifact.rb +++ b/Library/Homebrew/cask/artifact/abstract_artifact.rb @@ -77,7 +77,7 @@ module Cask 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 diff --git a/Library/Homebrew/cask/artifact/abstract_uninstall.rb b/Library/Homebrew/cask/artifact/abstract_uninstall.rb index 1a2c10d2f2..ce85fd6a65 100644 --- a/Library/Homebrew/cask/artifact/abstract_uninstall.rb +++ b/Library/Homebrew/cask/artifact/abstract_uninstall.rb @@ -34,7 +34,7 @@ module Cask 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) @@ -49,7 +49,7 @@ module Cask 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 diff --git a/Library/Homebrew/cask/dsl/conflicts_with.rb b/Library/Homebrew/cask/dsl/conflicts_with.rb index 48a184dfd3..d90ecdb06e 100644 --- a/Library/Homebrew/cask/dsl/conflicts_with.rb +++ b/Library/Homebrew/cask/dsl/conflicts_with.rb @@ -18,7 +18,7 @@ module Cask 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 diff --git a/Library/Homebrew/cli/parser.rb b/Library/Homebrew/cli/parser.rb index 8109bceee1..13532c8991 100644 --- a/Library/Homebrew/cli/parser.rb +++ b/Library/Homebrew/cli/parser.rb @@ -213,10 +213,11 @@ module Homebrew 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 @@ -225,10 +226,11 @@ module Homebrew 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 diff --git a/Library/Homebrew/cmd/update-report.rb b/Library/Homebrew/cmd/update-report.rb index d3c4637ee2..47b5f50db1 100644 --- a/Library/Homebrew/cmd/update-report.rb +++ b/Library/Homebrew/cmd/update-report.rb @@ -199,10 +199,11 @@ class Reporter 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 diff --git a/Library/Homebrew/dev-cmd/bump-formula-pr.rb b/Library/Homebrew/dev-cmd/bump-formula-pr.rb index a718d92077..4418d66d15 100644 --- a/Library/Homebrew/dev-cmd/bump-formula-pr.rb +++ b/Library/Homebrew/dev-cmd/bump-formula-pr.rb @@ -274,7 +274,8 @@ module Homebrew 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, @@ -291,19 +292,20 @@ module Homebrew "\\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", diff --git a/Library/Homebrew/dev-cmd/man.rb b/Library/Homebrew/dev-cmd/man.rb index ee299ebc68..8d864a7b29 100644 --- a/Library/Homebrew/dev-cmd/man.rb +++ b/Library/Homebrew/dev-cmd/man.rb @@ -124,10 +124,11 @@ module Homebrew 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{(.*?)}, "*`\\1`*") .gsub(/\n\n\n+/, "\n\n") - elsif format_flag == "--roff" + when "--roff" ronn_output = ronn_output.gsub(%r{(.*?)}, "\\fB\\1\\fR") .gsub(%r{(.*?)}, "\\fI\\1\\fR") .gsub(/(^\[?\\fB.+): /, "\\1\n ") diff --git a/Library/Homebrew/exceptions.rb b/Library/Homebrew/exceptions.rb index f7a442eb08..c81977eed9 100644 --- a/Library/Homebrew/exceptions.rb +++ b/Library/Homebrew/exceptions.rb @@ -524,7 +524,7 @@ class ErrorDuringExecution < RuntimeError 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 @@ -543,7 +543,7 @@ class ErrorDuringExecution < RuntimeError end def stderr - [*output].select { |type,| type == :stderr }.map(&:last).join + Array(output).select { |type,| type == :stderr }.map(&:last).join end end diff --git a/Library/Homebrew/language/java.rb b/Library/Homebrew/language/java.rb index 77bddccf5f..78077f3578 100644 --- a/Library/Homebrew/language/java.rb +++ b/Library/Homebrew/language/java.rb @@ -27,7 +27,7 @@ module Language 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 diff --git a/Library/Homebrew/language/python.rb b/Library/Homebrew/language/python.rb index c3538f0ddf..5842e3a55b 100644 --- a/Library/Homebrew/language/python.rb +++ b/Library/Homebrew/language/python.rb @@ -262,7 +262,7 @@ module Language # 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" @@ -292,7 +292,7 @@ module Language 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 diff --git a/Library/Homebrew/os/linux.rb b/Library/Homebrew/os/linux.rb index aed872fce4..2cffb06535 100644 --- a/Library/Homebrew/os/linux.rb +++ b/Library/Homebrew/os/linux.rb @@ -42,7 +42,7 @@ module OS end def languages - @languages ||= [*ENV["LANG"]&.slice(/[a-z]+/)].uniq + @languages ||= Array(ENV["LANG"]&.slice(/[a-z]+/)).uniq end def language diff --git a/Library/Homebrew/requirements/macos_requirement.rb b/Library/Homebrew/requirements/macos_requirement.rb index 194215d6ad..a723dda2c6 100644 --- a/Library/Homebrew/requirements/macos_requirement.rb +++ b/Library/Homebrew/requirements/macos_requirement.rb @@ -29,7 +29,7 @@ class MacOSRequirement < Requirement 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 diff --git a/Library/Homebrew/searchable.rb b/Library/Homebrew/searchable.rb index 05b00d98fe..43fa35241d 100644 --- a/Library/Homebrew/searchable.rb +++ b/Library/Homebrew/searchable.rb @@ -19,7 +19,7 @@ module Searchable 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 @@ -28,7 +28,7 @@ module Searchable 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 diff --git a/Library/Homebrew/system_command.rb b/Library/Homebrew/system_command.rb index fb05c7bd8b..3db2429ab0 100644 --- a/Library/Homebrew/system_command.rb +++ b/Library/Homebrew/system_command.rb @@ -61,7 +61,7 @@ class SystemCommand @executable = executable @args = args @sudo = sudo - @input = [*input] + @input = Array(input) @print_stdout = print_stdout @print_stderr = print_stderr @verbose = verbose