cmd/list: Bump to Sorbet typed: strict

This commit is contained in:
Issy Long 2024-08-10 22:26:32 +01:00
parent 6cc4d6dacb
commit 686b5afa05
No known key found for this signature in database

View File

@ -1,4 +1,4 @@
# typed: true # typed: strict
# frozen_string_literal: true # frozen_string_literal: true
require "abstract_command" require "abstract_command"
@ -160,6 +160,7 @@ module Homebrew
private private
sig { void }
def filtered_list def filtered_list
names = if args.no_named? names = if args.no_named?
Formula.racks Formula.racks
@ -189,6 +190,7 @@ module Homebrew
end end
end end
sig { void }
def list_casks def list_casks
casks = if args.no_named? casks = if args.no_named?
Cask::Caskroom.casks Cask::Caskroom.casks
@ -212,6 +214,7 @@ module Homebrew
end end
class PrettyListing class PrettyListing
sig { params(path: T.any(String, Pathname, Keg)).void }
def initialize(path) def initialize(path)
Pathname.new(path).children.sort_by { |p| p.to_s.downcase }.each do |pn| Pathname.new(path).children.sort_by { |p| p.to_s.downcase }.each do |pn|
case pn.basename.to_s case pn.basename.to_s
@ -240,7 +243,8 @@ module Homebrew
private private
def print_dir(root) sig { params(root: Pathname, block: T.nilable(T.proc.params(arg0: Pathname).returns(T::Boolean))).void }
def print_dir(root, &block)
dirs = [] dirs = []
remaining_root_files = [] remaining_root_files = []
other = "" other = ""
@ -248,7 +252,7 @@ module Homebrew
root.children.sort.each do |pn| root.children.sort.each do |pn|
if pn.directory? if pn.directory?
dirs << pn dirs << pn
elsif block_given? && yield(pn) elsif block && yield(pn)
puts pn puts pn
other = "other " other = "other "
elsif pn.basename.to_s != ".DS_Store" elsif pn.basename.to_s != ".DS_Store"
@ -265,6 +269,7 @@ module Homebrew
print_remaining_files remaining_root_files, root, other print_remaining_files remaining_root_files, root, other
end end
sig { params(files: T::Array[Pathname], root: Pathname, other: String).void }
def print_remaining_files(files, root, other = "") def print_remaining_files(files, root, other = "")
if files.length == 1 if files.length == 1
puts files puts files