rubocops/urls: allow plain HTTP mirrors
This commit is contained in:
parent
d6eb9eca52
commit
629dbb7c59
@ -35,14 +35,14 @@ module RuboCop
|
|||||||
# @param urls [Array] url/mirror method call nodes
|
# @param urls [Array] url/mirror method call nodes
|
||||||
# @param regex [Regexp] pattern to match URLs
|
# @param regex [Regexp] pattern to match URLs
|
||||||
def audit_urls(urls, regex)
|
def audit_urls(urls, regex)
|
||||||
urls.each do |url_node|
|
urls.each_with_index do |url_node, index|
|
||||||
url_string_node = parameters(url_node).first
|
url_string_node = parameters(url_node).first
|
||||||
url_string = string_content(url_string_node)
|
url_string = string_content(url_string_node)
|
||||||
match_object = regex_match_group(url_string_node, regex)
|
match_object = regex_match_group(url_string_node, regex)
|
||||||
next unless match_object
|
next unless match_object
|
||||||
|
|
||||||
offending_node(url_string_node.parent)
|
offending_node(url_string_node.parent)
|
||||||
yield match_object, url_string
|
yield match_object, url_string, index
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -83,8 +83,14 @@ module RuboCop
|
|||||||
%r{^http://(?:[^/]*\.)?archive\.org},
|
%r{^http://(?:[^/]*\.)?archive\.org},
|
||||||
%r{^http://(?:[^/]*\.)?freedesktop\.org},
|
%r{^http://(?:[^/]*\.)?freedesktop\.org},
|
||||||
%r{^http://(?:[^/]*\.)?mirrorservice\.org/}])
|
%r{^http://(?:[^/]*\.)?mirrorservice\.org/}])
|
||||||
audit_urls(urls, http_to_https_patterns) do |_, url|
|
audit_urls(urls, http_to_https_patterns) do |_, url, index|
|
||||||
problem "Please use https:// for #{url}"
|
# It's fine to have a plain HTTP mirror further down the mirror list.
|
||||||
|
https_url = url.dup.insert(4, "s")
|
||||||
|
https_index = nil
|
||||||
|
audit_urls(urls, https_url) do |_, _, found_https_index|
|
||||||
|
https_index = found_https_index
|
||||||
|
end
|
||||||
|
problem "Please use https:// for #{url}" if !https_index || https_index > index
|
||||||
end
|
end
|
||||||
|
|
||||||
apache_mirror_pattern = %r{^https?://(?:[^/]*\.)?apache\.org/dyn/closer\.(?:cgi|lua)\?path=/?(.*)}i
|
apache_mirror_pattern = %r{^https?://(?:[^/]*\.)?apache\.org/dyn/closer\.(?:cgi|lua)\?path=/?(.*)}i
|
||||||
|
Loading…
x
Reference in New Issue
Block a user