From ca6fc4873e4cb396e9ff650a52853ccd2359ac47 Mon Sep 17 00:00:00 2001 From: Steve Peters Date: Thu, 27 May 2021 17:45:24 -0700 Subject: [PATCH 1/2] audit_spec: expect error for uppercase formula Our docs state that formula filenames must not have uppercase letters. This adds a test to expect that FormulaAuditor's audit_formula_name method complains about such a formula. --- Library/Homebrew/test/dev-cmd/audit_spec.rb | 26 +++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/Library/Homebrew/test/dev-cmd/audit_spec.rb b/Library/Homebrew/test/dev-cmd/audit_spec.rb index 59c041366c..92dcb75377 100644 --- a/Library/Homebrew/test/dev-cmd/audit_spec.rb +++ b/Library/Homebrew/test/dev-cmd/audit_spec.rb @@ -488,6 +488,32 @@ module Homebrew end end + describe "#audit_formula_name" do + specify "no issue" do + fa = formula_auditor "foo", <<~RUBY, core_tap: true, strict: true + class Foo < Formula + url "https://brew.sh/foo-1.0.tgz" + homepage "https://brew.sh" + end + RUBY + + fa.audit_formula_name + expect(fa.problems).to be_empty + end + + specify "uppercase formula name" do + fa = formula_auditor "Foo", <<~RUBY + class Foo < Formula + url "https://brew.sh/Foo-1.0.tgz" + homepage "https://brew.sh" + end + RUBY + + fa.audit_formula_name + expect(fa.problems.first[:message]).to match "must not contain uppercase letters" + end + end + describe "#check_service_command" do specify "Not installed" do fa = formula_auditor "foo", <<~RUBY From 9b9d25d27fb6ab3ce5cb73db2bb383368b1682b7 Mon Sep 17 00:00:00 2001 From: Steve Peters Date: Thu, 27 May 2021 17:55:28 -0700 Subject: [PATCH 2/2] audit: complain about uppercase formula names Check for uppercase formula names in audit_formula_name method of formula_auditor. --- Library/Homebrew/formula_auditor.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Library/Homebrew/formula_auditor.rb b/Library/Homebrew/formula_auditor.rb index e4ff85db0b..5a69bc751c 100644 --- a/Library/Homebrew/formula_auditor.rb +++ b/Library/Homebrew/formula_auditor.rb @@ -120,11 +120,13 @@ module Homebrew end def audit_formula_name + name = formula.name + + problem "Formula name '#{name}' must not contain uppercase letters." if name != name.downcase + return unless @strict return unless @core_tap - name = formula.name - problem "'#{name}' is not allowed in homebrew/core." if MissingFormula.disallowed_reason(name) if Formula.aliases.include? name