components order: fix audit and add test
This commit is contained in:
parent
e247a10643
commit
8d55c87adb
@ -226,11 +226,10 @@ module RuboCop
|
|||||||
next if succeeding_component.empty?
|
next if succeeding_component.empty?
|
||||||
|
|
||||||
offensive_nodes = check_precedence(preceding_component, succeeding_component)
|
offensive_nodes = check_precedence(preceding_component, succeeding_component)
|
||||||
break if offensive_nodes
|
return [present_components, offensive_nodes] if offensive_nodes
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
nil
|
||||||
[present_components, offensive_nodes]
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Method to format message for reporting component precedence violations
|
# Method to format message for reporting component precedence violations
|
||||||
|
|||||||
@ -77,6 +77,37 @@ describe RuboCop::Cop::FormulaAudit::ComponentsOrder do
|
|||||||
RUBY
|
RUBY
|
||||||
end
|
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
|
it "When only one of many `depends_on` precedes `conflicts_with`" do
|
||||||
expect_offense(<<~RUBY)
|
expect_offense(<<~RUBY)
|
||||||
class Foo < Formula
|
class Foo < Formula
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user