diff --git a/Library/Homebrew/rubocops/lines.rb b/Library/Homebrew/rubocops/lines.rb index 369216ff3d..92d02b3b69 100644 --- a/Library/Homebrew/rubocops/lines.rb +++ b/Library/Homebrew/rubocops/lines.rb @@ -64,6 +64,15 @@ module RuboCop problem "Commented-out dependency #{Regexp.last_match(1)}" end + + return if formula_tap != "homebrew-core" + + # Citation and tag comments from third-party taps + audit_comments do |comment| + next if comment !~ /#\s*(cite(?=\s*\w+:)|doi(?=\s*['"])|tag(?=\s*['"]))/ + + problem "Formulae in homebrew/core should not use `#{Regexp.last_match(1)}` comments" + end end end diff --git a/Library/Homebrew/test/rubocops/lines_spec.rb b/Library/Homebrew/test/rubocops/lines_spec.rb index 4620603439..5e10d89f7a 100644 --- a/Library/Homebrew/test/rubocops/lines_spec.rb +++ b/Library/Homebrew/test/rubocops/lines_spec.rb @@ -106,6 +106,21 @@ describe RuboCop::Cop::FormulaAudit::Comments do end RUBY end + + it "citation tags" do + expect_offense(<<~RUBY, "/homebrew-core/") + class Foo < Formula + desc "foo" + url 'https://brew.sh/foo-1.0.tgz' + # cite Howell_2009: + ^^^^^^^^^^^^^^^^^^^ Formulae in homebrew/core should not use `cite` comments + # doi "10.111/222.x" + ^^^^^^^^^^^^^^^^^^^^ Formulae in homebrew/core should not use `doi` comments + # tag "software" + ^^^^^^^^^^^^^^^^ Formulae in homebrew/core should not use `tag` comments + end + RUBY + end end end