Skip to content

Commit 780fbbc

Browse files
authored
Merge pull request #16873 from cho-m/cleaner-types
cleaner: add types
2 parents a30f6c4 + 2d88498 commit 780fbbc

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

Library/Homebrew/cleaner.rb

+8-2
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,13 @@ class Cleaner
1515
include Context
1616

1717
# Create a cleaner for the given formula.
18+
sig { params(formula: Formula).void }
1819
def initialize(formula)
1920
@formula = formula
2021
end
2122

2223
# Clean the keg of the formula.
24+
sig { void }
2325
def clean
2426
ObserverPathnameExtension.reset_counts!
2527

@@ -48,8 +50,7 @@ def clean
4850
# [1]: https://github.com/Homebrew/brew/pull/11597
4951
# [2]: https://github.com/Homebrew/homebrew-core/issues/100190
5052
# [3]: https://github.com/Homebrew/brew/pull/13215
51-
Dir.glob(@formula.info/"**/dir").each do |file|
52-
info_dir_file = Pathname(file)
53+
@formula.info.glob("**/dir").each do |info_dir_file|
5354
next unless info_dir_file.file?
5455
next if info_dir_file == @formula.info/@formula.name/"dir"
5556
next if @formula.skip_clean?(info_dir_file)
@@ -65,13 +66,15 @@ def clean
6566

6667
private
6768

69+
sig { params(path: Pathname).void }
6870
def observe_file_removal(path)
6971
path.extend(ObserverPathnameExtension).unlink if path.exist?
7072
end
7173

7274
# Removes any empty directories in the formula's prefix subtree
7375
# Keeps any empty directories protected by skip_clean
7476
# Removes any unresolved symlinks
77+
sig { void }
7578
def prune
7679
dirs = []
7780
symlinks = []
@@ -100,6 +103,7 @@ def prune
100103
end
101104
end
102105

106+
sig { params(path: Pathname).returns(T::Boolean) }
103107
def executable_path?(path)
104108
path.text_executable? || path.executable?
105109
end
@@ -119,6 +123,7 @@ def executable_path?(path)
119123
#
120124
# lib may have a large directory tree (see Erlang for instance), and
121125
# clean_dir applies cleaning rules to the entire tree
126+
sig { params(directory: Pathname).void }
122127
def clean_dir(directory)
123128
directory.find do |path|
124129
path.extend(ObserverPathnameExtension)
@@ -147,6 +152,7 @@ def clean_dir(directory)
147152
end
148153
end
149154

155+
sig { void }
150156
def rewrite_shebangs
151157
require "language/perl"
152158
require "utils/shebang"

Library/Homebrew/extend/os/linux/cleaner.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
class Cleaner
55
private
66

7-
sig { params(path: Pathname).returns(T.nilable(T::Boolean)) }
7+
sig { params(path: Pathname).returns(T::Boolean) }
88
def executable_path?(path)
99
path.elf? || path.text_executable?
1010
end

Library/Homebrew/extend/os/mac/cleaner.rb

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ class Cleaner
66

77
undef executable_path?
88

9+
sig { params(path: Pathname).returns(T::Boolean) }
910
def executable_path?(path)
1011
path.mach_o_executable? || path.text_executable?
1112
end

0 commit comments

Comments
 (0)