livecheck: add component order rubocop

This commit is contained in:
nandahkrishna 2020-05-15 18:28:47 +05:30
parent 56f0308fe7
commit a4f9a66406
No known key found for this signature in database
GPG Key ID: 067E5FCD58ADF3AA
2 changed files with 34 additions and 16 deletions

View File

@ -23,6 +23,7 @@ module RuboCop
[{ name: :version_scheme, type: :method_call }],
[{ name: :head, type: :method_call }],
[{ name: :stable, type: :block_call }],
[{ name: :livecheck, type: :block_call }],
[{ name: :bottle, type: :block_call }],
[{ name: :pour_bottle?, type: :block_call }],
[{ name: :devel, type: :block_call }],

View File

@ -19,6 +19,23 @@ describe RuboCop::Cop::FormulaAudit::ComponentsOrder do
RUBY
end
it "When `bottle` precedes `livecheck`" do
expect_offense(<<~RUBY)
class Foo < Formula
homepage "https://brew.sh"
url "https://brew.sh/foo-1.0.tgz"
bottle :unneeded
livecheck do
^^^^^^^^^^^^ `livecheck` (line 7) should be put before `bottle` (line 5)
url "https://brew.sh/foo/versions/"
regex(/href=.+?foo-(\d+(?:\.\d+)+)\.t/)
end
end
RUBY
end
it "When url precedes homepage" do
expect_offense(<<~RUBY)
class Foo < Formula