Merge pull request #4457 from commitay/latest-autoupdate

cask audit: check for `latest` with `auto_updates`
This commit is contained in:
Vítor Galvão 2018-07-14 14:29:19 +01:00 committed by GitHub
commit 3742cf892c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 47 additions and 0 deletions

View File

@ -36,6 +36,7 @@ module Hbc
check_untrusted_pkg check_untrusted_pkg
check_hosting_with_appcast check_hosting_with_appcast
check_latest_with_appcast check_latest_with_appcast
check_latest_with_auto_updates
check_stanza_requires_uninstall check_stanza_requires_uninstall
self self
rescue StandardError => e rescue StandardError => e
@ -199,6 +200,13 @@ module Hbc
add_warning "Casks with an appcast should not use version :latest" add_warning "Casks with an appcast should not use version :latest"
end end
def check_latest_with_auto_updates
return unless cask.version.latest?
return unless cask.auto_updates
add_warning "Casks with `version :latest` should not use `auto_updates`"
end
def check_hosting_with_appcast def check_hosting_with_appcast
return if cask.appcast return if cask.appcast

View File

@ -413,6 +413,34 @@ describe Hbc::Audit, :cask do
end end
end end
describe "latest with auto_updates checks" do
let(:warning_msg) { "Casks with `version :latest` should not use `auto_updates`" }
context "when the Cask is :latest and does not have auto_updates" do
let(:cask_token) { "version-latest" }
it { is_expected.not_to warn_with(warning_msg) }
end
context "when the Cask is versioned and does not have auto_updates" do
let(:cask_token) { "basic-cask" }
it { is_expected.not_to warn_with(warning_msg) }
end
context "when the Cask is versioned and has auto_updates" do
let(:cask_token) { "auto-updates" }
it { is_expected.not_to warn_with(warning_msg) }
end
context "when the Cask is :latest and has auto_updates" do
let(:cask_token) { "latest-with-auto-updates" }
it { is_expected.to warn_with(warning_msg) }
end
end
describe "preferred download URL formats" do describe "preferred download URL formats" do
let(:warning_msg) { /URL format incorrect/ } let(:warning_msg) { /URL format incorrect/ }

View File

@ -0,0 +1,11 @@
cask 'latest-with-auto-updates' do
version :latest
sha256 :no_check
url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip"
homepage 'http://example.com/latest-with-auto-updates'
auto_updates true
app 'Caffeine.app'
end