From e3f4701f385c286a2cc72c5d07870cc9a6ce0bf4 Mon Sep 17 00:00:00 2001 From: Misty De Meo Date: Sun, 26 Feb 2017 16:49:09 +1100 Subject: [PATCH] audit: fix audit on formulae without homepages --- Library/Homebrew/dev-cmd/audit.rb | 5 +++++ Library/Homebrew/test/audit_test.rb | 11 +++++++++++ 2 files changed, 16 insertions(+) diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb index 35d590b693..a8c18f7b63 100644 --- a/Library/Homebrew/dev-cmd/audit.rb +++ b/Library/Homebrew/dev-cmd/audit.rb @@ -605,6 +605,11 @@ class FormulaAuditor def audit_homepage homepage = formula.homepage + if homepage.nil? || homepage.empty? + problem "Formula should have a homepage." + return + end + unless homepage =~ %r{^https?://} problem "The homepage should start with http or https (URL is #{homepage})." end diff --git a/Library/Homebrew/test/audit_test.rb b/Library/Homebrew/test/audit_test.rb index f4b7cae4a3..66e5af5670 100644 --- a/Library/Homebrew/test/audit_test.rb +++ b/Library/Homebrew/test/audit_test.rb @@ -466,6 +466,17 @@ class FormulaAuditorTests < Homebrew::TestCase end end + def test_audit_without_homepage + fa = formula_auditor "foo", <<-EOS.undent, online: true + class Foo < Formula + url "http://example.com/foo-1.0.tgz" + end + EOS + + fa.audit_homepage + assert_match "Formula should have a homepage.", fa.problems.first + end + def test_audit_xcodebuild_suggests_symroot fa = formula_auditor "foo", <<-EOS.undent class Foo < Formula