Skip to content
Snippets Groups Projects
Unverified Commit bb44b716 authored by Mike McQuaid's avatar Mike McQuaid Committed by GitHub
Browse files

Merge pull request #7619 from mathaeus/migrate_vcs_scheme_checks_to_rubocop

audit: Migrate scheme checks for `cvs`, `bzr`, `hg`, `fossil` and `svn+http` to `Rubocop` + add tests
parents dc0346a7 bb9665ce
No related branches found
No related tags found
No related merge requests found
......@@ -1052,11 +1052,6 @@ module Homebrew
end
def audit_download_strategy
if url =~ %r{^(cvs|bzr|hg|fossil)://} || url =~ %r{^(svn)\+http://}
# TODO: check could be in RuboCop
problem "Use of the #{$&} scheme is deprecated, pass `:using => :#{Regexp.last_match(1)}` instead"
end
url_strategy = DownloadStrategyDetector.detect(url)
if using == :git || url_strategy == GitDownloadStrategy
......
......@@ -66,6 +66,16 @@ module RuboCop
problem "#{url} should be `https://www.apache.org/dyn/closer.lua?path=#{match[1]}`"
end
version_control_pattern = %r{^(cvs|bzr|hg|fossil)://}
audit_urls(urls, version_control_pattern) do |match, _|
problem "Use of the #{match[1]}:// scheme is deprecated, pass `:using => :#{match[1]}` instead"
end
svn_pattern = %r{^svn\+http://}
audit_urls(urls, svn_pattern) do |_, _|
problem "Use of the svn+http:// scheme is deprecated, pass `:using => :svn` instead"
end
audit_urls(mirrors, /.*/) do |_, mirror|
urls.each do |url|
url_string = string_content(parameters(url).first)
......
......@@ -159,6 +159,26 @@ describe RuboCop::Cop::FormulaAudit::Urls do
"not a source archive; homebrew/core is source-only.",
"col" => 2,
"formula_tap" => "homebrew-core",
}, {
"url" => "cvs://brew.sh/foo/bar",
"msg" => "Use of the cvs:// scheme is deprecated, pass `:using => :cvs` instead",
"col" => 2,
}, {
"url" => "bzr://brew.sh/foo/bar",
"msg" => "Use of the bzr:// scheme is deprecated, pass `:using => :bzr` instead",
"col" => 2,
}, {
"url" => "hg://brew.sh/foo/bar",
"msg" => "Use of the hg:// scheme is deprecated, pass `:using => :hg` instead",
"col" => 2,
}, {
"url" => "fossil://brew.sh/foo/bar",
"msg" => "Use of the fossil:// scheme is deprecated, pass `:using => :fossil` instead",
"col" => 2,
}, {
"url" => "svn+http://brew.sh/foo/bar",
"msg" => "Use of the svn+http:// scheme is deprecated, pass `:using => :svn` instead",
"col" => 2,
}]
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment