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
This commit is contained in:
		
						commit
						bb44b71647
					
				@ -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,
 | 
			
		||||
    }]
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user