Merge pull request #4170 from commitay/new-formulae-options
audit: new formulae should not have options
This commit is contained in:
commit
dc96e6f735
@ -414,6 +414,13 @@ module Homebrew
|
|||||||
if dep.tags.include?(:run)
|
if dep.tags.include?(:run)
|
||||||
problem "Dependency '#{dep.name}' is marked as :run. Remove :run; it is a no-op."
|
problem "Dependency '#{dep.name}' is marked as :run. Remove :run; it is a no-op."
|
||||||
end
|
end
|
||||||
|
|
||||||
|
next unless @new_formula
|
||||||
|
next if formula.versioned_formula?
|
||||||
|
next unless @official_tap
|
||||||
|
if dep.tags.include?(:recommended) || dep.tags.include?(:optional)
|
||||||
|
new_formula_problem "Formulae should not have #{dep.tags} dependencies."
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -46,11 +46,14 @@ module RuboCop
|
|||||||
|
|
||||||
module NewFormulaAudit
|
module NewFormulaAudit
|
||||||
class Options < FormulaCop
|
class Options < FormulaCop
|
||||||
MSG = "New Formula should not use `deprecated_option`".freeze
|
DEP_OPTION = "New Formula should not use `deprecated_option`".freeze
|
||||||
|
OPTION = "Formula should not have an `option`".freeze
|
||||||
|
|
||||||
def audit_formula(_node, _class_node, _parent_class_node, body_node)
|
def audit_formula(_node, _class_node, _parent_class_node, body_node)
|
||||||
return if versioned_formula?
|
return if versioned_formula?
|
||||||
problem MSG if method_called_ever?(body_node, :deprecated_option)
|
problem DEP_OPTION if method_called_ever?(body_node, :deprecated_option)
|
||||||
|
return unless formula_tap == "homebrew-core"
|
||||||
|
problem OPTION if method_called_ever?(body_node, :option)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -64,5 +64,15 @@ describe RuboCop::Cop::NewFormulaAudit::Options do
|
|||||||
end
|
end
|
||||||
RUBY
|
RUBY
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "with options" do
|
||||||
|
expect_offense(<<~RUBY, "/homebrew-core/")
|
||||||
|
class Foo < Formula
|
||||||
|
url 'http://example.com/foo-1.0.tgz'
|
||||||
|
option "with-examples"
|
||||||
|
^^^^^^^^^^^^^^^^^^^^^^ Formula should not have an `option`
|
||||||
|
end
|
||||||
|
RUBY
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user