Skip to content

Commit

Permalink
Use each_with_object
Browse files Browse the repository at this point in the history
  • Loading branch information
dduugg committed Jan 22, 2024
1 parent 1a40468 commit e574904
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 18 deletions.
11 changes: 0 additions & 11 deletions Library/Homebrew/extend/enumerable.rbi
Original file line number Diff line number Diff line change
@@ -1,16 +1,5 @@
# typed: strict

module Enumerable
requires_ancestor { Object }

sig {
type_parameters(:key).params(
block: T.nilable(T.proc.params(o: Enumerable::Elem).returns(T.type_parameter(:key))),
).returns(T::Hash[T.type_parameter(:key), Enumerable::Elem])
}
def index_by(&block); end
end

class Hash
sig { returns(T::Hash[Hash::K, Hash::V]) }
def compact_blank; end
Expand Down
13 changes: 6 additions & 7 deletions Library/Homebrew/formula_installer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -565,8 +565,8 @@ def runtime_requirements(formula)
def expand_requirements
unsatisfied_reqs = Hash.new { |h, k| h[k] = [] }
formulae = [formula]
formula_deps_map = {}
formula.recursive_dependencies.each { |dep| formula_deps_map[dep.name] = dep }
formula_deps_map = formula.recursive_dependencies
.each_with_object({}) { |dep, h| h[dep.name] = dep }

Check warning on line 569 in Library/Homebrew/formula_installer.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/formula_installer.rb#L569

Added line #L569 was not covered by tests

while (f = formulae.pop)
runtime_requirements = runtime_requirements(f)
Expand Down Expand Up @@ -1206,11 +1206,10 @@ def previously_fetched_formula
def fetch_bottle_tab
@fetch_bottle_tab ||= begin
formula.fetch_bottle_tab
@bottle_tab_runtime_dependencies = {}
formula.bottle_tab_attributes
.fetch("runtime_dependencies", [])
.each { |dep| @bottle_tab_runtime_dependencies[dep["full_name"]] = dep }
@bottle_tab_runtime_dependencies.freeze
@bottle_tab_runtime_dependencies = formula.bottle_tab_attributes
.fetch("runtime_dependencies", [])
.each_with_object({}) { |dep, h| h[dep["full_name"]] = dep }

Check warning on line 1211 in Library/Homebrew/formula_installer.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/formula_installer.rb#L1211

Added line #L1211 was not covered by tests
.freeze
true
rescue DownloadError, ArgumentError
@fetch_bottle_tab = true
Expand Down

0 comments on commit e574904

Please sign in to comment.