You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In #4694 the Lint/UriRegexp cop was introduced, and tests were added for two cases:
Without arguments, e.g. URI.regexp
With a string argument, e.g. URI.regexp('http://example.com')
However, a common argument passed to URI.regexp is an array of schemes to use in the uri matching, e.g.
URI.regexp(%w[http https])
Such usage isn't flagged up by RuboCop, since it appears to me to only check for string arguments.
Also, the existing example for string arguments should be changed, since it is confusing. It only makes sense to pass a schema to URI::DEFAULT_PARSER.make_regexp, e.g. URI::DEFAULT_PARSER.make_regexp('http'), rather than a full url.
Expected behavior
Lint/UriRegexp should warn on the common usecase of URI.regexp(%w[http https])
Actual behavior
Lint/UriRegexp does not warn when using URI.regexp(%w[http https])
Steps to reproduce the problem
$ cat test.rb
# frozen_string_literal: true
URI.regexp
URI.regexp('http')
URI.regexp(%w[http https])
$ bundle exec rubocop
Inspecting 2 files
.W
Offenses:
test.rb:3:5: W: Lint/UriRegexp: URI.regexp is obsolete and should not be used. Instead, use URI::DEFAULT_PARSER.make_regexp.
URI.regexp
^^^^^^
test.rb:4:5: W: Lint/UriRegexp: URI.regexp('http') is obsolete and should not be used. Instead, use URI::DEFAULT_PARSER.make_regexp('http').
URI.regexp('http')
^^^^^^
2 files inspected, 2 offenses detected
It should have detected 3 offenses
RuboCop version
$ bundle exec rubocop -v
0.81.0
The text was updated successfully, but these errors were encountered:
In #4694 the Lint/UriRegexp cop was introduced, and tests were added for two cases:
URI.regexp
URI.regexp('http://example.com')
However, a common argument passed to URI.regexp is an array of schemes to use in the uri matching, e.g.
URI.regexp(%w[http https])
Such usage isn't flagged up by RuboCop, since it appears to me to only check for string arguments.
Also, the existing example for string arguments should be changed, since it is confusing. It only makes sense to pass a schema to
URI::DEFAULT_PARSER.make_regexp
, e.g.URI::DEFAULT_PARSER.make_regexp('http')
, rather than a full url.Expected behavior
Lint/UriRegexp should warn on the common usecase of
URI.regexp(%w[http https])
Actual behavior
Lint/UriRegexp does not warn when using
URI.regexp(%w[http https])
Steps to reproduce the problem
It should have detected 3 offenses
RuboCop version
The text was updated successfully, but these errors were encountered: