class RuboCop::Cop::RSpec::ReturnFromStub::AndReturnCallCorrector
Attributes
arg[R]
node[R]
receiver[R]
Public Class Methods
new(node)
click to toggle source
# File lib/rubocop/cop/rspec/return_from_stub.rb, line 96 def initialize(node) @node = node @receiver = node.receiver @arg = node.first_argument end
Public Instance Methods
call(corrector)
click to toggle source
# File lib/rubocop/cop/rspec/return_from_stub.rb, line 102 def call(corrector) # Heredoc autocorrection is not yet implemented. return if heredoc? corrector.replace(range, " { #{replacement} }") end
Private Instance Methods
hash_without_braces?()
click to toggle source
# File lib/rubocop/cop/rspec/return_from_stub.rb, line 133 def hash_without_braces? arg.hash_type? && !arg.braces? end
heredoc?()
click to toggle source
# File lib/rubocop/cop/rspec/return_from_stub.rb, line 113 def heredoc? arg.loc.is_a?(Parser::Source::Map::Heredoc) end
range()
click to toggle source
# File lib/rubocop/cop/rspec/return_from_stub.rb, line 117 def range Parser::Source::Range.new( node.source_range.source_buffer, receiver.source_range.end_pos, node.source_range.end_pos ) end
replacement()
click to toggle source
# File lib/rubocop/cop/rspec/return_from_stub.rb, line 125 def replacement if hash_without_braces? "{ #{arg.source} }" else arg.source end end