-
-
Notifications
You must be signed in to change notification settings - Fork 10.5k
formula: allow excluding deprecate!
reason when disable!
exists
#18661
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -324,4 +324,65 @@ class Foo < Formula | |||||
RUBY | ||||||
end | ||||||
end | ||||||
|
||||||
context "when auditing `deprecate!` and `disable!`" do | ||||||
it "reports no offense if deprecate `reason` is absent" do | ||||||
expect_no_offenses(<<~RUBY) | ||||||
class Foo < Formula | ||||||
url 'https://brew.sh/foo-1.0.tgz' | ||||||
disable! date: "2021-08-28", because: :does_not_build | ||||||
deprecate! date: "2020-08-28" | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not really relevant for this PR, but are these automatically sorted in this order by another cop? To me it would make more sense to have There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is from AST order: brew/Library/Homebrew/ast_constants.rb Lines 27 to 28 in 1d19230
Could reverse them if we wanted, though would need to make sure about handling. I did try to add code so order doesn't matter. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will look into order in #18974 prior to continuing this PR. |
||||||
end | ||||||
RUBY | ||||||
end | ||||||
|
||||||
it "reports offense if disable `reason` is absent`" do | ||||||
expect_offense(<<~RUBY) | ||||||
class Foo < Formula | ||||||
url 'https://brew.sh/foo-1.0.tgz' | ||||||
disable! date: "2021-08-28" | ||||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^ FormulaAudit/DeprecateDisableReason: Add a reason for disabling: `disable! because: "..."` | ||||||
deprecate! date: "2020-08-28", because: :does_not_build | ||||||
end | ||||||
RUBY | ||||||
end | ||||||
|
||||||
it "reports and corrects an offense if disable and deprecate `reason` are identical symbols" do | ||||||
expect_offense(<<~RUBY) | ||||||
class Foo < Formula | ||||||
url 'https://brew.sh/foo-1.0.tgz' | ||||||
disable! date: "2021-08-28", because: :does_not_build | ||||||
deprecate! date: "2020-08-28", because: :does_not_build | ||||||
^^^^^^^^^^^^^^^^^^^^^^^^ FormulaAudit/DeprecateDisableReason: Remove deprecate reason when disable reason is identical | ||||||
end | ||||||
RUBY | ||||||
|
||||||
expect_correction(<<~RUBY) | ||||||
class Foo < Formula | ||||||
url 'https://brew.sh/foo-1.0.tgz' | ||||||
disable! date: "2021-08-28", because: :does_not_build | ||||||
deprecate! date: "2020-08-28" | ||||||
end | ||||||
RUBY | ||||||
end | ||||||
|
||||||
it "reports and corrects an offense if disable and deprecate `reason` are identical strings" do | ||||||
expect_offense(<<~RUBY) | ||||||
class Foo < Formula | ||||||
url 'https://brew.sh/foo-1.0.tgz' | ||||||
disable! date: "2021-08-28", because: "is broken" | ||||||
deprecate! date: "2020-08-28", because: "is broken" | ||||||
^^^^^^^^^^^^^^^^^^^^ FormulaAudit/DeprecateDisableReason: Remove deprecate reason when disable reason is identical | ||||||
end | ||||||
RUBY | ||||||
|
||||||
expect_correction(<<~RUBY) | ||||||
class Foo < Formula | ||||||
url 'https://brew.sh/foo-1.0.tgz' | ||||||
disable! date: "2021-08-28", because: "is broken" | ||||||
deprecate! date: "2020-08-28" | ||||||
end | ||||||
RUBY | ||||||
end | ||||||
end | ||||||
end |
Uh oh!
There was an error while loading. Please reload this page.