Merge pull request #8285 from reitermarkus/desc-audit
Ensure new casks have a description.
This commit is contained in:
commit
deea71b1d0
@ -13,7 +13,7 @@ module Cask
|
|||||||
|
|
||||||
attr_reader :cask, :commit_range, :download
|
attr_reader :cask, :commit_range, :download
|
||||||
|
|
||||||
attr_predicate :appcast?
|
attr_predicate :appcast?, :new_cask?, :strict?, :online?
|
||||||
|
|
||||||
def initialize(cask, appcast: false, download: false, quarantine: nil,
|
def initialize(cask, appcast: false, download: false, quarantine: nil,
|
||||||
token_conflicts: false, online: false, strict: false,
|
token_conflicts: false, online: false, strict: false,
|
||||||
@ -34,6 +34,7 @@ module Cask
|
|||||||
check_required_stanzas
|
check_required_stanzas
|
||||||
check_version
|
check_version
|
||||||
check_sha256
|
check_sha256
|
||||||
|
check_desc
|
||||||
check_url
|
check_url
|
||||||
check_generic_artifacts
|
check_generic_artifacts
|
||||||
check_token_valid
|
check_token_valid
|
||||||
@ -279,6 +280,14 @@ module Cask
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def check_desc
|
||||||
|
return unless new_cask?
|
||||||
|
|
||||||
|
return if cask.desc.present?
|
||||||
|
|
||||||
|
add_warning "Cask should have a description. Please add a `desc` stanza."
|
||||||
|
end
|
||||||
|
|
||||||
def check_url
|
def check_url
|
||||||
return unless cask.url
|
return unless cask.url
|
||||||
|
|
||||||
@ -339,7 +348,7 @@ module Cask
|
|||||||
end
|
end
|
||||||
|
|
||||||
def check_token_valid
|
def check_token_valid
|
||||||
return unless @strict
|
return unless strict?
|
||||||
|
|
||||||
add_warning "cask token is not lowercase" if cask.token.downcase!
|
add_warning "cask token is not lowercase" if cask.token.downcase!
|
||||||
|
|
||||||
@ -365,7 +374,7 @@ module Cask
|
|||||||
end
|
end
|
||||||
|
|
||||||
def check_token_bad_words
|
def check_token_bad_words
|
||||||
return unless @strict
|
return unless strict?
|
||||||
|
|
||||||
token = cask.token
|
token = cask.token
|
||||||
|
|
||||||
@ -467,8 +476,8 @@ module Cask
|
|||||||
end
|
end
|
||||||
|
|
||||||
def get_repo_data(regex)
|
def get_repo_data(regex)
|
||||||
return unless @online
|
return unless online?
|
||||||
return unless @new_cask
|
return unless new_cask?
|
||||||
|
|
||||||
_, user, repo = *regex.match(cask.url.to_s)
|
_, user, repo = *regex.match(cask.url.to_s)
|
||||||
_, user, repo = *regex.match(cask.homepage) unless user
|
_, user, repo = *regex.match(cask.homepage) unless user
|
||||||
|
@ -33,12 +33,14 @@ describe Cask::Audit, :cask do
|
|||||||
let(:download) { false }
|
let(:download) { false }
|
||||||
let(:token_conflicts) { false }
|
let(:token_conflicts) { false }
|
||||||
let(:strict) { false }
|
let(:strict) { false }
|
||||||
|
let(:new_cask) { false }
|
||||||
let(:fake_system_command) { class_double(SystemCommand) }
|
let(:fake_system_command) { class_double(SystemCommand) }
|
||||||
let(:audit) {
|
let(:audit) {
|
||||||
described_class.new(cask, download: download,
|
described_class.new(cask, download: download,
|
||||||
token_conflicts: token_conflicts,
|
token_conflicts: token_conflicts,
|
||||||
command: fake_system_command,
|
command: fake_system_command,
|
||||||
strict: strict)
|
strict: strict,
|
||||||
|
new_cask: new_cask)
|
||||||
}
|
}
|
||||||
|
|
||||||
describe "#result" do
|
describe "#result" do
|
||||||
@ -790,5 +792,58 @@ describe Cask::Audit, :cask do
|
|||||||
expect(subject).to fail_with(/exception while auditing/)
|
expect(subject).to fail_with(/exception while auditing/)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe "without description" do
|
||||||
|
let(:cask_token) { "without-description" }
|
||||||
|
let(:cask) do
|
||||||
|
tmp_cask cask_token.to_s, <<~RUBY
|
||||||
|
cask '#{cask_token}' do
|
||||||
|
version '1.0'
|
||||||
|
sha256 '8dd95daa037ac02455435446ec7bc737b34567afe9156af7d20b2a83805c1d8a'
|
||||||
|
url "https://brew.sh/"
|
||||||
|
name 'Audit'
|
||||||
|
homepage 'https://brew.sh/'
|
||||||
|
app 'Audit.app'
|
||||||
|
end
|
||||||
|
RUBY
|
||||||
|
end
|
||||||
|
|
||||||
|
context "when `new_cask` is true" do
|
||||||
|
let(:new_cask) { true }
|
||||||
|
|
||||||
|
it "warns" do
|
||||||
|
expect(subject).to warn_with(/should have a description/)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context "when `new_cask` is true" do
|
||||||
|
let(:new_cask) { false }
|
||||||
|
|
||||||
|
it "does not warn" do
|
||||||
|
expect(subject).not_to warn_with(/should have a description/)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context "with description" do
|
||||||
|
let(:cask_token) { "with-description" }
|
||||||
|
let(:cask) do
|
||||||
|
tmp_cask cask_token.to_s, <<~RUBY
|
||||||
|
cask '#{cask_token}' do
|
||||||
|
version '1.0'
|
||||||
|
sha256 '8dd95daa037ac02455435446ec7bc737b34567afe9156af7d20b2a83805c1d8a'
|
||||||
|
url "https://brew.sh/"
|
||||||
|
name 'Audit'
|
||||||
|
desc 'Cask Auditor'
|
||||||
|
homepage 'https://brew.sh/'
|
||||||
|
app 'Audit.app'
|
||||||
|
end
|
||||||
|
RUBY
|
||||||
|
end
|
||||||
|
|
||||||
|
it "does not warn" do
|
||||||
|
expect(subject).not_to warn_with(/should have a description/)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user