audit: check for build.with? in core
Co-Authored-By: Mike McQuaid <mike@mikemcquaid.com>
This commit is contained in:
parent
4bdce4701f
commit
7239b3099a
@ -148,6 +148,16 @@ module RuboCop
|
||||
|
||||
problem "Reference '#{match[1]}' without dashes"
|
||||
end
|
||||
|
||||
return if formula_tap != "homebrew-core"
|
||||
|
||||
# Use of build.with? implies options, which are forbidden in homebrew/core
|
||||
find_instance_method_call(body_node, :build, :without?) do
|
||||
problem "Formulae in homebrew/core should not use `build.without?`."
|
||||
end
|
||||
find_instance_method_call(body_node, :build, :with?) do
|
||||
problem "Formulae in homebrew/core should not use `build.with?`."
|
||||
end
|
||||
end
|
||||
|
||||
def unless_modifier?(node)
|
||||
|
||||
@ -160,6 +160,32 @@ end
|
||||
describe RuboCop::Cop::FormulaAudit::OptionDeclarations do
|
||||
subject(:cop) { described_class.new }
|
||||
|
||||
it "build.without? in homebrew/core" do
|
||||
expect_offense(<<~RUBY, "/homebrew-core/")
|
||||
class Foo < Formula
|
||||
desc "foo"
|
||||
url 'https://brew.sh/foo-1.0.tgz'
|
||||
def install
|
||||
build.without? "bar"
|
||||
^^^^^^^^^^^^^^^^^^^^ Formulae in homebrew/core should not use `build.without?`.
|
||||
end
|
||||
end
|
||||
RUBY
|
||||
end
|
||||
|
||||
it "build.with? in homebrew/core" do
|
||||
expect_offense(<<~RUBY, "/homebrew-core/")
|
||||
class Foo < Formula
|
||||
desc "foo"
|
||||
url 'https://brew.sh/foo-1.0.tgz'
|
||||
def install
|
||||
build.with? "bar"
|
||||
^^^^^^^^^^^^^^^^^ Formulae in homebrew/core should not use `build.with?`.
|
||||
end
|
||||
end
|
||||
RUBY
|
||||
end
|
||||
|
||||
it "unless build.without? conditional" do
|
||||
expect_offense(<<~RUBY)
|
||||
class Foo < Formula
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user