Skip to content

Commit e6b9415

Browse files
committed
Bump some leftover RuboCops to Sorbet typed: strict
1 parent 7c21e41 commit e6b9415

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

Library/Homebrew/rubocops/compact_blank.rb

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# typed: true # rubocop:todo Sorbet/StrictSigil
1+
# typed: strict
22
# frozen_string_literal: true
33

44
module RuboCop
@@ -87,12 +87,18 @@ def bad_method?(node)
8787
false
8888
end
8989

90+
sig {
91+
params(arguments: RuboCop::AST::ArgsNode, receiver_in_block: RuboCop::AST::Node).returns(T::Boolean)
92+
}
9093
def use_single_value_block_argument?(arguments, receiver_in_block)
91-
arguments.length == 1 && arguments[0].source == receiver_in_block.source
94+
arguments.length == 1 && arguments.fetch(0).source == receiver_in_block.source
9295
end
9396

97+
sig {
98+
params(arguments: RuboCop::AST::ArgsNode, receiver_in_block: RuboCop::AST::Node).returns(T::Boolean)
99+
}
94100
def use_hash_value_block_argument?(arguments, receiver_in_block)
95-
arguments.length == 2 && arguments[1].source == receiver_in_block.source
101+
arguments.length == 2 && arguments.fetch(1).source == receiver_in_block.source
96102
end
97103

98104
sig { params(node: RuboCop::AST::SendNode).returns(Parser::Source::Range) }

Library/Homebrew/rubocops/shared/desc_helper.rb

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# typed: true # rubocop:todo Sorbet/StrictSigil
1+
# typed: strict
22
# frozen_string_literal: true
33

44
require "rubocops/shared/helper_functions"
@@ -25,7 +25,8 @@ def audit_desc(type, name, desc_call)
2525
return
2626
end
2727

28-
@offensive_node = desc_call
28+
@offensive_node = T.let(desc_call, T.nilable(RuboCop::AST::Node))
29+
@name = T.let(name, T.nilable(String))
2930

3031
desc = T.cast(desc_call, RuboCop::AST::SendNode).first_argument
3132

@@ -84,9 +85,10 @@ def audit_desc(type, name, desc_call)
8485
end
8586

8687
# Auto correct desc problems. `regex_match_group` must be called before this to populate @offense_source_range.
88+
sig { params(message: String).void }
8789
def desc_problem(message)
8890
add_offense(@offensive_source_range, message:) do |corrector|
89-
match_data = @offensive_node.source.match(/\A(?<quote>["'])(?<correction>.*)(?:\k<quote>)\Z/)
91+
match_data = T.must(@offensive_node).source.match(/\A(?<quote>["'])(?<correction>.*)(?:\k<quote>)\Z/)
9092
correction = match_data[:correction]
9193
quote = match_data[:quote]
9294

@@ -112,7 +114,7 @@ def desc_problem(message)
112114

113115
next if correction == match_data[:correction]
114116

115-
corrector.replace(@offensive_node.source_range, "#{quote}#{correction}#{quote}")
117+
corrector.replace(@offensive_node&.source_range, "#{quote}#{correction}#{quote}")
116118
end
117119
end
118120
end

0 commit comments

Comments
 (0)