Skip to content

Commit

Permalink
Merge pull request #17228 from Homebrew/replace-formula-text-audits-w…
Browse files Browse the repository at this point in the history
…ith-rubocops

Replace `FormulaTextAuditor` usage
  • Loading branch information
MikeMcQuaid authored May 6, 2024
2 parents 80b35e8 + 9f915a6 commit 82c2e74
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 97 deletions.
13 changes: 1 addition & 12 deletions Library/Homebrew/formula_auditor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
# frozen_string_literal: true

require "deprecate_disable"
require "formula_text_auditor"
require "formula_versions"
require "resource_auditor"
require "utils/shared_audits"
Expand Down Expand Up @@ -32,7 +31,7 @@ def initialize(formula, options = {})
@core_tap = formula.tap&.core_tap? || options[:core_tap]
@problems = []
@new_formula_problems = []
@text = FormulaTextAuditor.new(formula.path)
@text = formula.path.open("rb", &:read)
@specs = %w[stable head].filter_map { |s| formula.send(s) }
@spdx_license_data = options[:spdx_license_data]
@spdx_exception_data = options[:spdx_exception_data]
Expand Down Expand Up @@ -510,16 +509,6 @@ def audit_relicensed_formulae
"It must not be upgraded to version #{relicensed_version} or newer."
end

def audit_keg_only_reason
return unless @core_tap
return unless formula.keg_only?

keg_only_message = text.to_s.match(/keg_only\s+["'](.*)["']/)&.captures&.first
return unless keg_only_message&.include?("HOMEBREW_PREFIX")

problem "`keg_only` reason should not include `HOMEBREW_PREFIX` as it creates confusing `brew info` output."
end

def audit_versioned_keg_only
return unless @versioned_formula
return unless @core_tap
Expand Down
43 changes: 0 additions & 43 deletions Library/Homebrew/formula_text_auditor.rb

This file was deleted.

11 changes: 9 additions & 2 deletions Library/Homebrew/rubocops/text.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,15 @@ def audit_formula(node, _class_node, _parent_class_node, body_node)
problem "Formulae should not depend on both OpenSSL and LibreSSL (even optionally)."
end

if formula_tap == "homebrew-core" && (depends_on?("veclibfort") || depends_on?("lapack"))
problem "Formulae in homebrew/core should use OpenBLAS as the default serial linear algebra library."
if formula_tap == "homebrew-core"
if depends_on?("veclibfort") || depends_on?("lapack")
problem "Formulae in homebrew/core should use OpenBLAS as the default serial linear algebra library."
end

if find_node_method_by_name(body_node, :keg_only)&.source&.include?("HOMEBREW_PREFIX")
problem "`keg_only` reason should not include `HOMEBREW_PREFIX` " \
"as it creates confusing `brew info` output."
end
end

unless method_called_ever?(body_node, :go_resource)
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/test/formula_auditor_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1238,7 +1238,7 @@ class FooAT11 < Formula

describe "#audit_conflicts" do
before do
# We don't really test FormulaTextAuditor here
# We don't really test the formula text retrieval here
allow(File).to receive(:open).and_return("")
end

Expand Down
39 changes: 0 additions & 39 deletions Library/Homebrew/test/formula_text_auditor_spec.rb

This file was deleted.

0 comments on commit 82c2e74

Please sign in to comment.