diff --git a/Library/Homebrew/rubocops/components_order.rb b/Library/Homebrew/rubocops/components_order.rb index a9d4d577b8..5049598b4b 100644 --- a/Library/Homebrew/rubocops/components_order.rb +++ b/Library/Homebrew/rubocops/components_order.rb @@ -12,24 +12,25 @@ module RuboCop class ComponentsOrder < FormulaCop def audit_formula(_node, _class_node, _parent_class_node, body_node) component_precedence_list = [ - [{ name: :include, type: :method_call }], - [{ name: :desc, type: :method_call }], - [{ name: :homepage, type: :method_call }], - [{ name: :url, type: :method_call }], - [{ name: :mirror, type: :method_call }], - [{ name: :version, type: :method_call }], - [{ name: :sha256, type: :method_call }], - [{ name: :revision, type: :method_call }], + [{ name: :include, type: :method_call }], + [{ name: :desc, type: :method_call }], + [{ name: :homepage, type: :method_call }], + [{ name: :url, type: :method_call }], + [{ name: :mirror, type: :method_call }], + [{ name: :version, type: :method_call }], + [{ name: :sha256, type: :method_call }], + [{ name: :revision, type: :method_call }], [{ name: :version_scheme, type: :method_call }], - [{ name: :head, type: :method_call }], - [{ name: :stable, type: :block_call }], - [{ name: :bottle, type: :block_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 }], - [{ name: :head, type: :block_call }], - [{ name: :bottle, type: :method_call }], - [{ name: :keg_only, type: :method_call }], - [{ name: :option, type: :method_call }], + [{ name: :devel, type: :block_call }], + [{ name: :head, type: :block_call }], + [{ name: :bottle, type: :method_call }], + [{ name: :keg_only, type: :method_call }], + [{ name: :option, type: :method_call }], [{ name: :deprecated_option, type: :method_call }], [{ name: :depends_on, type: :method_call }], [{ name: :uses_from_macos, type: :method_call }], diff --git a/Library/Homebrew/test/rubocops/components_order_spec.rb b/Library/Homebrew/test/rubocops/components_order_spec.rb index 1edc7fd499..821cbd64a1 100644 --- a/Library/Homebrew/test/rubocops/components_order_spec.rb +++ b/Library/Homebrew/test/rubocops/components_order_spec.rb @@ -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