diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb index 678e50e3fe..deec12b9d6 100644 --- a/Library/Homebrew/dev-cmd/audit.rb +++ b/Library/Homebrew/dev-cmd/audit.rb @@ -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 diff --git a/Library/Homebrew/rubocops/urls.rb b/Library/Homebrew/rubocops/urls.rb index 33d471a33a..429f5b8ebd 100644 --- a/Library/Homebrew/rubocops/urls.rb +++ b/Library/Homebrew/rubocops/urls.rb @@ -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) diff --git a/Library/Homebrew/test/rubocops/urls_spec.rb b/Library/Homebrew/test/rubocops/urls_spec.rb index c3a547f435..24c33cf60a 100644 --- a/Library/Homebrew/test/rubocops/urls_spec.rb +++ b/Library/Homebrew/test/rubocops/urls_spec.rb @@ -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, }] }