class RuboCop::Cop::Rails::RootPathnameMethods

def build_path_replacement(path, method, args)

def build_path_replacement(path, method, args)
  path_replacement = path.source
  if path.arguments? && !path.parenthesized_call?
    path_replacement[' '] = '('
    path_replacement << ')'
  end
  replacement = "#{path_replacement}.#{method}"
  if args.any?
    formatted_args = args.map { |arg| arg.array_type? ? "*#{arg.source}" : arg.source }
    replacement += "(#{formatted_args.join(', ')})"
  end
  replacement
end