Cleanup code and remove unneeded methods

This commit is contained in:
Rylan Polster 2021-09-21 00:42:40 -04:00
parent 50fac1737a
commit e8e1deeb32
No known key found for this signature in database
GPG Key ID: 46A744940CFF4D64
2 changed files with 3 additions and 13 deletions

View File

@ -77,10 +77,6 @@ class Formula
# e.g. `this-formula`
attr_reader :name
# The path to the alias that was used to identify this {Formula}.
# e.g. `/usr/local/Library/Taps/homebrew/homebrew-core/Aliases/another-name-for-this-formula`
attr_reader :bottle_path
# The path to the alias that was used to identify this {Formula}.
# e.g. `/usr/local/Library/Taps/homebrew/homebrew-core/Aliases/another-name-for-this-formula`
attr_reader :alias_path
@ -312,18 +308,12 @@ class Formula
full_name_with_optional_tap(installed_alias_name)
end
def prefix_formula_file
return unless prefix.directory?
prefix/".brew/#{name}.rb"
end
# The path that was specified to find this formula.
def specified_path
default_specified_path = alias_path || path
return default_specified_path if default_specified_path.present? && default_specified_path.exist?
return local_bottle_path if local_bottle_path.present? && local_bottle_path.exist?
return default_specified_path if default_specified_path.presence&.exist?
return local_bottle_path if local_bottle_path.presence&.exist?
default_specified_path
end

View File

@ -287,7 +287,7 @@ module FormulaCellarChecks
def check_cpuid_instruction(formula)
return unless formula.prefix.directory?
# TODO: add methods to `utils/ast` to allow checking for method use
return unless formula.prefix_formula_file.read.include? "ENV.runtime_cpu_detection"
return unless (formula.prefix/".brew/#{formula.name}.rb").read.include? "ENV.runtime_cpu_detection"
# Checking for `cpuid` only makes sense on Intel:
# https://en.wikipedia.org/wiki/CPUID
return unless Hardware::CPU.intel?