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.
This commit is contained in:
Issy Long 2020-11-18 21:26:16 +00:00
parent 125555752f
commit 7bcf554799
No known key found for this signature in database
GPG Key ID: 8247C390DADC67D4
2 changed files with 27 additions and 0 deletions

View File

@ -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 }],

View File

@ -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