Merge pull request #7854 from iMichka/components
components order: fix audit and add test
This commit is contained in:
commit
9d71f9521d
@ -226,11 +226,10 @@ module RuboCop
|
||||
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
|
||||
|
||||
@ -77,6 +77,37 @@ describe RuboCop::Cop::FormulaAudit::ComponentsOrder do
|
||||
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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user