Add link to pypi downloads page to problem message
This commit is contained in:
		
							parent
							
								
									5f3f7d010b
								
							
						
					
					
						commit
						70dfaf3b42
					
				@ -292,16 +292,22 @@ module RuboCop
 | 
			
		||||
 | 
			
		||||
          # Check pypi urls
 | 
			
		||||
          pypi_pattern = %r{^https?://pypi.python.org/}
 | 
			
		||||
          audit_urls(urls, pypi_pattern) do
 | 
			
		||||
            problem "use the `files.pythonhosted.org` url found on the pypi downloads page"
 | 
			
		||||
          audit_urls(urls, pypi_pattern) do |_, url|
 | 
			
		||||
            problem "use the `Source` url found on PyPI downloads page (`#{get_pypi_url(url)}`)"
 | 
			
		||||
          end
 | 
			
		||||
 | 
			
		||||
          # Require long files.pythonhosted.org urls
 | 
			
		||||
          pythonhosted_pattern = %r{^https?://files.pythonhosted.org/packages/source/}
 | 
			
		||||
          audit_urls(urls, pythonhosted_pattern) do
 | 
			
		||||
            problem "use the url found on the pypi downloads page"
 | 
			
		||||
          audit_urls(urls, pythonhosted_pattern) do |_, url|
 | 
			
		||||
            problem "use the `Source` url found on PyPI downloads page (`#{get_pypi_url(url)}`)"
 | 
			
		||||
          end
 | 
			
		||||
        end
 | 
			
		||||
 | 
			
		||||
        def get_pypi_url(url)
 | 
			
		||||
          package_file = File.basename(url)
 | 
			
		||||
          package_name = package_file.match(/^(.+)-[a-z0-9.]+$/)[1]
 | 
			
		||||
          "https://pypi.org/project/#{package_name}/#files"
 | 
			
		||||
        end
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
@ -251,7 +251,7 @@ describe RuboCop::Cop::FormulaAudit::PyPiUrls do
 | 
			
		||||
        class Foo < Formula
 | 
			
		||||
          desc "foo"
 | 
			
		||||
          url "https://pypi.python.org/packages/source/foo/foo-0.1.tar.gz"
 | 
			
		||||
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ use the `files.pythonhosted.org` url found on the pypi downloads page
 | 
			
		||||
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ use the `Source` url found on PyPI downloads page (`https://pypi.org/project/foo/#files`)
 | 
			
		||||
        end
 | 
			
		||||
      RUBY
 | 
			
		||||
    end
 | 
			
		||||
@ -261,7 +261,7 @@ describe RuboCop::Cop::FormulaAudit::PyPiUrls do
 | 
			
		||||
        class Foo < Formula
 | 
			
		||||
          desc "foo"
 | 
			
		||||
          url "https://files.pythonhosted.org/packages/source/f/foo/foo-0.1.tar.gz"
 | 
			
		||||
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ use the url found on the pypi downloads page
 | 
			
		||||
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ use the `Source` url found on PyPI downloads page (`https://pypi.org/project/foo/#files`)
 | 
			
		||||
        end
 | 
			
		||||
      RUBY
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user