Skip to content
Snippets Groups Projects
Commit cf66c05d authored by Jonathan Chang's avatar Jonathan Chang
Browse files

audit: avoid build-time checks in core

parent 9634041f
No related branches found
No related tags found
No related merge requests found
......@@ -419,6 +419,21 @@ module RuboCop
problem "Use the `#{match}` Ruby method instead of `#{method.source}`"
end
return if formula_tap != "homebrew-core"
# Avoid build-time checks in homebrew/core
find_every_method_call_by_name(body_node, :system).each do |method|
params = parameters(method)
next unless node_equals?(params[0], "make")
params[1..].each do |arg|
next unless regex_match_group(arg, /^(checks?|tests?)$/)
offending_node(method)
problem "Formulae in homebrew/core should not run build-time checks"
end
end
end
def modifier?(node)
......
......@@ -349,6 +349,17 @@ describe RuboCop::Cop::FormulaAudit::Miscellaneous do
subject(:cop) { described_class.new }
context "When auditing formula" do
it "build-time checks in homebrew/core" do
expect_offense(<<~RUBY, "/homebrew-core/")
class Foo < Formula
desc "foo"
url 'https://brew.sh/foo-1.0.tgz'
system "make", "-j1", "test"
^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Formulae in homebrew/core should not run build-time checks
end
RUBY
end
it "FileUtils usage" do
expect_offense(<<~RUBY)
class Foo < Formula
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment