From 7bcf55479954f8c38a1c239e30dc576219542ee5 Mon Sep 17 00:00:00 2001 From: Issy Long Date: Wed, 18 Nov 2020 21:26:16 +0000 Subject: [PATCH] rubocops/components_order: Specify `disable!` and `deprecate!` order - Ordering them this way seems to require less `--fix`ing in Homebrew/homebrew-core than the other way around. - In the Big Sur bottling, we found many repos that were archived. We've been going through and deprecating repos that are archived or that don't build any more. I felt weird without the ordering of these stanzas without an audit to guide me - I spent time looking at previous examples to see "should `deprecate!` go before or after `depends_on`" question. Computers can tell us this instead. --- Library/Homebrew/rubocops/components_order.rb | 2 ++ .../test/rubocops/components_order_spec.rb | 25 +++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/Library/Homebrew/rubocops/components_order.rb b/Library/Homebrew/rubocops/components_order.rb index f76351fc0e..7f6613799c 100644 --- a/Library/Homebrew/rubocops/components_order.rb +++ b/Library/Homebrew/rubocops/components_order.rb @@ -38,6 +38,8 @@ module RuboCop [{ name: :keg_only, type: :method_call }], [{ name: :option, type: :method_call }], [{ name: :deprecated_option, type: :method_call }], + [{ name: :disable!, type: :method_call }], + [{ name: :deprecate!, type: :method_call }], [{ name: :depends_on, type: :method_call }], [{ name: :uses_from_macos, type: :method_call }], [{ name: :on_macos, type: :block_call }], diff --git a/Library/Homebrew/test/rubocops/components_order_spec.rb b/Library/Homebrew/test/rubocops/components_order_spec.rb index 098e782546..8aa6bfc867 100644 --- a/Library/Homebrew/test/rubocops/components_order_spec.rb +++ b/Library/Homebrew/test/rubocops/components_order_spec.rb @@ -225,6 +225,31 @@ describe RuboCop::Cop::FormulaAudit::ComponentsOrder do corrected_source = autocorrect_source(source) expect(corrected_source).to eq(correct_source) end + + it "When `depends_on` precedes `deprecate!`" do + source = <<~RUBY + class Foo < Formula + url "https://brew.sh/foo-1.0.tgz" + + depends_on "openssl" + + deprecate! because: "has been replaced by bar" + end + RUBY + + correct_source = <<~RUBY + class Foo < Formula + url "https://brew.sh/foo-1.0.tgz" + + deprecate! because: "has been replaced by bar" + + depends_on "openssl" + end + RUBY + + corrected_source = autocorrect_source(source) + expect(corrected_source).to eq(correct_source) + end end context "no on_os_block" do