Merge pull request #4170 from commitay/new-formulae-options

audit: new formulae should not have options
This commit is contained in:
commitay 2018-05-24 07:16:11 +10:00 committed by GitHub
commit dc96e6f735
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 2 deletions

View File

@ -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

View File

@ -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

View File

@ -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