lib/rubocop/cop/rspec/hook_argument.rb in rubocop-rspec-2.18.1 vs lib/rubocop/cop/rspec/hook_argument.rb in rubocop-rspec-2.19.0
- old
+ new
@@ -81,28 +81,37 @@
return check_implicit(method_send) unless scope_name
style_detected(scope_name)
msg = explicit_message(scope_name)
add_offense(method_send, message: msg) do |corrector|
- scope = implicit_style? ? '' : "(#{style.inspect})"
- corrector.replace(argument_range(method_send), scope)
+ autocorrect(corrector, node, method_send)
end
end
end
alias on_numblock on_block
private
+ def autocorrect(corrector, _node, method_send)
+ scope = implicit_style? ? '' : "(#{style.inspect})"
+ corrector.replace(
+ LocationHelp.arguments_with_whitespace(method_send), scope
+ )
+ end
+
def check_implicit(method_send)
style_detected(:implicit)
return if implicit_style?
msg = explicit_message(nil)
add_offense(method_send.loc.selector, message: msg) do |corrector|
scope = "(#{style.inspect})"
- corrector.replace(argument_range(method_send), scope)
+ corrector.replace(
+ LocationHelp.arguments_with_whitespace(method_send),
+ scope
+ )
end
end
def explicit_message(scope)
if implicit_style?
@@ -116,15 +125,9 @@
style.equal?(:implicit)
end
def hook(node, &block)
scoped_hook(node, &block) || unscoped_hook(node, &block)
- end
-
- def argument_range(send_node)
- send_node.loc.selector.end.with(
- end_pos: send_node.loc.expression.end_pos
- )
end
end
end
end
end