Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use RuboCop default hash syntax. #1322

Merged
merged 1 commit into from Mar 7, 2024
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/bundle/brew_checker.rb
Expand Up @@ -7,7 +7,7 @@ class BrewChecker < Bundle::Checker::Base
PACKAGE_TYPE_NAME = "Formula"

def installed_and_up_to_date?(formula, no_upgrade: false)
Bundle::BrewInstaller.formula_installed_and_up_to_date?(formula, no_upgrade: no_upgrade)
Bundle::BrewInstaller.formula_installed_and_up_to_date?(formula, no_upgrade:)
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/bundle/brew_dumper.rb
Expand Up @@ -164,7 +164,7 @@ def formula_to_hash(formula)
aliases: formula.aliases,
any_version_installed?: formula.any_version_installed?,
args: Array(args).uniq,
version: version,
version:,
installed_as_dependency?: installed_as_dependency || false,
installed_on_request?: installed_on_request || false,
dependencies: runtime_dependencies,
Expand Down
36 changes: 18 additions & 18 deletions lib/bundle/brew_installer.rb
Expand Up @@ -9,11 +9,11 @@ def self.reset!
end

def self.preinstall(name, no_upgrade: false, verbose: false, **options)
new(name, options).preinstall(no_upgrade: no_upgrade, verbose: verbose)
new(name, options).preinstall(no_upgrade:, verbose:)
end

def self.install(name, preinstall: true, no_upgrade: false, verbose: false, **options)
new(name, options).install(preinstall: preinstall, no_upgrade: no_upgrade, verbose: verbose)
new(name, options).install(preinstall:, no_upgrade:, verbose:)
end

def initialize(name, options = {})
Expand All @@ -39,26 +39,26 @@ def preinstall(no_upgrade: false, verbose: false)

def install(preinstall: true, no_upgrade: false, verbose: false, force: false)
install_result = if preinstall
install_change_state!(no_upgrade: no_upgrade, verbose: verbose, force: force)
install_change_state!(no_upgrade:, verbose:, force:)
else
true
end

if installed?
service_change_state!(verbose: verbose) if install_result
link_change_state!(verbose: verbose, force: force)
service_change_state!(verbose:) if install_result
link_change_state!(verbose:, force:)
end

install_result
end

def install_change_state!(no_upgrade:, verbose:, force:)
return false unless resolve_conflicts!(verbose: verbose)
return false unless resolve_conflicts!(verbose:)

if installed?
upgrade!(verbose: verbose, force: force)
upgrade!(verbose:, force:)
else
install!(verbose: verbose, force: force)
install!(verbose:, force:)
end
end

Expand Down Expand Up @@ -88,10 +88,10 @@ def changed?
def service_change_state!(verbose:)
if restart_service_needed?
puts "Restarting #{@name} service." if verbose
BrewServices.restart(@full_name, verbose: verbose)
BrewServices.restart(@full_name, verbose:)
elsif start_service_needed?
puts "Starting #{@name} service." if verbose
BrewServices.start(@full_name, verbose: verbose)
BrewServices.start(@full_name, verbose:)
else
true
end
Expand All @@ -102,22 +102,22 @@ def link_change_state!(verbose: false, force: false)
when true
unless linked_and_keg_only?
puts "Force-linking #{@name} formula." if verbose
Bundle.system(HOMEBREW_BREW_FILE, "link", "--force", @name, verbose: verbose)
Bundle.system(HOMEBREW_BREW_FILE, "link", "--force", @name, verbose:)
end
when false
unless unlinked_and_not_keg_only?
puts "Unlinking #{@name} formula." if verbose
Bundle.system(HOMEBREW_BREW_FILE, "unlink", @name, verbose: verbose)
Bundle.system(HOMEBREW_BREW_FILE, "unlink", @name, verbose:)
end
when nil
if unlinked_and_not_keg_only?
puts "Linking #{@name} formula." if verbose
link_args = "link"
link_args << "--overwrite" if force
Bundle.system(HOMEBREW_BREW_FILE, *link_args, @name, verbose: verbose)
Bundle.system(HOMEBREW_BREW_FILE, *link_args, @name, verbose:)
elsif linked_and_keg_only?
puts "Unlinking #{@name} formula." if verbose
Bundle.system(HOMEBREW_BREW_FILE, "unlink", @name, verbose: verbose)
Bundle.system(HOMEBREW_BREW_FILE, "unlink", @name, verbose:)
end
end
end
Expand Down Expand Up @@ -233,11 +233,11 @@ def resolve_conflicts!(verbose:)
It is currently installed and conflicts with #{@name}.
EOS
end
return false unless Bundle.system(HOMEBREW_BREW_FILE, "unlink", conflict, verbose: verbose)
return false unless Bundle.system(HOMEBREW_BREW_FILE, "unlink", conflict, verbose:)

if restart_service?
puts "Stopping #{conflict} service (if it is running)." if verbose
BrewServices.stop(conflict, verbose: verbose)
BrewServices.stop(conflict, verbose:)
end
end

Expand All @@ -249,7 +249,7 @@ def install!(verbose:, force:)
install_args << "--force" << "--overwrite" if force
with_args = " with #{install_args.join(" ")}" if install_args.present?
puts "Installing #{@name} formula#{with_args}. It is not currently installed." if verbose
unless Bundle.system(HOMEBREW_BREW_FILE, "install", "--formula", @full_name, *install_args, verbose: verbose)
unless Bundle.system(HOMEBREW_BREW_FILE, "install", "--formula", @full_name, *install_args, verbose:)
@changed = nil
return false
end
Expand All @@ -264,7 +264,7 @@ def upgrade!(verbose:, force:)
upgrade_args << "--force" if force
with_args = " with #{upgrade_args.join(" ")}" if upgrade_args.present?
puts "Upgrading #{@name} formula#{with_args}. It is installed but not up-to-date." if verbose
unless Bundle.system(HOMEBREW_BREW_FILE, "upgrade", "--formula", @name, *upgrade_args, verbose: verbose)
unless Bundle.system(HOMEBREW_BREW_FILE, "upgrade", "--formula", @name, *upgrade_args, verbose:)
@changed = nil
return false
end
Expand Down
2 changes: 1 addition & 1 deletion lib/bundle/brewfile.rb
Expand Up @@ -28,7 +28,7 @@ def path(dash_writes_to_stdout: false, global: false, file: nil)
end

def read(global: false, file: nil)
Brewfile.path(global: global, file: file).read
Brewfile.path(global:, file:).read
rescue Errno::ENOENT
raise "No Brewfile found"
end
Expand Down
2 changes: 1 addition & 1 deletion lib/bundle/cask_checker.rb
Expand Up @@ -7,7 +7,7 @@ class CaskChecker < Bundle::Checker::Base
PACKAGE_TYPE_NAME = "Cask"

def installed_and_up_to_date?(cask, no_upgrade: false)
Bundle::CaskInstaller.cask_installed_and_up_to_date?(cask, no_upgrade: no_upgrade)
Bundle::CaskInstaller.cask_installed_and_up_to_date?(cask, no_upgrade:)
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/bundle/cask_installer.rb
Expand Up @@ -34,7 +34,7 @@ def install(name, preinstall: true, no_upgrade: false, verbose: false, force: fa
if installed_casks.include?(name) && upgrading?(no_upgrade, name, options)
status = "#{options[:greedy] ? "may not be" : "not"} up-to-date"
puts "Upgrading #{name} cask. It is installed but #{status}." if verbose
return Bundle.system HOMEBREW_BREW_FILE, "upgrade", "--cask", full_name, verbose: verbose
return Bundle.system HOMEBREW_BREW_FILE, "upgrade", "--cask", full_name, verbose:
end

args = options.fetch(:args, []).filter_map do |k, v|
Expand Down
26 changes: 13 additions & 13 deletions lib/bundle/checker.rb
Expand Up @@ -9,7 +9,7 @@ class Base

def exit_early_check(packages, no_upgrade:)
work_to_be_done = packages.find do |pkg|
!installed_and_up_to_date?(pkg, no_upgrade: no_upgrade)
!installed_and_up_to_date?(pkg, no_upgrade:)
end

Array(work_to_be_done)
Expand All @@ -25,8 +25,8 @@ def failure_reason(name, no_upgrade:)
end

def full_check(packages, no_upgrade:)
packages.reject { |pkg| installed_and_up_to_date?(pkg, no_upgrade: no_upgrade) }
.map { |pkg| failure_reason(pkg, no_upgrade: no_upgrade) }
packages.reject { |pkg| installed_and_up_to_date?(pkg, no_upgrade:) }
.map { |pkg| failure_reason(pkg, no_upgrade:) }
end

def checkable_entries(all_entries)
Expand All @@ -46,9 +46,9 @@ def find_actionable(entries, exit_on_first_error: false, no_upgrade: false, verb
requested = format_checkable entries

if exit_on_first_error
exit_early_check(requested, no_upgrade: no_upgrade)
exit_early_check(requested, no_upgrade:)
else
full_check(requested, no_upgrade: no_upgrade)
full_check(requested, no_upgrade:)
end
end
end
Expand All @@ -67,7 +67,7 @@ def find_actionable(entries, exit_on_first_error: false, no_upgrade: false, verb
}.freeze

def check(global: false, file: nil, exit_on_first_error: false, no_upgrade: false, verbose: false)
@dsl ||= Bundle::Dsl.new(Brewfile.read(global: global, file: file))
@dsl ||= Bundle::Dsl.new(Brewfile.read(global:, file:))

check_method_names = CHECKS.keys

Expand All @@ -76,7 +76,7 @@ def check(global: false, file: nil, exit_on_first_error: false, no_upgrade: fals

work_to_be_done = check_method_names.public_send(enumerator) do |check_method|
check_errors =
send(check_method, exit_on_first_error: exit_on_first_error, no_upgrade: no_upgrade, verbose: verbose)
send(check_method, exit_on_first_error:, no_upgrade:, verbose:)
any_errors = check_errors.any?
errors.concat(check_errors) if any_errors
any_errors
Expand All @@ -90,42 +90,42 @@ def check(global: false, file: nil, exit_on_first_error: false, no_upgrade: fals
def casks_to_install(exit_on_first_error: false, no_upgrade: false, verbose: false)
Bundle::Checker::CaskChecker.new.find_actionable(
@dsl.entries,
exit_on_first_error: exit_on_first_error, no_upgrade: no_upgrade, verbose: verbose,
exit_on_first_error:, no_upgrade:, verbose:,
)
end

def formulae_to_install(exit_on_first_error: false, no_upgrade: false, verbose: false)
Bundle::Checker::BrewChecker.new.find_actionable(
@dsl.entries,
exit_on_first_error: exit_on_first_error, no_upgrade: no_upgrade, verbose: verbose,
exit_on_first_error:, no_upgrade:, verbose:,
)
end

def taps_to_tap(exit_on_first_error: false, no_upgrade: false, verbose: false)
Bundle::Checker::TapChecker.new.find_actionable(
@dsl.entries,
exit_on_first_error: exit_on_first_error, no_upgrade: no_upgrade, verbose: verbose,
exit_on_first_error:, no_upgrade:, verbose:,
)
end

def apps_to_install(exit_on_first_error: false, no_upgrade: false, verbose: false)
Bundle::Checker::MacAppStoreChecker.new.find_actionable(
@dsl.entries,
exit_on_first_error: exit_on_first_error, no_upgrade: no_upgrade, verbose: verbose,
exit_on_first_error:, no_upgrade:, verbose:,
)
end

def extensions_to_install(exit_on_first_error: false, no_upgrade: false, verbose: false)
Bundle::Checker::VscodeExtensionChecker.new.find_actionable(
@dsl.entries,
exit_on_first_error: exit_on_first_error, no_upgrade: no_upgrade, verbose: verbose,
exit_on_first_error:, no_upgrade:, verbose:,
)
end

def formulae_to_start(exit_on_first_error: false, no_upgrade: false, verbose: false)
Bundle::Checker::BrewServiceChecker.new.find_actionable(
@dsl.entries,
exit_on_first_error: exit_on_first_error, no_upgrade: no_upgrade, verbose: verbose,
exit_on_first_error:, no_upgrade:, verbose:,
)
end

Expand Down
4 changes: 2 additions & 2 deletions lib/bundle/commands/check.rb
Expand Up @@ -12,8 +12,8 @@ def run(global: false, file: nil, no_upgrade: false, verbose: false)
output_errors = verbose
exit_on_first_error = !verbose
check_result = Bundle::Checker.check(
global: global, file: file,
exit_on_first_error: exit_on_first_error, no_upgrade: no_upgrade, verbose: verbose
global:, file:,
exit_on_first_error:, no_upgrade:, verbose:
)

if check_result.work_to_be_done
Expand Down
18 changes: 9 additions & 9 deletions lib/bundle/commands/cleanup.rb
Expand Up @@ -19,10 +19,10 @@ def reset!
end

def run(global: false, file: nil, force: false, zap: false)
casks = casks_to_uninstall(global: global, file: file)
formulae = formulae_to_uninstall(global: global, file: file)
taps = taps_to_untap(global: global, file: file)
vscode_extensions = vscode_extensions_to_uninstall(global: global, file: file)
casks = casks_to_uninstall(global:, file:)
formulae = formulae_to_uninstall(global:, file:)
taps = taps_to_untap(global:, file:)
vscode_extensions = vscode_extensions_to_uninstall(global:, file:)
if force
if casks.any?
args = zap ? ["--zap"] : []
Expand Down Expand Up @@ -77,11 +77,11 @@ def run(global: false, file: nil, force: false, zap: false)
end

def casks_to_uninstall(global: false, file: nil)
Bundle::CaskDumper.cask_names - kept_casks(global: global, file: file)
Bundle::CaskDumper.cask_names - kept_casks(global:, file:)
end

def formulae_to_uninstall(global: false, file: nil)
@dsl ||= Bundle::Dsl.new(Brewfile.read(global: global, file: file))
@dsl ||= Bundle::Dsl.new(Brewfile.read(global:, file:))
kept_formulae = @dsl.entries.select { |e| e.type == :brew }.map(&:name)
kept_cask_formula_dependencies = Bundle::CaskDumper.formula_dependencies(kept_casks)
kept_formulae += kept_cask_formula_dependencies
Expand All @@ -102,7 +102,7 @@ def formulae_to_uninstall(global: false, file: nil)
def kept_casks(global: false, file: nil)
return @kept_casks if @kept_casks

@dsl ||= Bundle::Dsl.new(Brewfile.read(global: global, file: file))
@dsl ||= Bundle::Dsl.new(Brewfile.read(global:, file:))
@kept_casks = @dsl.entries.select { |e| e.type == :cask }.map(&:name)
end

Expand Down Expand Up @@ -135,14 +135,14 @@ def recursive_dependencies(current_formulae, formulae_names, top_level: true)
IGNORED_TAPS = %w[homebrew/core homebrew/bundle].freeze

def taps_to_untap(global: false, file: nil)
@dsl ||= Bundle::Dsl.new(Brewfile.read(global: global, file: file))
@dsl ||= Bundle::Dsl.new(Brewfile.read(global:, file:))
kept_taps = @dsl.entries.select { |e| e.type == :tap }.map(&:name)
current_taps = Bundle::TapDumper.tap_names
current_taps - kept_taps - IGNORED_TAPS
end

def vscode_extensions_to_uninstall(global: false, file: nil)
@dsl ||= Bundle::Dsl.new(Brewfile.read(global: global, file: file))
@dsl ||= Bundle::Dsl.new(Brewfile.read(global:, file:))
kept_extensions = @dsl.entries.select { |e| e.type == :vscode }.map { |x| x.name.downcase }

# To provide a graceful migration from `Brewfile`s that don't yet or
Expand Down
6 changes: 3 additions & 3 deletions lib/bundle/commands/dump.rb
Expand Up @@ -9,9 +9,9 @@ def run(global: false, file: nil, describe: false, force: false, no_restart: fal
all: false, taps: false, brews: false, casks: false,
mas: false, whalebrew: false, vscode: false)
Bundle::Dumper.dump_brewfile(
global: global, file: file, describe: describe, force: force, no_restart: no_restart,
all: all, taps: taps, brews: brews, casks: casks,
mas: mas, whalebrew: whalebrew, vscode: vscode
global:, file:, describe:, force:, no_restart:,
all:, taps:, brews:, casks:,
mas:, whalebrew:, vscode:
)
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/bundle/commands/exec.rb
Expand Up @@ -25,7 +25,7 @@ def run(*args, global: false, file: nil)
command_path = command_path.dirname.to_s
end

brewfile = Bundle::Dsl.new(Brewfile.read(global: global, file: file))
brewfile = Bundle::Dsl.new(Brewfile.read(global:, file:))

require "formula"
require "formulary"
Expand Down
4 changes: 2 additions & 2 deletions lib/bundle/commands/install.rb
Expand Up @@ -6,10 +6,10 @@ module Install
module_function

def run(global: false, file: nil, no_lock: false, no_upgrade: false, verbose: false, force: false)
parsed_entries = Bundle::Dsl.new(Brewfile.read(global: global, file: file)).entries
parsed_entries = Bundle::Dsl.new(Brewfile.read(global:, file:)).entries
Bundle::Installer.install(
parsed_entries,
global: global, file: file, no_lock: no_lock, no_upgrade: no_upgrade, verbose: verbose, force: force,
global:, file:, no_lock:, no_upgrade:, verbose:, force:,
) || exit(1)
end
end
Expand Down
4 changes: 2 additions & 2 deletions lib/bundle/commands/list.rb
Expand Up @@ -7,10 +7,10 @@ module List

def run(global: false, file: nil, all: false, casks: false, taps: false, mas: false, whalebrew: false,
vscode: false, brews: false)
parsed_entries = Bundle::Dsl.new(Brewfile.read(global: global, file: file)).entries
parsed_entries = Bundle::Dsl.new(Brewfile.read(global:, file:)).entries
Bundle::Lister.list(
parsed_entries,
all: all, casks: casks, taps: taps, mas: mas, whalebrew: whalebrew, vscode: vscode, brews: brews,
all:, casks:, taps:, mas:, whalebrew:, vscode:, brews:,
)
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/bundle/dsl.rb
Expand Up @@ -65,7 +65,7 @@ def mas(name, options = {})
raise "name(#{name.inspect}) should be a String object" unless name.is_a? String
raise "options[:id](#{id}) should be an Integer object" unless id.is_a? Integer

@entries << Entry.new(:mas, name, id: id)
@entries << Entry.new(:mas, name, id:)
end

def whalebrew(name)
Expand Down