Skip to content

Commit

Permalink
Merge pull request #1313 from Homebrew/new-rubocop-fixes
Browse files Browse the repository at this point in the history
Fix RuboCop `Lint/RedundantDirGlobSort` and `Performance/MapCompact` offenses
  • Loading branch information
issyl0 authored Feb 26, 2024
2 parents 9d77d70 + d4eb4d7 commit 1467bb8
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 13 deletions.
8 changes: 4 additions & 4 deletions lib/bundle/brew_dumper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,8 @@ def formula_to_hash(formula)
installed_as_dependency = tab.installed_as_dependency
installed_on_request = tab.installed_on_request
runtime_dependencies = if (runtime_deps = tab.runtime_dependencies)
runtime_deps.map { |d| d["full_name"] }
.compact
runtime_deps.filter_map { |d| d["full_name"] }

end
poured_from_bottle = tab.poured_from_bottle
end
Expand Down Expand Up @@ -205,13 +205,13 @@ def sort!(formulae)
# Step 2: Sort by formula dependency topology.
topo = Topo.new
formulae.each do |f|
topo[f[:name]] = topo[f[:full_name]] = f[:dependencies].map do |dep|
topo[f[:name]] = topo[f[:full_name]] = f[:dependencies].filter_map do |dep|
ff = formulae_by_name(dep)
next if ff.blank?
next unless ff[:any_version_installed?]

ff[:full_name]
end.compact
end
end
@formulae = topo.tsort
.map { |name| @formulae_by_full_name[name] || @formulae_by_name[name] }
Expand Down
8 changes: 4 additions & 4 deletions lib/bundle/brew_installer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -172,19 +172,19 @@ def self.upgradable_formulae
end

def self.outdated_formulae
@outdated_formulae ||= formulae.map { |f| f[:name] if f[:outdated?] }.compact
@outdated_formulae ||= formulae.filter_map { |f| f[:name] if f[:outdated?] }
end

def self.pinned_formulae
@pinned_formulae ||= formulae.map { |f| f[:name] if f[:pinned?] }.compact
@pinned_formulae ||= formulae.filter_map { |f| f[:name] if f[:pinned?] }
end

def self.linked_and_keg_only_formulae
@linked_and_keg_only_formulae ||= formulae.map { |f| f[:name] if f[:link?] == true }.compact
@linked_and_keg_only_formulae ||= formulae.filter_map { |f| f[:name] if f[:link?] == true }
end

def self.unlinked_and_not_keg_only_formulae
@unlinked_and_not_keg_only_formulae ||= formulae.map { |f| f[:name] if f[:link?] == false }.compact
@unlinked_and_not_keg_only_formulae ||= formulae.filter_map { |f| f[:name] if f[:link?] == false }
end

def self.formulae
Expand Down
4 changes: 2 additions & 2 deletions lib/bundle/brew_services.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@ def started?(name)
def started_services
@started_services ||= if Bundle.services_installed?
states_to_skip = %w[stopped none]
Utils.safe_popen_read(HOMEBREW_BREW_FILE, "services", "list").lines.map do |line|
Utils.safe_popen_read(HOMEBREW_BREW_FILE, "services", "list").lines.filter_map do |line|
name, state, _plist = line.split(/\s+/)
next if states_to_skip.include? state

name
end.compact
end
else
[]
end
Expand Down
4 changes: 2 additions & 2 deletions lib/bundle/cask_installer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def install(name, preinstall: true, no_upgrade: false, verbose: false, force: fa
return Bundle.system HOMEBREW_BREW_FILE, "upgrade", "--cask", full_name, verbose: verbose
end

args = options.fetch(:args, []).map do |k, v|
args = options.fetch(:args, []).filter_map do |k, v|
case v
when TrueClass
"--#{k}"
Expand All @@ -46,7 +46,7 @@ def install(name, preinstall: true, no_upgrade: false, verbose: false, force: fa
else
"--#{k}=#{v}"
end
end.compact
end

args << "--force" if force
args.uniq!
Expand Down
2 changes: 1 addition & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def linux?
require "active_support/core_ext/enumerable"
require "active_support/core_ext/hash/keys"

Dir.glob("#{PROJECT_ROOT}/lib/**/*.rb").sort.each do |file|
Dir.glob("#{PROJECT_ROOT}/lib/**/*.rb").each do |file|
next if file.include?("/extend/os/")

require file
Expand Down

0 comments on commit 1467bb8

Please sign in to comment.