cask audit: check for sourceforge appcast

This commit is contained in:
commitay 2018-06-05 16:42:15 +10:00
parent 7d2530016a
commit f012b5acf8
3 changed files with 44 additions and 2 deletions

View File

@ -34,7 +34,7 @@ module Hbc
check_single_pre_postflight
check_single_uninstall_zap
check_untrusted_pkg
check_github_releases_appcast
check_hosting_with_appcast
check_latest_with_appcast
check_stanza_requires_uninstall
self
@ -246,13 +246,25 @@ module Hbc
add_warning "Casks with an appcast should not use version :latest"
end
def check_github_releases_appcast
def check_hosting_with_appcast
return if cask.appcast
check_github_releases_appcast
check_sourceforge_appcast
end
def check_github_releases_appcast
return unless cask.url.to_s =~ %r{github.com/([^/]+)/([^/]+)/releases/download/(\S+)}
add_warning "Cask uses GitHub releases, please add an appcast. See https://github.com/Homebrew/homebrew-cask/blob/master/doc/cask_language_reference/stanzas/appcast.md"
end
def check_sourceforge_appcast
return if cask.version.latest?
return unless cask.url.to_s =~ %r{sourceforge.net/(\S+)}
add_warning "Cask hosted on SourceForge, please add an appcast. See https://github.com/Homebrew/homebrew-cask/blob/master/doc/cask_language_reference/stanzas/appcast.md"
end
def check_url
return unless cask.url
check_download_url_format

View File

@ -460,6 +460,28 @@ describe Hbc::Audit, :cask do
end
end
describe "SourceForge appcast check" do
let(:error_msg) { /Cask hosted on SourceForge/ }
context "when the Cask is not hosted on SourceForge" do
let(:cask_token) { "basic-cask" }
it { is_expected.not_to warn_with(error_msg) }
end
context "when the Cask is hosted on SourceForge and has an appcast" do
let(:cask_token) { "sourceforge-with-appcast" }
it { is_expected.not_to warn_with(error_msg) }
end
context "when the Cask is hosted on SourceForge and does not have an appcast" do
let(:cask_token) { "sourceforge-correct-url-format" }
it { is_expected.to warn_with(error_msg) }
end
end
describe "latest with appcast checks" do
let(:error_msg) { "Casks with an appcast should not use version :latest" }

View File

@ -0,0 +1,8 @@
cask 'sourceforge-with-appcast' do
version '1.2.3'
url 'https://downloads.sourceforge.net/something/Something-1.2.3.dmg'
appcast 'https://sourceforge.net/projects/something/rss',
checkpoint: '407fb59baa4b9eb7651d9243b89c30b7481590947ef78bd5a4c24f5810f56531'
homepage 'https://sourceforge.net/projects/something/'
end