class RuboCop::Cop::Lint::UriRegexp
URI::DEFAULT_PARSER.make_regexp(‘example.com’)
# good
URI.regexp(‘example.com’)
# bad
@example
not be used. Instead, use ‘URI::DEFAULT_PARSER.make_regexp`.
Identifies places where `URI.regexp` is obsolete and should
def on_send(node)
def on_send(node) return unless node.receiver return unless URI_CONSTANTS.include?(node.receiver.source) argument = node.first_argument ? "(#{node.first_argument.source})" : '' preferred_method = "#{node.receiver.source}::DEFAULT_PARSER.make_regexp#{argument}" message = format(MSG, current: node.source, preferred: preferred_method) add_offense(node.loc.selector, message: message) do |corrector| corrector.replace(node, preferred_method) end end