Skip to content

Commit

Permalink
Standardize livecheck block language formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
samford committed Dec 2, 2024
1 parent 01cb74e commit 79e20b3
Show file tree
Hide file tree
Showing 13 changed files with 28 additions and 27 deletions.
2 changes: 1 addition & 1 deletion Library/Homebrew/formula.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4179,7 +4179,7 @@ def test(&block)
end

# {Livecheck} can be used to check for newer versions of the software.
# This method evaluates the DSL specified in the livecheck block of the
# This method evaluates the DSL specified in the `livecheck` block of the
# {Formula} (if it exists) and sets the instance variables of a {Livecheck}
# object accordingly. This is used by `brew livecheck` to check for newer
# versions of the software.
Expand Down
4 changes: 2 additions & 2 deletions Library/Homebrew/livecheck.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def initialize(package_or_resource)
# Sets the `@referenced_cask_name` instance variable to the provided `String`
# or returns the `@referenced_cask_name` instance variable when no argument
# is provided. Inherited livecheck values from the referenced cask
# (e.g. regex) can be overridden in the livecheck block.
# (e.g. regex) can be overridden in the `livecheck` block.
sig {
params(
# Name of cask to inherit livecheck info from.
Expand All @@ -56,7 +56,7 @@ def cask(cask_name = T.unsafe(nil))
# Sets the `@referenced_formula_name` instance variable to the provided
# `String` or returns the `@referenced_formula_name` instance variable when
# no argument is provided. Inherited livecheck values from the referenced
# formula (e.g. regex) can be overridden in the livecheck block.
# formula (e.g. regex) can be overridden in the `livecheck` block.
sig {
params(
# Name of formula to inherit livecheck info from.
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/livecheck/livecheck.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def self.resolve_livecheck_reference(
full_name: false,
debug: false
)
# Check the livecheck block for a formula or cask reference
# Check the `livecheck` block for a formula or cask reference
livecheck = formula_or_cask.livecheck
livecheck_formula = livecheck.formula
livecheck_cask = livecheck.cask
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/resource.rb
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ def fetch(verify_download_integrity: true, timeout: nil, quiet: false)
end

# {Livecheck} can be used to check for newer versions of the software.
# This method evaluates the DSL specified in the livecheck block of the
# This method evaluates the DSL specified in the `livecheck` block of the
# {Resource} (if it exists) and sets the instance variables of a {Livecheck}
# object accordingly. This is used by `brew livecheck` to check for newer
# versions of the software.
Expand Down
3 changes: 2 additions & 1 deletion Library/Homebrew/rubocops/cask/no_overrides.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ def on_system_stanzas(on_system)
method_nodes.select(&:block_type?).each do |node|
node.child_nodes.each do |child|
child.each_node(:send) do |send_node|
# Skip (nested) livecheck blocks as its `url` is different to a download `url`.
# Skip (nested) `livecheck` block as its `url` is different
# from a download `url`.
next if send_node.method_name == :livecheck || inside_livecheck_defined?(send_node)
# Skip string interpolations.
if send_node.ancestors.drop_while { |a| !a.begin_type? }.any? { |a| a.dstr_type? || a.regexp_type? }
Expand Down
12 changes: 6 additions & 6 deletions Library/Homebrew/test/cask/audit_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -508,13 +508,13 @@ def tmp_cask(name, text)
let(:online) { true }
let(:message) { /Version '[^']*' differs from '[^']*' retrieved by livecheck\./ }

context "when the Cask has a livecheck block using skip" do
context "when the Cask has a `livecheck` block using skip" do
let(:cask_token) { "livecheck-skip" }

it { is_expected.not_to error_with(message) }
end

context "when the Cask has a livecheck block referencing a Cask using skip" do
context "when the Cask has a `livecheck` block referencing a Cask using skip" do
let(:cask_token) { "livecheck-skip-reference" }

it { is_expected.not_to error_with(message) }
Expand All @@ -526,7 +526,7 @@ def tmp_cask(name, text)
it { is_expected.not_to error_with(message) }
end

context "when the Cask has a livecheck block referencing a deprecated Cask" do
context "when the Cask has a `livecheck` block referencing a deprecated Cask" do
let(:cask_token) { "livecheck-deprecated-reference" }

it { is_expected.not_to error_with(message) }
Expand All @@ -538,7 +538,7 @@ def tmp_cask(name, text)
it { is_expected.not_to error_with(message) }
end

context "when the Cask has a livecheck block referencing a disabled Cask" do
context "when the Cask has a `livecheck` block referencing a disabled Cask" do
let(:cask_token) { "livecheck-disabled-reference" }

it { is_expected.not_to error_with(message) }
Expand All @@ -550,7 +550,7 @@ def tmp_cask(name, text)
it { is_expected.not_to error_with(message) }
end

context "when the Cask has a livecheck block referencing a Cask where version is :latest" do
context "when the Cask has a `livecheck` block referencing a Cask where version is :latest" do
let(:cask_token) { "livecheck-version-latest-reference" }

it { is_expected.not_to error_with(message) }
Expand All @@ -562,7 +562,7 @@ def tmp_cask(name, text)
it { is_expected.not_to error_with(message) }
end

context "when the Cask has a livecheck block referencing a Cask with an unversioned url" do
context "when the Cask has a `livecheck` block referencing a Cask with an unversioned url" do
let(:cask_token) { "livecheck-url-unversioned-reference" }

it { is_expected.not_to error_with(message) }
Expand Down
4 changes: 2 additions & 2 deletions Library/Homebrew/test/formula_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -705,15 +705,15 @@ def post_install
end

describe "#livecheck_defined?" do
specify "no livecheck block defined" do
specify "no `livecheck` block defined" do
f = formula do
url "https://brew.sh/test-1.0.tbz"
end

expect(f.livecheck_defined?).to be false
end

specify "livecheck block defined" do
specify "`livecheck` block defined" do
f = formula do
url "https://brew.sh/test-1.0.tbz"
livecheck do
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/test/livecheck/livecheck_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
end

describe "::resolve_livecheck_reference" do
context "when a formula/cask has a livecheck block without formula/cask methods" do
context "when a formula/cask has a `livecheck` block without formula/cask methods" do
it "returns [nil, []]" do
expect(livecheck.resolve_livecheck_reference(f)).to eq([nil, []])
expect(livecheck.resolve_livecheck_reference(c)).to eq([nil, []])
Expand Down
6 changes: 3 additions & 3 deletions Library/Homebrew/test/resource_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,18 +65,18 @@
end

describe "#livecheck" do
specify "when livecheck block is set" do
specify "when `livecheck` block is set" do
expect(livecheck_resource.livecheck.url).to eq("https://brew.sh/test/releases")
expect(livecheck_resource.livecheck.regex).to eq(/foo[._-]v?(\d+(?:\.\d+)+)\.t/i)
end
end

describe "#livecheck_defined?" do
it "returns false if livecheck block is not set in resource" do
it "returns false if `livecheck` block is not set in resource" do
expect(resource.livecheck_defined?).to be false
end

specify "livecheck block defined in resources" do
specify "`livecheck` block defined in resources" do
expect(livecheck_resource.livecheck_defined?).to be true
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
RSpec.describe RuboCop::Cop::FormulaAudit::LivecheckRegexParentheses do
subject(:cop) { described_class.new }

it "reports an offense when the `regex` call in the livecheck block does not use parentheses" do
it "reports an offense when the `regex` call in the `livecheck` block does not use parentheses" do
expect_offense(<<~RUBY)
class Foo < Formula
url "https://brew.sh/foo-1.0.tgz"
Expand All @@ -30,7 +30,7 @@ class Foo < Formula
RUBY
end

it "reports no offenses when the `regex` call in the livecheck block uses parentheses" do
it "reports no offenses when the `regex` call in the `livecheck` block uses parentheses" do
expect_no_offenses(<<~RUBY)
class Foo < Formula
url "https://brew.sh/foo-1.0.tgz"
Expand Down
4 changes: 2 additions & 2 deletions Library/Homebrew/test/rubocops/livecheck/skip_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
RSpec.describe RuboCop::Cop::FormulaAudit::LivecheckSkip do
subject(:cop) { described_class.new }

it "reports an offense when a skipped formula's livecheck block contains other information" do
it "reports an offense when a skipped formula's `livecheck` block contains other information" do
expect_offense(<<~RUBY)
class Foo < Formula
url "https://brew.sh/foo-1.0.tgz"
Expand All @@ -29,7 +29,7 @@ class Foo < Formula
RUBY
end

it "reports no offenses when a skipped formula's livecheck block contains no other information" do
it "reports no offenses when a skipped formula's `livecheck` block contains no other information" do
expect_no_offenses(<<~RUBY)
class Foo < Formula
url "https://brew.sh/foo-1.0.tgz"
Expand Down
6 changes: 3 additions & 3 deletions Library/Homebrew/test/rubocops/livecheck/url_provided_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
RSpec.describe RuboCop::Cop::FormulaAudit::LivecheckUrlProvided do
subject(:cop) { described_class.new }

it "reports an offense when a `url` is not specified in a livecheck block" do
it "reports an offense when a `url` is not specified in a `livecheck` block" do
expect_offense(<<~RUBY)
class Foo < Formula
url "https://brew.sh/foo-1.0.tgz"
Expand All @@ -29,7 +29,7 @@ class Foo < Formula
RUBY
end

it "reports no offenses when a `url` and `regex` are specified in the livecheck block" do
it "reports no offenses when a `url` and `regex` are specified in the `livecheck` block" do
expect_no_offenses(<<~RUBY)
class Foo < Formula
url "https://brew.sh/foo-1.0.tgz"
Expand All @@ -42,7 +42,7 @@ class Foo < Formula
RUBY
end

it "reports no offenses when a `url` and `strategy` are specified in the livecheck block" do
it "reports no offenses when a `url` and `strategy` are specified in the `livecheck` block" do
expect_no_offenses(<<~RUBY)
class Foo < Formula
url "https://brew.sh/foo-1.0.tgz"
Expand Down
4 changes: 2 additions & 2 deletions Library/Homebrew/test/rubocops/livecheck/url_symbol_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
RSpec.describe RuboCop::Cop::FormulaAudit::LivecheckUrlSymbol do
subject(:cop) { described_class.new }

it "reports an offense when the `url` specified in the livecheck block is identical to a formula URL" do
it "reports an offense when the `url` specified in the `livecheck` block is identical to a formula URL" do
expect_offense(<<~RUBY)
class Foo < Formula
url "https://brew.sh/foo-1.0.tgz"
Expand All @@ -28,7 +28,7 @@ class Foo < Formula
RUBY
end

it "reports no offenses when the `url` specified in the livecheck block is not identical to a formula URL" do
it "reports no offenses when the `url` specified in the `livecheck` block is not identical to a formula URL" do
expect_no_offenses(<<~RUBY)
class Foo < Formula
url "https://brew.sh/foo-1.0.tgz"
Expand Down

0 comments on commit 79e20b3

Please sign in to comment.