class RuboCop::Cop::Performance::LstripRstrip
‘abc’.strip
@good
’abc’.rstrip.lstrip
’abc’.lstrip.rstrip
@bad
@example
`strip`.
This cop identifies places where ‘lstrip.rstrip` can be replaced by
def autocorrect(node)
def autocorrect(node) range = range_between(node.receiver.loc.selector.begin_pos, node.source_range.end_pos) ->(corrector) { corrector.replace(range, 'strip') } end
def on_send(node)
def on_send(node) lstrip_rstrip(node) do |first_send, method_one, method_two| range = range_between(first_send.loc.selector.begin_pos, node.source_range.end_pos) add_offense(node, range, format(MSG, method_one, method_two)) end end