Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

components order: fix audit and add test #7854

Merged
merged 1 commit into from Jun 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 2 additions & 3 deletions Library/Homebrew/rubocops/components_order.rb
Expand Up @@ -226,11 +226,10 @@ def check_order(component_precedence_list, body_node)
next if succeeding_component.empty?

offensive_nodes = check_precedence(preceding_component, succeeding_component)
break if offensive_nodes
return [present_components, offensive_nodes] if offensive_nodes
end
end

[present_components, offensive_nodes]
nil
end

# Method to format message for reporting component precedence violations
Expand Down
31 changes: 31 additions & 0 deletions Library/Homebrew/test/rubocops/components_order_spec.rb
Expand Up @@ -77,6 +77,37 @@ def plist
RUBY
end

it "When `install` precedes `depends_on`" do
expect_offense(<<~RUBY)
class Foo < Formula
url "https://brew.sh/foo-1.0.tgz"

def install
end

depends_on "openssl"
^^^^^^^^^^^^^^^^^^^^ `depends_on` (line 7) should be put before `install` (line 4)
end
RUBY
end

it "When `test` precedes `depends_on`" do
expect_offense(<<~RUBY)
class Foo < Formula
url "https://brew.sh/foo-1.0.tgz"

def install
end

def test
end

depends_on "openssl"
^^^^^^^^^^^^^^^^^^^^ `depends_on` (line 10) should be put before `install` (line 4)
end
RUBY
end

it "When only one of many `depends_on` precedes `conflicts_with`" do
expect_offense(<<~RUBY)
class Foo < Formula
Expand Down