Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

audit: check versioned formulae for keg_only :versioned_formula #5091

Merged
merged 1 commit into from
Oct 20, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 19 additions & 0 deletions Library/Homebrew/dev-cmd/audit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,25 @@ def audit_keg_only_style
problem "keg_only reason should not end with a period."
end

def audit_versioned_keg_only
return unless formula.versioned_formula?
return unless @core_tap

return if formula.keg_only? && formula.keg_only_reason.reason == :versioned_formula

keg_only_whitelist = %w[
autoconf@2.13
bash-completion@2
gnupg@1.4
lua@5.1
python@2
].freeze

return if keg_only_whitelist.include?(formula.name) || formula.name.start_with?("gcc@")

problem "Versioned formulae should use `keg_only :versioned_formula`"
end

def audit_homepage
homepage = formula.homepage

Expand Down
44 changes: 44 additions & 0 deletions Library/Homebrew/test/dev-cmd/audit_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -600,5 +600,49 @@ class Foo < Formula
expect(fa.problems).to eq([])
end
end

describe "#audit_versioned_keg_only" do
specify "it warns when a versioned formula is not `keg_only`" do
fa = formula_auditor "foo@1.1", <<~RUBY, core_tap: true
class FooAT11 < Formula
url "https://example.com/foo-1.1.tgz"
end
RUBY

fa.audit_versioned_keg_only

expect(fa.problems.first)
.to match("Versioned formulae should use `keg_only :versioned_formula`")
end

specify "it warns when a versioned formula has an incorrect `keg_only` reason" do
fa = formula_auditor "foo@1.1", <<~RUBY, core_tap: true
class FooAT11 < Formula
url "https://example.com/foo-1.1.tgz"

keg_only :provided_by_macos
end
RUBY

fa.audit_versioned_keg_only

expect(fa.problems.first)
.to match("Versioned formulae should use `keg_only :versioned_formula`")
end

specify "it does not warn when a versioned formula has `keg_only :versioned_formula`" do
fa = formula_auditor "foo@1.1", <<~RUBY, core_tap: true
class FooAT11 < Formula
url "https://example.com/foo-1.1.tgz"

keg_only :versioned_formula
end
RUBY

fa.audit_versioned_keg_only

expect(fa.problems).to eq([])
end
end
end
end