class RuboCop::Cop::InternalAffairs::RedundantLocationArgument
Checks for redundant ‘location` argument to `#add_offense`. `location` argument has a default value of `:expression` and this method will automatically use it.
@example
# bad add_offense(node, location: :expression) # good add_offense(node) add_offense(node, location: :selector)
Constants
- MSG
- RESTRICT_ON_SEND
Public Instance Methods
on_send(node)
click to toggle source
# File lib/rubocop/cop/internal_affairs/redundant_location_argument.rb, line 33 def on_send(node) redundant_location_argument(node) do |argument| add_offense(argument) do |corrector| range = offending_range(argument) corrector.remove(range) end end end
Private Instance Methods
offending_range(node)
click to toggle source
# File lib/rubocop/cop/internal_affairs/redundant_location_argument.rb, line 45 def offending_range(node) with_space = range_with_surrounding_space(node.loc.expression) range_with_surrounding_comma(with_space, :left) end