Skip to content

Commit

Permalink
components order: fix audit and add test
Browse files Browse the repository at this point in the history
  • Loading branch information
iMichka authored and MikeMcQuaid committed Jun 30, 2020
1 parent e247a10 commit 8d55c87
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 3 deletions.
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

0 comments on commit 8d55c87

Please sign in to comment.