Bump some leftover RuboCops to Sorbet typed: strict
This commit is contained in:
parent
5f1241b953
commit
a00bd424da
@ -1,4 +1,4 @@
|
|||||||
# typed: true # rubocop:todo Sorbet/StrictSigil
|
# typed: strict
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
module RuboCop
|
module RuboCop
|
||||||
@ -87,12 +87,18 @@ module RuboCop
|
|||||||
false
|
false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
sig {
|
||||||
|
params(arguments: T::Array[RuboCop::AST::Node], receiver_in_block: RuboCop::AST::Node).returns(T::Boolean)
|
||||||
|
}
|
||||||
def use_single_value_block_argument?(arguments, receiver_in_block)
|
def use_single_value_block_argument?(arguments, receiver_in_block)
|
||||||
arguments.length == 1 && arguments[0].source == receiver_in_block.source
|
arguments.length == 1 && arguments[0]&.source == receiver_in_block.source
|
||||||
end
|
end
|
||||||
|
|
||||||
|
sig {
|
||||||
|
params(arguments: T::Array[RuboCop::AST::Node], receiver_in_block: RuboCop::AST::Node).returns(T::Boolean)
|
||||||
|
}
|
||||||
def use_hash_value_block_argument?(arguments, receiver_in_block)
|
def use_hash_value_block_argument?(arguments, receiver_in_block)
|
||||||
arguments.length == 2 && arguments[1].source == receiver_in_block.source
|
arguments.length == 2 && arguments[1]&.source == receiver_in_block.source
|
||||||
end
|
end
|
||||||
|
|
||||||
sig { params(node: RuboCop::AST::SendNode).returns(Parser::Source::Range) }
|
sig { params(node: RuboCop::AST::SendNode).returns(Parser::Source::Range) }
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
# typed: true # rubocop:todo Sorbet/StrictSigil
|
# typed: strict
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require "rubocops/shared/helper_functions"
|
require "rubocops/shared/helper_functions"
|
||||||
@ -25,7 +25,8 @@ module RuboCop
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
@offensive_node = desc_call
|
@offensive_node = T.let(desc_call, T.nilable(RuboCop::AST::Node))
|
||||||
|
@name = T.let(name, T.nilable(String))
|
||||||
|
|
||||||
desc = T.cast(desc_call, RuboCop::AST::SendNode).first_argument
|
desc = T.cast(desc_call, RuboCop::AST::SendNode).first_argument
|
||||||
|
|
||||||
@ -84,9 +85,10 @@ module RuboCop
|
|||||||
end
|
end
|
||||||
|
|
||||||
# Auto correct desc problems. `regex_match_group` must be called before this to populate @offense_source_range.
|
# Auto correct desc problems. `regex_match_group` must be called before this to populate @offense_source_range.
|
||||||
|
sig { params(message: String).void }
|
||||||
def desc_problem(message)
|
def desc_problem(message)
|
||||||
add_offense(@offensive_source_range, message:) do |corrector|
|
add_offense(@offensive_source_range, message:) do |corrector|
|
||||||
match_data = @offensive_node.source.match(/\A(?<quote>["'])(?<correction>.*)(?:\k<quote>)\Z/)
|
match_data = @offensive_node&.source&.match(/\A(?<quote>["'])(?<correction>.*)(?:\k<quote>)\Z/)
|
||||||
correction = match_data[:correction]
|
correction = match_data[:correction]
|
||||||
quote = match_data[:quote]
|
quote = match_data[:quote]
|
||||||
|
|
||||||
@ -112,7 +114,7 @@ module RuboCop
|
|||||||
|
|
||||||
next if correction == match_data[:correction]
|
next if correction == match_data[:correction]
|
||||||
|
|
||||||
corrector.replace(@offensive_node.source_range, "#{quote}#{correction}#{quote}")
|
corrector.replace(@offensive_node&.source_range, "#{quote}#{correction}#{quote}")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user