audit: add "homebrew/core" for relevant checks
This commit is contained in:
parent
33b4e08394
commit
779304df68
@ -219,7 +219,7 @@ module Homebrew
|
|||||||
@except = options[:except]
|
@except = options[:except]
|
||||||
# Accept precomputed style offense results, for efficiency
|
# Accept precomputed style offense results, for efficiency
|
||||||
@style_offenses = options[:style_offenses]
|
@style_offenses = options[:style_offenses]
|
||||||
# Allow the formula tap to be set as `core`, for testing purposes
|
# Allow the formula tap to be set as homebrew/core, for testing purposes
|
||||||
@core_tap = formula.tap&.core_tap? || options[:core_tap]
|
@core_tap = formula.tap&.core_tap? || options[:core_tap]
|
||||||
@problems = []
|
@problems = []
|
||||||
@new_formula_problems = []
|
@new_formula_problems = []
|
||||||
@ -335,15 +335,15 @@ module Homebrew
|
|||||||
|
|
||||||
name = formula.name
|
name = formula.name
|
||||||
|
|
||||||
problem "'#{name}' is blacklisted." if MissingFormula.blacklisted_reason(name)
|
problem "'#{name}' is blacklisted from homebrew/core." if MissingFormula.blacklisted_reason(name)
|
||||||
|
|
||||||
if Formula.aliases.include? name
|
if Formula.aliases.include? name
|
||||||
problem "Formula name conflicts with existing aliases."
|
problem "Formula name conflicts with existing aliases in homebrew/core."
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
if oldname = CoreTap.instance.formula_renames[name]
|
if oldname = CoreTap.instance.formula_renames[name]
|
||||||
problem "'#{name}' is reserved as the old name of #{oldname}"
|
problem "'#{name}' is reserved as the old name of #{oldname} in homebrew/core."
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -380,7 +380,8 @@ module Homebrew
|
|||||||
|
|
||||||
if self.class.aliases.include?(dep.name) &&
|
if self.class.aliases.include?(dep.name) &&
|
||||||
(dep_f.core_formula? || !dep_f.versioned_formula?)
|
(dep_f.core_formula? || !dep_f.versioned_formula?)
|
||||||
problem "Dependency '#{dep.name}' is an alias; use the canonical name '#{dep.to_formula.full_name}'."
|
problem "Dependency '#{dep.name}' from homebrew/core is an alias; " \
|
||||||
|
"use the canonical name '#{dep.to_formula.full_name}'."
|
||||||
end
|
end
|
||||||
|
|
||||||
if @new_formula &&
|
if @new_formula &&
|
||||||
@ -414,14 +415,14 @@ module Homebrew
|
|||||||
next unless @core_tap
|
next unless @core_tap
|
||||||
|
|
||||||
if dep.tags.include?(:recommended) || dep.tags.include?(:optional)
|
if dep.tags.include?(:recommended) || dep.tags.include?(:optional)
|
||||||
problem "Formulae should not have optional or recommended dependencies"
|
problem "Formulae in homebrew/core should not have optional or recommended dependencies"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
next unless @core_tap
|
next unless @core_tap
|
||||||
|
|
||||||
if spec.requirements.map(&:recommended?).any? || spec.requirements.map(&:optional?).any?
|
if spec.requirements.map(&:recommended?).any? || spec.requirements.map(&:optional?).any?
|
||||||
problem "Formulae should not have optional or recommended requirements"
|
problem "Formulae in homebrew/core should not have optional or recommended requirements"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -485,7 +486,7 @@ module Homebrew
|
|||||||
begin
|
begin
|
||||||
Formula[previous_formula_name]
|
Formula[previous_formula_name]
|
||||||
rescue FormulaUnavailableError
|
rescue FormulaUnavailableError
|
||||||
problem "Versioned #{previous_formula_name} must be created for " \
|
problem "Versioned #{previous_formula_name} in homebrew/core must be created for " \
|
||||||
"`brew-postgresql-upgrade-database` and `pg_upgrade` to work."
|
"`brew-postgresql-upgrade-database` and `pg_upgrade` to work."
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -513,7 +514,7 @@ module Homebrew
|
|||||||
|
|
||||||
return if keg_only_whitelist.include?(formula.name) || formula.name.start_with?("gcc@")
|
return if keg_only_whitelist.include?(formula.name) || formula.name.start_with?("gcc@")
|
||||||
|
|
||||||
problem "Versioned formulae should use `keg_only :versioned_formula`"
|
problem "Versioned formulae in homebrew/core should use `keg_only :versioned_formula`"
|
||||||
end
|
end
|
||||||
|
|
||||||
def audit_homepage
|
def audit_homepage
|
||||||
@ -542,7 +543,7 @@ module Homebrew
|
|||||||
|
|
||||||
return unless formula.bottle_defined?
|
return unless formula.bottle_defined?
|
||||||
|
|
||||||
new_formula_problem "New formulae should not have a `bottle do` block"
|
new_formula_problem "New formulae in homebrew/core should not have a `bottle do` block"
|
||||||
end
|
end
|
||||||
|
|
||||||
def audit_bottle_disabled
|
def audit_bottle_disabled
|
||||||
@ -553,7 +554,7 @@ module Homebrew
|
|||||||
|
|
||||||
return unless @core_tap
|
return unless @core_tap
|
||||||
|
|
||||||
problem "Formulae should not use `bottle :disabled`"
|
problem "Formulae in homebrew/core should not use `bottle :disabled`"
|
||||||
end
|
end
|
||||||
|
|
||||||
def audit_github_repository
|
def audit_github_repository
|
||||||
@ -698,7 +699,7 @@ module Homebrew
|
|||||||
|
|
||||||
return unless @core_tap
|
return unless @core_tap
|
||||||
|
|
||||||
problem "Formulae should not have a `devel` spec" if formula.devel
|
problem "Formulae in homebrew/core should not have a `devel` spec" if formula.devel
|
||||||
|
|
||||||
if formula.head && @versioned_formula
|
if formula.head && @versioned_formula
|
||||||
head_spec_message = "Formulae should not have a `HEAD` spec"
|
head_spec_message = "Formulae should not have a `HEAD` spec"
|
||||||
@ -951,7 +952,7 @@ module Homebrew
|
|||||||
|
|
||||||
return unless @core_tap
|
return unless @core_tap
|
||||||
|
|
||||||
problem "`env :std` in `core` formulae is deprecated" if line.include?("env :std")
|
problem "`env :std` in homebrew/core formulae is deprecated" if line.include?("env :std")
|
||||||
end
|
end
|
||||||
|
|
||||||
def audit_reverse_migration
|
def audit_reverse_migration
|
||||||
|
@ -163,7 +163,8 @@ module RuboCop
|
|||||||
return unless formula_tap == "homebrew-core"
|
return unless formula_tap == "homebrew-core"
|
||||||
|
|
||||||
find_method_with_args(body_node, :depends_on, "mpich") do
|
find_method_with_args(body_node, :depends_on, "mpich") do
|
||||||
problem "Use 'depends_on \"open-mpi\"' instead of '#{@offensive_node.source}'."
|
problem "Formulae in homebrew/core should use 'depends_on \"open-mpi\"' " \
|
||||||
|
"instead of '#{@offensive_node.source}'."
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -201,7 +202,7 @@ module RuboCop
|
|||||||
next if formula_tap != "homebrew-core" || file_path&.include?("linuxbrew")
|
next if formula_tap != "homebrew-core" || file_path&.include?("linuxbrew")
|
||||||
|
|
||||||
find_instance_method_call(body_node, "OS", method_name) do |check|
|
find_instance_method_call(body_node, "OS", method_name) do |check|
|
||||||
problem "Don't use #{check.source}; Homebrew/core only supports macOS"
|
problem "Don't use #{check.source}; homebrew/core only supports macOS"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -10,8 +10,8 @@ module RuboCop
|
|||||||
DEPRECATION_MSG = "macOS has been 64-bit only since 10.6 so 32-bit options are deprecated."
|
DEPRECATION_MSG = "macOS has been 64-bit only since 10.6 so 32-bit options are deprecated."
|
||||||
UNI_DEPRECATION_MSG = "macOS has been 64-bit only since 10.6 so universal options are deprecated."
|
UNI_DEPRECATION_MSG = "macOS has been 64-bit only since 10.6 so universal options are deprecated."
|
||||||
|
|
||||||
DEP_OPTION = "Formulae should not use `deprecated_option`"
|
DEP_OPTION = "Formulae in homebrew/core should not use `deprecated_option`."
|
||||||
OPTION = "Formulae should not have an `option`"
|
OPTION = "Formulae in homebrew/core should not use `option`."
|
||||||
|
|
||||||
def audit_formula(_node, _class_node, _parent_class_node, body_node)
|
def audit_formula(_node, _class_node, _parent_class_node, body_node)
|
||||||
option_call_nodes = find_every_method_call_by_name(body_node, :option)
|
option_call_nodes = find_every_method_call_by_name(body_node, :option)
|
||||||
|
@ -17,7 +17,7 @@ module RuboCop
|
|||||||
end
|
end
|
||||||
|
|
||||||
if formula_tap == "homebrew-core" && (depends_on?("veclibfort") || depends_on?("lapack"))
|
if formula_tap == "homebrew-core" && (depends_on?("veclibfort") || depends_on?("lapack"))
|
||||||
problem "Formulae should use OpenBLAS as the default serial linear algebra library."
|
problem "Formulae in homebrew/core should use OpenBLAS as the default serial linear algebra library."
|
||||||
end
|
end
|
||||||
|
|
||||||
if method_called_ever?(body_node, :virtualenv_create) ||
|
if method_called_ever?(body_node, :virtualenv_create) ||
|
||||||
|
@ -234,8 +234,8 @@ module RuboCop
|
|||||||
next if BINARY_FORMULA_URLS_WHITELIST.include?(@formula_name)
|
next if BINARY_FORMULA_URLS_WHITELIST.include?(@formula_name)
|
||||||
next if BINARY_URLS_WHITELIST.include?(url)
|
next if BINARY_URLS_WHITELIST.include?(url)
|
||||||
|
|
||||||
problem "#{url} looks like a binary package, not a source archive. " \
|
problem "#{url} looks like a binary package, not a source archive; " \
|
||||||
"Homebrew/homebrew-core is source-only."
|
"homebrew/core is source-only."
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -569,7 +569,7 @@ module Homebrew
|
|||||||
fa.audit_versioned_keg_only
|
fa.audit_versioned_keg_only
|
||||||
|
|
||||||
expect(fa.problems.first)
|
expect(fa.problems.first)
|
||||||
.to match("Versioned formulae should use `keg_only :versioned_formula`")
|
.to match("Versioned formulae in homebrew/core should use `keg_only :versioned_formula`")
|
||||||
end
|
end
|
||||||
|
|
||||||
specify "it warns when a versioned formula has an incorrect `keg_only` reason" do
|
specify "it warns when a versioned formula has an incorrect `keg_only` reason" do
|
||||||
@ -584,7 +584,7 @@ module Homebrew
|
|||||||
fa.audit_versioned_keg_only
|
fa.audit_versioned_keg_only
|
||||||
|
|
||||||
expect(fa.problems.first)
|
expect(fa.problems.first)
|
||||||
.to match("Versioned formulae should use `keg_only :versioned_formula`")
|
.to match("Versioned formulae in homebrew/core should use `keg_only :versioned_formula`")
|
||||||
end
|
end
|
||||||
|
|
||||||
specify "it does not warn when a versioned formula has `keg_only :versioned_formula`" do
|
specify "it does not warn when a versioned formula has `keg_only :versioned_formula`" do
|
||||||
|
@ -289,7 +289,7 @@ describe RuboCop::Cop::FormulaAudit::MpiCheck do
|
|||||||
desc "foo"
|
desc "foo"
|
||||||
url 'https://brew.sh/foo-1.0.tgz'
|
url 'https://brew.sh/foo-1.0.tgz'
|
||||||
depends_on "mpich"
|
depends_on "mpich"
|
||||||
^^^^^^^^^^^^^^^^^^ Use 'depends_on "open-mpi"' instead of 'depends_on "mpich"'.
|
^^^^^^^^^^^^^^^^^^ Formulae in homebrew/core should use 'depends_on "open-mpi"' instead of 'depends_on "mpich"'.
|
||||||
end
|
end
|
||||||
RUBY
|
RUBY
|
||||||
|
|
||||||
@ -353,7 +353,7 @@ describe RuboCop::Cop::FormulaAudit::Miscellaneous do
|
|||||||
url 'https://brew.sh/foo-1.0.tgz'
|
url 'https://brew.sh/foo-1.0.tgz'
|
||||||
bottle do
|
bottle do
|
||||||
if OS.linux?
|
if OS.linux?
|
||||||
^^^^^^^^^ Don\'t use OS.linux?; Homebrew/core only supports macOS
|
^^^^^^^^^ Don\'t use OS.linux?; homebrew/core only supports macOS
|
||||||
nil
|
nil
|
||||||
end
|
end
|
||||||
sha256 "fe0679b932dd43a87fd415b609a7fbac7a069d117642ae8ebaac46ae1fb9f0b3" => :sierra
|
sha256 "fe0679b932dd43a87fd415b609a7fbac7a069d117642ae8ebaac46ae1fb9f0b3" => :sierra
|
||||||
|
@ -52,7 +52,7 @@ describe RuboCop::Cop::FormulaAudit::Options do
|
|||||||
class Foo < Formula
|
class Foo < Formula
|
||||||
url 'https://brew.sh/foo-1.0.tgz'
|
url 'https://brew.sh/foo-1.0.tgz'
|
||||||
deprecated_option "examples" => "with-examples"
|
deprecated_option "examples" => "with-examples"
|
||||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Formulae should not use `deprecated_option`
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Formulae in homebrew/core should not use `deprecated_option`.
|
||||||
end
|
end
|
||||||
RUBY
|
RUBY
|
||||||
end
|
end
|
||||||
@ -62,7 +62,7 @@ describe RuboCop::Cop::FormulaAudit::Options do
|
|||||||
class Foo < Formula
|
class Foo < Formula
|
||||||
url 'https://brew.sh/foo-1.0.tgz'
|
url 'https://brew.sh/foo-1.0.tgz'
|
||||||
option "with-examples"
|
option "with-examples"
|
||||||
^^^^^^^^^^^^^^^^^^^^^^ Formulae should not have an `option`
|
^^^^^^^^^^^^^^^^^^^^^^ Formulae in homebrew/core should not use `option`.
|
||||||
end
|
end
|
||||||
RUBY
|
RUBY
|
||||||
end
|
end
|
||||||
|
@ -38,7 +38,7 @@ describe RuboCop::Cop::FormulaAudit::Text do
|
|||||||
url "https://brew.sh/foo-1.0.tgz"
|
url "https://brew.sh/foo-1.0.tgz"
|
||||||
homepage "https://brew.sh"
|
homepage "https://brew.sh"
|
||||||
depends_on "veclibfort"
|
depends_on "veclibfort"
|
||||||
^^^^^^^^^^^^^^^^^^^^^^^ Formulae should use OpenBLAS as the default serial linear algebra library.
|
^^^^^^^^^^^^^^^^^^^^^^^ Formulae in homebrew/core should use OpenBLAS as the default serial linear algebra library.
|
||||||
end
|
end
|
||||||
RUBY
|
RUBY
|
||||||
end
|
end
|
||||||
@ -49,7 +49,7 @@ describe RuboCop::Cop::FormulaAudit::Text do
|
|||||||
url "https://brew.sh/foo-1.0.tgz"
|
url "https://brew.sh/foo-1.0.tgz"
|
||||||
homepage "https://brew.sh"
|
homepage "https://brew.sh"
|
||||||
depends_on "lapack"
|
depends_on "lapack"
|
||||||
^^^^^^^^^^^^^^^^^^^ Formulae should use OpenBLAS as the default serial linear algebra library.
|
^^^^^^^^^^^^^^^^^^^ Formulae in homebrew/core should use OpenBLAS as the default serial linear algebra library.
|
||||||
end
|
end
|
||||||
RUBY
|
RUBY
|
||||||
end
|
end
|
||||||
|
@ -145,13 +145,13 @@ describe RuboCop::Cop::FormulaAudit::Urls do
|
|||||||
}, {
|
}, {
|
||||||
"url" => "https://brew.sh/example-darwin.x86_64.tar.gz",
|
"url" => "https://brew.sh/example-darwin.x86_64.tar.gz",
|
||||||
"msg" => "https://brew.sh/example-darwin.x86_64.tar.gz looks like a binary package, " \
|
"msg" => "https://brew.sh/example-darwin.x86_64.tar.gz looks like a binary package, " \
|
||||||
"not a source archive. Homebrew/homebrew-core is source-only.",
|
"not a source archive; homebrew/core is source-only.",
|
||||||
"col" => 2,
|
"col" => 2,
|
||||||
"formula_tap" => "homebrew-core",
|
"formula_tap" => "homebrew-core",
|
||||||
}, {
|
}, {
|
||||||
"url" => "https://brew.sh/example-darwin.amd64.tar.gz",
|
"url" => "https://brew.sh/example-darwin.amd64.tar.gz",
|
||||||
"msg" => "https://brew.sh/example-darwin.amd64.tar.gz looks like a binary package, " \
|
"msg" => "https://brew.sh/example-darwin.amd64.tar.gz looks like a binary package, " \
|
||||||
"not a source archive. Homebrew/homebrew-core is source-only.",
|
"not a source archive; homebrew/core is source-only.",
|
||||||
"col" => 2,
|
"col" => 2,
|
||||||
"formula_tap" => "homebrew-core",
|
"formula_tap" => "homebrew-core",
|
||||||
}]
|
}]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user