diff --git a/Library/Homebrew/bundle/brew_checker.rb b/Library/Homebrew/bundle/brew_checker.rb index 3697ccc271..2270a119f7 100644 --- a/Library/Homebrew/bundle/brew_checker.rb +++ b/Library/Homebrew/bundle/brew_checker.rb @@ -1,4 +1,4 @@ -# typed: true # rubocop:todo Sorbet/StrictSigil +# typed: strict # frozen_string_literal: true require "bundle/formula_installer" @@ -10,6 +10,7 @@ module Homebrew PACKAGE_TYPE = :brew PACKAGE_TYPE_NAME = "Formula" + sig { params(formula: String, no_upgrade: T::Boolean).returns(T::Boolean) } def installed_and_up_to_date?(formula, no_upgrade: false) Homebrew::Bundle::FormulaInstaller.formula_installed_and_up_to_date?(formula, no_upgrade:) end diff --git a/Library/Homebrew/bundle/cask_checker.rb b/Library/Homebrew/bundle/cask_checker.rb index ed715daf1c..34d6b82407 100644 --- a/Library/Homebrew/bundle/cask_checker.rb +++ b/Library/Homebrew/bundle/cask_checker.rb @@ -1,4 +1,4 @@ -# typed: true # rubocop:todo Sorbet/StrictSigil +# typed: strict # frozen_string_literal: true require "bundle/cask_installer" @@ -10,6 +10,7 @@ module Homebrew PACKAGE_TYPE = :cask PACKAGE_TYPE_NAME = "Cask" + sig { params(cask: String, no_upgrade: T::Boolean).returns(T::Boolean) } def installed_and_up_to_date?(cask, no_upgrade: false) Homebrew::Bundle::CaskInstaller.cask_installed_and_up_to_date?(cask, no_upgrade:) end diff --git a/Library/Homebrew/bundle/commands/dump.rb b/Library/Homebrew/bundle/commands/dump.rb index 98e943a9ca..2a6628f060 100644 --- a/Library/Homebrew/bundle/commands/dump.rb +++ b/Library/Homebrew/bundle/commands/dump.rb @@ -1,4 +1,4 @@ -# typed: true # rubocop:todo Sorbet/StrictSigil +# typed: strict # frozen_string_literal: true require "bundle/dumper" @@ -7,6 +7,11 @@ module Homebrew module Bundle module Commands module Dump + sig { + params(global: T::Boolean, file: T.nilable(String), describe: T::Boolean, force: T::Boolean, + no_restart: T::Boolean, taps: T::Boolean, formulae: T::Boolean, casks: T::Boolean, + mas: T::Boolean, whalebrew: T::Boolean, vscode: T::Boolean).void + } def self.run(global:, file:, describe:, force:, no_restart:, taps:, formulae:, casks:, mas:, whalebrew:, vscode:) Homebrew::Bundle::Dumper.dump_brewfile( diff --git a/Library/Homebrew/bundle/commands/list.rb b/Library/Homebrew/bundle/commands/list.rb index 595a698ec0..795d25df6f 100644 --- a/Library/Homebrew/bundle/commands/list.rb +++ b/Library/Homebrew/bundle/commands/list.rb @@ -1,4 +1,4 @@ -# typed: true # rubocop:todo Sorbet/StrictSigil +# typed: strict # frozen_string_literal: true require "bundle/brewfile" @@ -8,6 +8,10 @@ module Homebrew module Bundle module Commands module List + sig { + params(global: T::Boolean, file: T.nilable(String), formulae: T::Boolean, casks: T::Boolean, + taps: T::Boolean, mas: T::Boolean, whalebrew: T::Boolean, vscode: T::Boolean).void + } def self.run(global:, file:, formulae:, casks:, taps:, mas:, whalebrew:, vscode:) parsed_entries = Brewfile.read(global:, file:).entries Homebrew::Bundle::Lister.list( diff --git a/Library/Homebrew/bundle/commands/remove.rb b/Library/Homebrew/bundle/commands/remove.rb index 844ef39d90..a3d9bf9851 100644 --- a/Library/Homebrew/bundle/commands/remove.rb +++ b/Library/Homebrew/bundle/commands/remove.rb @@ -1,4 +1,4 @@ -# typed: true # rubocop:todo Sorbet/StrictSigil +# typed: strict # frozen_string_literal: true require "bundle/remover" @@ -7,6 +7,7 @@ module Homebrew module Bundle module Commands module Remove + sig { params(args: T.anything, type: Symbol, global: T::Boolean, file: T.nilable(String)).void } def self.run(*args, type:, global:, file:) Homebrew::Bundle::Remover.remove(*args, type:, global:, file:) end diff --git a/Library/Homebrew/bundle/lister.rb b/Library/Homebrew/bundle/lister.rb index a813ac6cf5..d270d1e0eb 100644 --- a/Library/Homebrew/bundle/lister.rb +++ b/Library/Homebrew/bundle/lister.rb @@ -1,15 +1,23 @@ -# typed: true # rubocop:todo Sorbet/StrictSigil +# typed: strict # frozen_string_literal: true module Homebrew module Bundle module Lister + sig { + params(entries: T::Array[Homebrew::Bundle::Dsl::Entry], formulae: T::Boolean, casks: T::Boolean, + taps: T::Boolean, mas: T::Boolean, whalebrew: T::Boolean, vscode: T::Boolean).void + } def self.list(entries, formulae:, casks:, taps:, mas:, whalebrew:, vscode:) entries.each do |entry| puts entry.name if show?(entry.type, formulae:, casks:, taps:, mas:, whalebrew:, vscode:) end end + sig { + params(type: Symbol, formulae: T::Boolean, casks: T::Boolean, taps: T::Boolean, mas: T::Boolean, + whalebrew: T::Boolean, vscode: T::Boolean).returns(T::Boolean) + } private_class_method def self.show?(type, formulae:, casks:, taps:, mas:, whalebrew:, vscode:) return true if formulae && type == :brew return true if casks && type == :cask diff --git a/Library/Homebrew/bundle/tap_checker.rb b/Library/Homebrew/bundle/tap_checker.rb index c36fb52e33..3919616425 100644 --- a/Library/Homebrew/bundle/tap_checker.rb +++ b/Library/Homebrew/bundle/tap_checker.rb @@ -1,4 +1,4 @@ -# typed: true # rubocop:todo Sorbet/StrictSigil +# typed: strict # frozen_string_literal: true module Homebrew @@ -8,6 +8,10 @@ module Homebrew PACKAGE_TYPE = :tap PACKAGE_TYPE_NAME = "Tap" + sig { + params(entries: T::Array[Homebrew::Bundle::Dsl::Entry], exit_on_first_error: T::Boolean, + no_upgrade: T::Boolean, verbose: T::Boolean).returns(T::Array[String]) + } def find_actionable(entries, exit_on_first_error: false, no_upgrade: false, verbose: false) requested_taps = format_checkable(entries) return [] if requested_taps.empty? diff --git a/Library/Homebrew/bundle/vscode_extension_checker.rb b/Library/Homebrew/bundle/vscode_extension_checker.rb index 44cfa6dca3..2106dca5e7 100644 --- a/Library/Homebrew/bundle/vscode_extension_checker.rb +++ b/Library/Homebrew/bundle/vscode_extension_checker.rb @@ -1,4 +1,4 @@ -# typed: true # rubocop:todo Sorbet/StrictSigil +# typed: strict # frozen_string_literal: true module Homebrew @@ -8,10 +8,12 @@ module Homebrew PACKAGE_TYPE = :vscode PACKAGE_TYPE_NAME = "VSCode Extension" + sig { params(extension: String, no_upgrade: T::Boolean).returns(String) } def failure_reason(extension, no_upgrade:) "#{PACKAGE_TYPE_NAME} #{extension} needs to be installed." end + sig { params(extension: String, no_upgrade: T::Boolean).returns(T::Boolean) } def installed_and_up_to_date?(extension, no_upgrade: false) require "bundle/vscode_extension_installer" Homebrew::Bundle::VscodeExtensionInstaller.extension_installed?(extension) diff --git a/Library/Homebrew/cask/artifact/zap.rb b/Library/Homebrew/cask/artifact/zap.rb index 0da02e1985..8773bb367a 100644 --- a/Library/Homebrew/cask/artifact/zap.rb +++ b/Library/Homebrew/cask/artifact/zap.rb @@ -1,4 +1,4 @@ -# typed: true # rubocop:todo Sorbet/StrictSigil +# typed: strict # frozen_string_literal: true require "cask/artifact/abstract_uninstall" @@ -7,6 +7,7 @@ module Cask module Artifact # Artifact corresponding to the `zap` stanza. class Zap < AbstractUninstall + sig { params(options: T.anything).void } def zap_phase(**options) dispatch_uninstall_directives(**options) end diff --git a/Library/Homebrew/pour_bottle_check.rb b/Library/Homebrew/pour_bottle_check.rb index 3ec8bb8a2d..40e627b75f 100644 --- a/Library/Homebrew/pour_bottle_check.rb +++ b/Library/Homebrew/pour_bottle_check.rb @@ -1,17 +1,20 @@ -# typed: true # rubocop:todo Sorbet/StrictSigil +# typed: strict # frozen_string_literal: true class PourBottleCheck include OnSystem::MacOSAndLinux + sig { params(formula: T.class_of(Formula)).void } def initialize(formula) @formula = formula end + sig { params(reason: String).void } def reason(reason) @formula.pour_bottle_check_unsatisfied_reason = reason end + sig { params(block: T.proc.void).void } def satisfy(&block) @formula.send(:define_method, :pour_bottle?, &block) end diff --git a/Library/Homebrew/test/bundle/commands/list_spec.rb b/Library/Homebrew/test/bundle/commands/list_spec.rb index c92d42de11..eb59d5bdbb 100644 --- a/Library/Homebrew/test/bundle/commands/list_spec.rb +++ b/Library/Homebrew/test/bundle/commands/list_spec.rb @@ -58,12 +58,12 @@ RSpec.describe Homebrew::Bundle::Commands::List do verb = (options_list.length == 1 && "is") || "are" context "when #{opts} #{verb} passed" do - let(:formulae) { args_hash[:formulae] } - let(:casks) { args_hash[:casks] } - let(:taps) { args_hash[:taps] } - let(:mas) { args_hash[:mas] } - let(:whalebrew) { args_hash[:whalebrew] } - let(:vscode) { args_hash[:vscode] } + let(:formulae) { args_hash.fetch(:formulae, false) } + let(:casks) { args_hash.fetch(:casks, false) } + let(:taps) { args_hash.fetch(:taps, false) } + let(:mas) { args_hash.fetch(:mas, false) } + let(:whalebrew) { args_hash.fetch(:whalebrew, false) } + let(:vscode) { args_hash.fetch(:vscode, false) } it "shows only #{words}" do expected = options_list.map { |opt| types_and_deps[opt] }.join("\n")