class RuboCop::Cop::Rails::MultipleRoutePaths


get ‘/other_path’, to: ‘users#index’
get ‘/users’, to: ‘users#index’
# good
get ‘/users’, ‘/other_path’, to: ‘users#index’
# bad
@example
Checks for mapping a route with multiple paths, which is deprecated and will be removed in Rails 8.1.

def migrate_to_multiple_routes(node, route_paths)

def migrate_to_multiple_routes(node, route_paths)
  rest = route_paths.last.source_range.end.join(node.source_range.end).source
  indentation = ' ' * node.source_range.column
  route_paths.map do |route_path|
    "#{node.method_name} #{route_path.source}#{rest}"
  end.join("\n#{indentation}")
end

def on_send(node)

def on_send(node)
  return unless within_routes?(node)
  route_paths = node.arguments.reject { |argument| IGNORED_ARGUMENT_TYPES.include?(argument.type) }
  return if route_paths.count < 2
  add_offense(node) do |corrector|
    corrector.replace(node, migrate_to_multiple_routes(node, route_paths))
  end
end