Standardize livecheck block language formatting

This commit is contained in:
Sam Ford 2024-12-02 10:06:14 -05:00
parent 01cb74e525
commit 79e20b3512
No known key found for this signature in database
GPG Key ID: 7AF5CBEE1DD6F76D
13 changed files with 28 additions and 27 deletions

View File

@ -4179,7 +4179,7 @@ class Formula
end end
# {Livecheck} can be used to check for newer versions of the software. # {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} # {Formula} (if it exists) and sets the instance variables of a {Livecheck}
# object accordingly. This is used by `brew livecheck` to check for newer # object accordingly. This is used by `brew livecheck` to check for newer
# versions of the software. # versions of the software.

View File

@ -37,7 +37,7 @@ class Livecheck
# Sets the `@referenced_cask_name` instance variable to the provided `String` # Sets the `@referenced_cask_name` instance variable to the provided `String`
# or returns the `@referenced_cask_name` instance variable when no argument # or returns the `@referenced_cask_name` instance variable when no argument
# is provided. Inherited livecheck values from the referenced cask # 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 { sig {
params( params(
# Name of cask to inherit livecheck info from. # Name of cask to inherit livecheck info from.
@ -56,7 +56,7 @@ class Livecheck
# Sets the `@referenced_formula_name` instance variable to the provided # Sets the `@referenced_formula_name` instance variable to the provided
# `String` or returns the `@referenced_formula_name` instance variable when # `String` or returns the `@referenced_formula_name` instance variable when
# no argument is provided. Inherited livecheck values from the referenced # 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 { sig {
params( params(
# Name of formula to inherit livecheck info from. # Name of formula to inherit livecheck info from.

View File

@ -79,7 +79,7 @@ module Homebrew
full_name: false, full_name: false,
debug: 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_or_cask.livecheck
livecheck_formula = livecheck.formula livecheck_formula = livecheck.formula
livecheck_cask = livecheck.cask livecheck_cask = livecheck.cask

View File

@ -142,7 +142,7 @@ class Resource
end end
# {Livecheck} can be used to check for newer versions of the software. # {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} # {Resource} (if it exists) and sets the instance variables of a {Livecheck}
# object accordingly. This is used by `brew livecheck` to check for newer # object accordingly. This is used by `brew livecheck` to check for newer
# versions of the software. # versions of the software.

View File

@ -40,7 +40,8 @@ module RuboCop
method_nodes.select(&:block_type?).each do |node| method_nodes.select(&:block_type?).each do |node|
node.child_nodes.each do |child| node.child_nodes.each do |child|
child.each_node(:send) do |send_node| 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) next if send_node.method_name == :livecheck || inside_livecheck_defined?(send_node)
# Skip string interpolations. # Skip string interpolations.
if send_node.ancestors.drop_while { |a| !a.begin_type? }.any? { |a| a.dstr_type? || a.regexp_type? } if send_node.ancestors.drop_while { |a| !a.begin_type? }.any? { |a| a.dstr_type? || a.regexp_type? }

View File

@ -508,13 +508,13 @@ RSpec.describe Cask::Audit, :cask do
let(:online) { true } let(:online) { true }
let(:message) { /Version '[^']*' differs from '[^']*' retrieved by livecheck\./ } 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" } let(:cask_token) { "livecheck-skip" }
it { is_expected.not_to error_with(message) } it { is_expected.not_to error_with(message) }
end 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" } let(:cask_token) { "livecheck-skip-reference" }
it { is_expected.not_to error_with(message) } it { is_expected.not_to error_with(message) }
@ -526,7 +526,7 @@ RSpec.describe Cask::Audit, :cask do
it { is_expected.not_to error_with(message) } it { is_expected.not_to error_with(message) }
end 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" } let(:cask_token) { "livecheck-deprecated-reference" }
it { is_expected.not_to error_with(message) } it { is_expected.not_to error_with(message) }
@ -538,7 +538,7 @@ RSpec.describe Cask::Audit, :cask do
it { is_expected.not_to error_with(message) } it { is_expected.not_to error_with(message) }
end 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" } let(:cask_token) { "livecheck-disabled-reference" }
it { is_expected.not_to error_with(message) } it { is_expected.not_to error_with(message) }
@ -550,7 +550,7 @@ RSpec.describe Cask::Audit, :cask do
it { is_expected.not_to error_with(message) } it { is_expected.not_to error_with(message) }
end 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" } let(:cask_token) { "livecheck-version-latest-reference" }
it { is_expected.not_to error_with(message) } it { is_expected.not_to error_with(message) }
@ -562,7 +562,7 @@ RSpec.describe Cask::Audit, :cask do
it { is_expected.not_to error_with(message) } it { is_expected.not_to error_with(message) }
end 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" } let(:cask_token) { "livecheck-url-unversioned-reference" }
it { is_expected.not_to error_with(message) } it { is_expected.not_to error_with(message) }

View File

@ -705,7 +705,7 @@ RSpec.describe Formula do
end end
describe "#livecheck_defined?" do describe "#livecheck_defined?" do
specify "no livecheck block defined" do specify "no `livecheck` block defined" do
f = formula do f = formula do
url "https://brew.sh/test-1.0.tbz" url "https://brew.sh/test-1.0.tbz"
end end
@ -713,7 +713,7 @@ RSpec.describe Formula do
expect(f.livecheck_defined?).to be false expect(f.livecheck_defined?).to be false
end end
specify "livecheck block defined" do specify "`livecheck` block defined" do
f = formula do f = formula do
url "https://brew.sh/test-1.0.tbz" url "https://brew.sh/test-1.0.tbz"
livecheck do livecheck do

View File

@ -77,7 +77,7 @@ RSpec.describe Homebrew::Livecheck do
end end
describe "::resolve_livecheck_reference" do 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 it "returns [nil, []]" do
expect(livecheck.resolve_livecheck_reference(f)).to eq([nil, []]) expect(livecheck.resolve_livecheck_reference(f)).to eq([nil, []])
expect(livecheck.resolve_livecheck_reference(c)).to eq([nil, []]) expect(livecheck.resolve_livecheck_reference(c)).to eq([nil, []])

View File

@ -65,18 +65,18 @@ RSpec.describe Resource do
end end
describe "#livecheck" do 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.url).to eq("https://brew.sh/test/releases")
expect(livecheck_resource.livecheck.regex).to eq(/foo[._-]v?(\d+(?:\.\d+)+)\.t/i) expect(livecheck_resource.livecheck.regex).to eq(/foo[._-]v?(\d+(?:\.\d+)+)\.t/i)
end end
end end
describe "#livecheck_defined?" do 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 expect(resource.livecheck_defined?).to be false
end end
specify "livecheck block defined in resources" do specify "`livecheck` block defined in resources" do
expect(livecheck_resource.livecheck_defined?).to be true expect(livecheck_resource.livecheck_defined?).to be true
end end
end end

View File

@ -5,7 +5,7 @@ require "rubocops/livecheck"
RSpec.describe RuboCop::Cop::FormulaAudit::LivecheckRegexParentheses do RSpec.describe RuboCop::Cop::FormulaAudit::LivecheckRegexParentheses do
subject(:cop) { described_class.new } 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) expect_offense(<<~RUBY)
class Foo < Formula class Foo < Formula
url "https://brew.sh/foo-1.0.tgz" url "https://brew.sh/foo-1.0.tgz"
@ -30,7 +30,7 @@ RSpec.describe RuboCop::Cop::FormulaAudit::LivecheckRegexParentheses do
RUBY RUBY
end 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) expect_no_offenses(<<~RUBY)
class Foo < Formula class Foo < Formula
url "https://brew.sh/foo-1.0.tgz" url "https://brew.sh/foo-1.0.tgz"

View File

@ -5,7 +5,7 @@ require "rubocops/livecheck"
RSpec.describe RuboCop::Cop::FormulaAudit::LivecheckSkip do RSpec.describe RuboCop::Cop::FormulaAudit::LivecheckSkip do
subject(:cop) { described_class.new } 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) expect_offense(<<~RUBY)
class Foo < Formula class Foo < Formula
url "https://brew.sh/foo-1.0.tgz" url "https://brew.sh/foo-1.0.tgz"
@ -29,7 +29,7 @@ RSpec.describe RuboCop::Cop::FormulaAudit::LivecheckSkip do
RUBY RUBY
end 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) expect_no_offenses(<<~RUBY)
class Foo < Formula class Foo < Formula
url "https://brew.sh/foo-1.0.tgz" url "https://brew.sh/foo-1.0.tgz"

View File

@ -5,7 +5,7 @@ require "rubocops/livecheck"
RSpec.describe RuboCop::Cop::FormulaAudit::LivecheckUrlProvided do RSpec.describe RuboCop::Cop::FormulaAudit::LivecheckUrlProvided do
subject(:cop) { described_class.new } 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) expect_offense(<<~RUBY)
class Foo < Formula class Foo < Formula
url "https://brew.sh/foo-1.0.tgz" url "https://brew.sh/foo-1.0.tgz"
@ -29,7 +29,7 @@ RSpec.describe RuboCop::Cop::FormulaAudit::LivecheckUrlProvided do
RUBY RUBY
end 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) expect_no_offenses(<<~RUBY)
class Foo < Formula class Foo < Formula
url "https://brew.sh/foo-1.0.tgz" url "https://brew.sh/foo-1.0.tgz"
@ -42,7 +42,7 @@ RSpec.describe RuboCop::Cop::FormulaAudit::LivecheckUrlProvided do
RUBY RUBY
end 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) expect_no_offenses(<<~RUBY)
class Foo < Formula class Foo < Formula
url "https://brew.sh/foo-1.0.tgz" url "https://brew.sh/foo-1.0.tgz"

View File

@ -5,7 +5,7 @@ require "rubocops/livecheck"
RSpec.describe RuboCop::Cop::FormulaAudit::LivecheckUrlSymbol do RSpec.describe RuboCop::Cop::FormulaAudit::LivecheckUrlSymbol do
subject(:cop) { described_class.new } 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) expect_offense(<<~RUBY)
class Foo < Formula class Foo < Formula
url "https://brew.sh/foo-1.0.tgz" url "https://brew.sh/foo-1.0.tgz"
@ -28,7 +28,7 @@ RSpec.describe RuboCop::Cop::FormulaAudit::LivecheckUrlSymbol do
RUBY RUBY
end 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) expect_no_offenses(<<~RUBY)
class Foo < Formula class Foo < Formula
url "https://brew.sh/foo-1.0.tgz" url "https://brew.sh/foo-1.0.tgz"