Skip to content

Commit 82c2e74

Browse files
authored
Merge pull request #17228 from Homebrew/replace-formula-text-audits-with-rubocops
Replace `FormulaTextAuditor` usage
2 parents 80b35e8 + 9f915a6 commit 82c2e74

File tree

5 files changed

+11
-97
lines changed

5 files changed

+11
-97
lines changed

Library/Homebrew/formula_auditor.rb

+1-12
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
# frozen_string_literal: true
33

44
require "deprecate_disable"
5-
require "formula_text_auditor"
65
require "formula_versions"
76
require "resource_auditor"
87
require "utils/shared_audits"
@@ -32,7 +31,7 @@ def initialize(formula, options = {})
3231
@core_tap = formula.tap&.core_tap? || options[:core_tap]
3332
@problems = []
3433
@new_formula_problems = []
35-
@text = FormulaTextAuditor.new(formula.path)
34+
@text = formula.path.open("rb", &:read)
3635
@specs = %w[stable head].filter_map { |s| formula.send(s) }
3736
@spdx_license_data = options[:spdx_license_data]
3837
@spdx_exception_data = options[:spdx_exception_data]
@@ -510,16 +509,6 @@ def audit_relicensed_formulae
510509
"It must not be upgraded to version #{relicensed_version} or newer."
511510
end
512511

513-
def audit_keg_only_reason
514-
return unless @core_tap
515-
return unless formula.keg_only?
516-
517-
keg_only_message = text.to_s.match(/keg_only\s+["'](.*)["']/)&.captures&.first
518-
return unless keg_only_message&.include?("HOMEBREW_PREFIX")
519-
520-
problem "`keg_only` reason should not include `HOMEBREW_PREFIX` as it creates confusing `brew info` output."
521-
end
522-
523512
def audit_versioned_keg_only
524513
return unless @versioned_formula
525514
return unless @core_tap

Library/Homebrew/formula_text_auditor.rb

-43
This file was deleted.

Library/Homebrew/rubocops/text.rb

+9-2
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,15 @@ def audit_formula(node, _class_node, _parent_class_node, body_node)
3030
problem "Formulae should not depend on both OpenSSL and LibreSSL (even optionally)."
3131
end
3232

33-
if formula_tap == "homebrew-core" && (depends_on?("veclibfort") || depends_on?("lapack"))
34-
problem "Formulae in homebrew/core should use OpenBLAS as the default serial linear algebra library."
33+
if formula_tap == "homebrew-core"
34+
if depends_on?("veclibfort") || depends_on?("lapack")
35+
problem "Formulae in homebrew/core should use OpenBLAS as the default serial linear algebra library."
36+
end
37+
38+
if find_node_method_by_name(body_node, :keg_only)&.source&.include?("HOMEBREW_PREFIX")
39+
problem "`keg_only` reason should not include `HOMEBREW_PREFIX` " \
40+
"as it creates confusing `brew info` output."
41+
end
3542
end
3643

3744
unless method_called_ever?(body_node, :go_resource)

Library/Homebrew/test/formula_auditor_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1238,7 +1238,7 @@ class FooAT11 < Formula
12381238

12391239
describe "#audit_conflicts" do
12401240
before do
1241-
# We don't really test FormulaTextAuditor here
1241+
# We don't really test the formula text retrieval here
12421242
allow(File).to receive(:open).and_return("")
12431243
end
12441244

Library/Homebrew/test/formula_text_auditor_spec.rb

-39
This file was deleted.

0 commit comments

Comments
 (0)