From 01cb74e525db995f976fa3062e1140490f3dd745 Mon Sep 17 00:00:00 2001 From: Sam Ford <1584702+samford@users.noreply.github.com> Date: Wed, 27 Nov 2024 18:20:56 -0500 Subject: [PATCH 1/2] livecheck: clarify livecheckable language Formulae, casks, and resources have a `#livecheckable?` method that indicates whether they contain a `livecheck` block. This is intended to be read as "has a livecheckable?", not "is livecheckable?" (as livecheck can find versions for some packages/resources without a `livecheck` block). Unfortunately, correct understanding of this method's behavior [outside of documentation] relies on historical knowledge that few people possess, so this is often confusing to anyone who hasn't been working on livecheck since 2020. In the olden days, a "livecheckable" was a Ruby file containing a `livecheck` block (originally a hash) with a filename that corresponded to a related formula. The `livecheck` blocks in livecheckable files were integrated into their respective formulae in August 2020, so [first-party] livecheckables ceased to exist at that time. From that point forward, we simply referred to these as `livecheck` blocks. With that in mind, this clarifies the situation by replacing "livecheckable" language. This includes renaming `#livecheckable?` to `#livecheck_defined?`, replacing usage of "livecheckable" as a noun with "`livecheck` block", replacing "livecheckable" as a boolean with "livecheck_defined", and replacing incorrect usage of "livecheckable" as an adjective with "checkable". --- Library/Homebrew/cask/audit.rb | 8 +- Library/Homebrew/cask/cask.rbi | 2 + Library/Homebrew/cask/dsl.rb | 17 ++- .../dev-cmd/bump-unversioned-casks.rb | 2 +- Library/Homebrew/dev-cmd/bump.rb | 8 +- Library/Homebrew/dev-cmd/irb.rb | 2 +- Library/Homebrew/formula.rb | 20 ++- Library/Homebrew/livecheck/livecheck.rb | 23 ++-- Library/Homebrew/livecheck/skip_conditions.rb | 120 +++++++++--------- Library/Homebrew/resource.rb | 23 +++- .../Homebrew/rubocops/cask/no_overrides.rb | 10 +- Library/Homebrew/sorbet/rbi/dsl/cask/dsl.rbi | 2 +- Library/Homebrew/sorbet/rbi/dsl/formula.rbi | 3 + Library/Homebrew/test/formula_spec.rb | 6 +- .../Homebrew/test/livecheck/livecheck_spec.rb | 4 +- .../test/livecheck/skip_conditions_spec.rb | 92 +++++++------- Library/Homebrew/test/livecheck_spec.rb | 80 ++++++------ Library/Homebrew/test/resource_spec.rb | 6 +- 18 files changed, 237 insertions(+), 191 deletions(-) diff --git a/Library/Homebrew/cask/audit.rb b/Library/Homebrew/cask/audit.rb index 0bc9292a80d39..cd243526d8fbd 100644 --- a/Library/Homebrew/cask/audit.rb +++ b/Library/Homebrew/cask/audit.rb @@ -277,7 +277,7 @@ def audit_sha256_invalid sig { void } def audit_latest_with_livecheck return unless cask.version&.latest? - return unless cask.livecheckable? + return unless cask.livecheck_defined? return if cask.livecheck.skip? add_error "Casks with a `livecheck` should not use `version :latest`." @@ -299,7 +299,7 @@ def audit_hosting_with_livecheck(livecheck_result: audit_livecheck_version) return if cask.version&.latest? return if (url = cask.url).nil? return if block_url_offline? - return if cask.livecheckable? + return if cask.livecheck_defined? return if livecheck_result == :auto_detected add_livecheck = "please add a livecheck. See #{Formatter.url(LIVECHECK_REFERENCE_URL)}" @@ -693,7 +693,7 @@ def audit_min_os sig { returns(T.nilable(MacOSVersion)) } def livecheck_min_os return unless online? - return unless cask.livecheckable? + return unless cask.livecheck_defined? return if cask.livecheck.strategy != :sparkle # `Sparkle` strategy blocks that use the `items` argument (instead of @@ -924,7 +924,7 @@ def audit_url_https_availability sig { void } def audit_livecheck_https_availability return unless online? - return unless cask.livecheckable? + return unless cask.livecheck_defined? return unless (url = cask.livecheck.url) return if url.is_a?(Symbol) diff --git a/Library/Homebrew/cask/cask.rbi b/Library/Homebrew/cask/cask.rbi index 9605255e043c0..1f789206e3bf0 100644 --- a/Library/Homebrew/cask/cask.rbi +++ b/Library/Homebrew/cask/cask.rbi @@ -44,6 +44,8 @@ module Cask def livecheck; end + def livecheck_defined?; end + def livecheckable?; end def name; end diff --git a/Library/Homebrew/cask/dsl.rb b/Library/Homebrew/cask/dsl.rb index 0b6a63a0d3a6e..434159b57a66c 100644 --- a/Library/Homebrew/cask/dsl.rb +++ b/Library/Homebrew/cask/dsl.rb @@ -95,7 +95,8 @@ class DSL :disable_replacement, :discontinued?, # TODO: remove once discontinued? is removed (4.5.0) :livecheck, - :livecheckable?, + :livecheck_defined?, + :livecheckable?, # TODO: remove once `#livecheckable?` is removed :on_system_blocks_exist?, :on_system_block_min_os, :depends_on_set_in_block?, @@ -110,7 +111,7 @@ class DSL attr_reader :cask, :token, :deprecation_date, :deprecation_reason, :deprecation_replacement, :disable_date, :disable_reason, :disable_replacement, :on_system_block_min_os - attr_predicate :deprecated?, :disabled?, :livecheckable?, :on_system_blocks_exist?, :depends_on_set_in_block? + attr_predicate :deprecated?, :disabled?, :livecheck_defined?, :on_system_blocks_exist?, :depends_on_set_in_block? def initialize(cask) @cask = cask @@ -431,14 +432,22 @@ def livecheck(&block) @livecheck ||= Livecheck.new(cask) return @livecheck unless block - if !@cask.allow_reassignment && @livecheckable + if !@cask.allow_reassignment && @livecheck_defined raise CaskInvalidError.new(cask, "'livecheck' stanza may only appear once.") end - @livecheckable = true + @livecheck_defined = true @livecheck.instance_eval(&block) end + # Whether the cask contains a `livecheck` block. This is a legacy alias + # for `#livecheck_defined?`. + sig { returns(T::Boolean) } + def livecheckable? + # odeprecated "`livecheckable?`", "`livecheck_defined?`" + @livecheck_defined == true + end + # Declare that a cask is no longer functional or supported. # # NOTE: A warning will be shown when trying to install this cask. diff --git a/Library/Homebrew/dev-cmd/bump-unversioned-casks.rb b/Library/Homebrew/dev-cmd/bump-unversioned-casks.rb index 4d5bcdbbd93f5..9c6cf4d19ab2b 100644 --- a/Library/Homebrew/dev-cmd/bump-unversioned-casks.rb +++ b/Library/Homebrew/dev-cmd/bump-unversioned-casks.rb @@ -44,7 +44,7 @@ def run casks = args.named.to_paths(only: :cask, recurse_tap: true).map { |path| Cask::CaskLoader.load(path) } unversioned_casks = casks.select do |cask| - cask.url&.unversioned? && !cask.livecheckable? + cask.url&.unversioned? && !cask.livecheck_defined? end ohai "Unversioned Casks: #{unversioned_casks.count} (#{state.size} cached)" diff --git a/Library/Homebrew/dev-cmd/bump.rb b/Library/Homebrew/dev-cmd/bump.rb index a275eb7551d31..4b2be96bc9c53 100644 --- a/Library/Homebrew/dev-cmd/bump.rb +++ b/Library/Homebrew/dev-cmd/bump.rb @@ -137,7 +137,7 @@ def run def skip_repology?(formula_or_cask) return true unless args.repology? - (ENV["CI"].present? && args.open_pr? && formula_or_cask.livecheckable?) || + (ENV["CI"].present? && args.open_pr? && formula_or_cask.livecheck_defined?) || (formula_or_cask.is_a?(Formula) && formula_or_cask.versioned_formula?) end @@ -329,7 +329,7 @@ def retrieve_versions_by_arch(formula_or_cask:, repositories:, name:) "skipped" elsif repology_latest.is_a?(Version) && repology_latest > current_version_value && - !loaded_formula_or_cask.livecheckable? && + !loaded_formula_or_cask.livecheck_defined? && current_version_value != "latest" repology_latest end.presence @@ -490,8 +490,8 @@ def retrieve_and_display_info_and_open_pr(formula_or_cask, name, repositories, a if repology_latest.is_a?(Version) && repology_latest > current_version.general && repology_latest > new_version.general && - formula_or_cask.livecheckable? - puts "#{title_name} was not bumped to the Repology version because it's livecheckable." + formula_or_cask.livecheck_defined? + puts "#{title_name} was not bumped to the Repology version because it has a `livecheck` block." end if new_version.blank? || versions_equal || (!new_version.general.is_a?(Version) && !version_info.multiple_versions) diff --git a/Library/Homebrew/dev-cmd/irb.rb b/Library/Homebrew/dev-cmd/irb.rb index 40a3fd9fc9c27..31cf968bcc34b 100644 --- a/Library/Homebrew/dev-cmd/irb.rb +++ b/Library/Homebrew/dev-cmd/irb.rb @@ -64,7 +64,7 @@ def run :mpd.f.recursive_dependencies.reject(&:installed?) 'vlc'.c # => instance of the vlc cask - :tsh.c.livecheckable? + :tsh.c.livecheck_defined? EOS return end diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb index 98f6bc8814140..4196ed290e915 100644 --- a/Library/Homebrew/formula.rb +++ b/Library/Homebrew/formula.rb @@ -454,6 +454,11 @@ def bottle_for_tag(tag = nil) # @see .livecheck= delegate livecheck: :"self.class" + # Is a livecheck specification defined for the software? + # @!method livecheck_defined? + # @see .livecheck_defined? + delegate livecheck_defined?: :"self.class" + # Is a livecheck specification defined for the software? # @!method livecheckable? # @see .livecheckable? @@ -3537,8 +3542,19 @@ def network_access_allowed?(phase) # It returns `true` when a `livecheck` block is present in the {Formula} # and `false` otherwise. sig { returns(T::Boolean) } + def livecheck_defined? + @livecheck_defined == true + end + + # Checks whether a `livecheck` specification is defined or not. This is a + # legacy alias for `#livecheck_defined?`. + # + # It returns `true` when a `livecheck` block is present in the {Formula} + # and `false` otherwise. + sig { returns(T::Boolean) } def livecheckable? - @livecheckable == true + # odeprecated "`livecheckable?`", "`livecheck_defined?`" + @livecheck_defined == true end # Checks whether a service specification is defined or not. @@ -4183,7 +4199,7 @@ def test(&block) def livecheck(&block) return @livecheck unless block - @livecheckable = true + @livecheck_defined = true @livecheck.instance_eval(&block) end diff --git a/Library/Homebrew/livecheck/livecheck.rb b/Library/Homebrew/livecheck/livecheck.rb index 4fd86a08f8e03..3aa03953379f2 100644 --- a/Library/Homebrew/livecheck/livecheck.rb +++ b/Library/Homebrew/livecheck/livecheck.rb @@ -347,7 +347,7 @@ def self.run_checks( newer_than_upstream: is_newer_than_upstream, }.compact info[:meta] = { - livecheckable: formula_or_cask.livecheckable?, + livecheck_defined: formula_or_cask.livecheck_defined?, } info[:meta][:head_only] = true if formula&.head_only? info[:meta].merge!(version_info[:meta]) if version_info.present? && version_info.key?(:meta) @@ -465,7 +465,7 @@ def self.status_hash(package_or_resource, status_str, messages = nil, full_name: status_hash[:messages] = messages if messages.is_a?(Array) status_hash[:meta] = { - livecheckable: package_or_resource.livecheckable?, + livecheck_defined: package_or_resource.livecheck_defined?, } status_hash[:meta][:head_only] = true if formula&.head_only? @@ -478,7 +478,7 @@ def self.status_hash(package_or_resource, status_str, messages = nil, full_name: package_or_resource_s = info[:resource].present? ? " " : "" package_or_resource_s += "#{Tty.blue}#{info[:formula] || info[:cask] || info[:resource]}#{Tty.reset}" package_or_resource_s += " (cask)" if ambiguous_cask - package_or_resource_s += " (guessed)" if verbose && !info[:meta][:livecheckable] + package_or_resource_s += " (guessed)" if verbose && !info[:meta][:livecheck_defined] current_s = if info[:version][:newer_than_upstream] "#{Tty.red}#{info[:version][:current]}#{Tty.reset}" @@ -608,7 +608,7 @@ def self.latest_version( formula = formula_or_cask if formula_or_cask.is_a?(Formula) cask = formula_or_cask if formula_or_cask.is_a?(Cask::Cask) - has_livecheckable = formula_or_cask.livecheckable? + livecheck_defined = formula_or_cask.livecheck_defined? livecheck = formula_or_cask.livecheck referenced_livecheck = referenced_formula_or_cask&.livecheck @@ -632,7 +632,7 @@ def self.latest_version( elsif cask puts "Cask: #{cask_name(formula_or_cask, full_name:)}" end - puts "Livecheckable?: #{has_livecheckable ? "Yes" : "No"}" + puts "livecheck block?: #{livecheck_defined ? "Yes" : "No"}" puts "Throttle: #{livecheck_throttle}" if livecheck_throttle livecheck_references.each do |ref_formula_or_cask| @@ -736,7 +736,7 @@ def self.latest_version( match_version_map.delete_if do |_match, version| next true if version.blank? - next false if has_livecheckable + next false if livecheck_defined UNSTABLE_VERSION_KEYWORDS.any? do |rejection| version.to_s.include?(rejection) @@ -839,12 +839,12 @@ def self.resource_version( quiet: false, verbose: false ) - has_livecheckable = resource.livecheckable? + livecheck_defined = resource.livecheck_defined? if debug puts "\n\n" puts "Resource: #{resource.name}" - puts "Livecheckable?: #{has_livecheckable ? "Yes" : "No"}" + puts "livecheck block?: #{livecheck_defined ? "Yes" : "No"}" end resource_version_info = {} @@ -939,7 +939,7 @@ def self.resource_version( match_version_map.delete_if do |_match, version| next true if version.blank? - next false if has_livecheckable + next false if livecheck_defined UNSTABLE_VERSION_KEYWORDS.any? do |rejection| version.to_s.include?(rejection) @@ -978,7 +978,10 @@ def self.resource_version( }, } - resource_version_info[:meta] = { livecheckable: has_livecheckable, url: {} } + resource_version_info[:meta] = { + livecheck_defined: livecheck_defined, + url: {}, + } if livecheck_url.is_a?(Symbol) && livecheck_url_string resource_version_info[:meta][:url][:symbol] = livecheck_url end diff --git a/Library/Homebrew/livecheck/skip_conditions.rb b/Library/Homebrew/livecheck/skip_conditions.rb index e8fc9a9ebd83e..d1c5b7cc68dd1 100644 --- a/Library/Homebrew/livecheck/skip_conditions.rb +++ b/Library/Homebrew/livecheck/skip_conditions.rb @@ -9,14 +9,14 @@ module SkipConditions sig { params( package_or_resource: T.any(Formula, Cask::Cask, Resource), - livecheckable: T::Boolean, + livecheck_defined: T::Boolean, full_name: T::Boolean, verbose: T::Boolean, ).returns(T::Hash[Symbol, T.untyped]) } private_class_method def self.package_or_resource_skip( package_or_resource, - livecheckable, + livecheck_defined, full_name: false, verbose: false ) @@ -32,7 +32,7 @@ module SkipConditions skip_message = if package_or_resource.livecheck.skip_msg.present? package_or_resource.livecheck.skip_msg - elsif !livecheckable + elsif !livecheck_defined if stable_from_google_code_archive "Stable URL is from Google Code Archive" elsif stable_from_internet_archive @@ -50,19 +50,19 @@ module SkipConditions sig { params( - formula: Formula, - _livecheckable: T::Boolean, - full_name: T::Boolean, - verbose: T::Boolean, + formula: Formula, + _livecheck_defined: T::Boolean, + full_name: T::Boolean, + verbose: T::Boolean, ).returns(T::Hash[Symbol, T.untyped]) } - private_class_method def self.formula_head_only(formula, _livecheckable, full_name: false, verbose: false) + private_class_method def self.formula_head_only(formula, _livecheck_defined, full_name: false, verbose: false) return {} if !formula.head_only? || formula.any_version_installed? Livecheck.status_hash( formula, "error", - ["HEAD only formula must be installed to be livecheckable"], + ["HEAD only formula must be installed to be checkable"], full_name:, verbose:, ) @@ -70,86 +70,86 @@ module SkipConditions sig { params( - formula: Formula, - livecheckable: T::Boolean, - full_name: T::Boolean, - verbose: T::Boolean, + formula: Formula, + livecheck_defined: T::Boolean, + full_name: T::Boolean, + verbose: T::Boolean, ).returns(T::Hash[Symbol, T.untyped]) } - private_class_method def self.formula_deprecated(formula, livecheckable, full_name: false, verbose: false) - return {} if !formula.deprecated? || livecheckable + private_class_method def self.formula_deprecated(formula, livecheck_defined, full_name: false, verbose: false) + return {} if !formula.deprecated? || livecheck_defined Livecheck.status_hash(formula, "deprecated", full_name:, verbose:) end sig { params( - formula: Formula, - livecheckable: T::Boolean, - full_name: T::Boolean, - verbose: T::Boolean, + formula: Formula, + livecheck_defined: T::Boolean, + full_name: T::Boolean, + verbose: T::Boolean, ).returns(T::Hash[Symbol, T.untyped]) } - private_class_method def self.formula_disabled(formula, livecheckable, full_name: false, verbose: false) - return {} if !formula.disabled? || livecheckable + private_class_method def self.formula_disabled(formula, livecheck_defined, full_name: false, verbose: false) + return {} if !formula.disabled? || livecheck_defined Livecheck.status_hash(formula, "disabled", full_name:, verbose:) end sig { params( - formula: Formula, - livecheckable: T::Boolean, - full_name: T::Boolean, - verbose: T::Boolean, + formula: Formula, + livecheck_defined: T::Boolean, + full_name: T::Boolean, + verbose: T::Boolean, ).returns(T::Hash[Symbol, T.untyped]) } - private_class_method def self.formula_versioned(formula, livecheckable, full_name: false, verbose: false) - return {} if !formula.versioned_formula? || livecheckable + private_class_method def self.formula_versioned(formula, livecheck_defined, full_name: false, verbose: false) + return {} if !formula.versioned_formula? || livecheck_defined Livecheck.status_hash(formula, "versioned", full_name:, verbose:) end sig { params( - cask: Cask::Cask, - livecheckable: T::Boolean, - full_name: T::Boolean, - verbose: T::Boolean, + cask: Cask::Cask, + livecheck_defined: T::Boolean, + full_name: T::Boolean, + verbose: T::Boolean, ).returns(T::Hash[Symbol, T.untyped]) } - private_class_method def self.cask_deprecated(cask, livecheckable, full_name: false, verbose: false) - return {} if !cask.deprecated? || livecheckable + private_class_method def self.cask_deprecated(cask, livecheck_defined, full_name: false, verbose: false) + return {} if !cask.deprecated? || livecheck_defined Livecheck.status_hash(cask, "deprecated", full_name:, verbose:) end sig { params( - cask: Cask::Cask, - livecheckable: T::Boolean, - full_name: T::Boolean, - verbose: T::Boolean, + cask: Cask::Cask, + livecheck_defined: T::Boolean, + full_name: T::Boolean, + verbose: T::Boolean, ).returns(T::Hash[Symbol, T.untyped]) } - private_class_method def self.cask_disabled(cask, livecheckable, full_name: false, verbose: false) - return {} if !cask.disabled? || livecheckable + private_class_method def self.cask_disabled(cask, livecheck_defined, full_name: false, verbose: false) + return {} if !cask.disabled? || livecheck_defined Livecheck.status_hash(cask, "disabled", full_name:, verbose:) end sig { params( - cask: Cask::Cask, - _livecheckable: T::Boolean, - full_name: T::Boolean, - verbose: T::Boolean, - extract_plist: T::Boolean, + cask: Cask::Cask, + _livecheck_defined: T::Boolean, + full_name: T::Boolean, + verbose: T::Boolean, + extract_plist: T::Boolean, ).returns(T::Hash[Symbol, T.untyped]) } private_class_method def self.cask_extract_plist( cask, - _livecheckable, + _livecheck_defined, full_name: false, verbose: false, extract_plist: false @@ -167,28 +167,28 @@ module SkipConditions sig { params( - cask: Cask::Cask, - livecheckable: T::Boolean, - full_name: T::Boolean, - verbose: T::Boolean, + cask: Cask::Cask, + livecheck_defined: T::Boolean, + full_name: T::Boolean, + verbose: T::Boolean, ).returns(T::Hash[Symbol, T.untyped]) } - private_class_method def self.cask_version_latest(cask, livecheckable, full_name: false, verbose: false) - return {} if !(cask.present? && cask.version&.latest?) || livecheckable + private_class_method def self.cask_version_latest(cask, livecheck_defined, full_name: false, verbose: false) + return {} if !(cask.present? && cask.version&.latest?) || livecheck_defined Livecheck.status_hash(cask, "latest", full_name:, verbose:) end sig { params( - cask: Cask::Cask, - livecheckable: T::Boolean, - full_name: T::Boolean, - verbose: T::Boolean, + cask: Cask::Cask, + livecheck_defined: T::Boolean, + full_name: T::Boolean, + verbose: T::Boolean, ).returns(T::Hash[Symbol, T.untyped]) } - private_class_method def self.cask_url_unversioned(cask, livecheckable, full_name: false, verbose: false) - return {} if !(cask.present? && cask.url&.unversioned?) || livecheckable + private_class_method def self.cask_url_unversioned(cask, livecheck_defined, full_name: false, verbose: false) + return {} if !(cask.present? && cask.url&.unversioned?) || livecheck_defined Livecheck.status_hash(cask, "unversioned", full_name:, verbose:) end @@ -232,7 +232,7 @@ module SkipConditions ).returns(T::Hash[Symbol, T.untyped]) } def self.skip_information(package_or_resource, full_name: false, verbose: false, extract_plist: true) - livecheckable = package_or_resource.livecheckable? + livecheck_defined = package_or_resource.livecheck_defined? checks = case package_or_resource when Formula @@ -246,9 +246,9 @@ def self.skip_information(package_or_resource, full_name: false, verbose: false, checks.each do |method_name| skip_hash = case method_name when :cask_extract_plist - send(method_name, package_or_resource, livecheckable, full_name:, verbose:, extract_plist:) + send(method_name, package_or_resource, livecheck_defined, full_name:, verbose:, extract_plist:) else - send(method_name, package_or_resource, livecheckable, full_name:, verbose:) + send(method_name, package_or_resource, livecheck_defined, full_name:, verbose:) end return skip_hash if skip_hash.present? end diff --git a/Library/Homebrew/resource.rb b/Library/Homebrew/resource.rb index f06160045845f..636cd0705b1a6 100644 --- a/Library/Homebrew/resource.rb +++ b/Library/Homebrew/resource.rb @@ -29,7 +29,7 @@ def initialize(name = nil, &block) @name = name @patches = [] @livecheck = Livecheck.new(self) - @livecheckable = false + @livecheck_defined = false @insecure = false instance_eval(&block) if block end @@ -160,15 +160,28 @@ def fetch(verify_download_integrity: true, timeout: nil, quiet: false) def livecheck(&block) return @livecheck unless block - @livecheckable = true + @livecheck_defined = true @livecheck.instance_eval(&block) end # Whether a livecheck specification is defined or not. - # It returns true when a `livecheck` block is present in the {Resource} and - # false otherwise and is used by livecheck. + # + # It returns `true` when a `livecheck` block is present in the {Resource} + # and `false` otherwise. + sig { returns(T::Boolean) } + def livecheck_defined? + @livecheck_defined == true + end + + # Whether a livecheck specification is defined or not. This is a legacy alias + # for `#livecheck_defined?`. + # + # It returns `true` when a `livecheck` block is present in the {Resource} + # and `false` otherwise. + sig { returns(T::Boolean) } def livecheckable? - @livecheckable == true + # odeprecated "`livecheckable?`", "`livecheck_defined?`" + @livecheck_defined == true end def sha256(val) diff --git a/Library/Homebrew/rubocops/cask/no_overrides.rb b/Library/Homebrew/rubocops/cask/no_overrides.rb index 0493246252b20..e1bdb5e77cc8c 100644 --- a/Library/Homebrew/rubocops/cask/no_overrides.rb +++ b/Library/Homebrew/rubocops/cask/no_overrides.rb @@ -41,7 +41,7 @@ def on_system_stanzas(on_system) 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`. - next if send_node.method_name == :livecheck || inside_livecheck_block?(send_node) + 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? } next @@ -55,15 +55,15 @@ def on_system_stanzas(on_system) names end - def inside_livecheck_block?(node) - single_stanza_livecheck_block?(node) || multi_stanza_livecheck_block?(node) + def inside_livecheck_defined?(node) + single_stanza_livecheck_defined?(node) || multi_stanza_livecheck_defined?(node) end - def single_stanza_livecheck_block?(node) + def single_stanza_livecheck_defined?(node) node.parent.block_type? && node.parent.method_name == :livecheck end - def multi_stanza_livecheck_block?(node) + def multi_stanza_livecheck_defined?(node) grandparent_node = node.parent.parent node.parent.begin_type? && grandparent_node.block_type? && grandparent_node.method_name == :livecheck end diff --git a/Library/Homebrew/sorbet/rbi/dsl/cask/dsl.rbi b/Library/Homebrew/sorbet/rbi/dsl/cask/dsl.rbi index ecc5e8731a629..93510e134bdb0 100644 --- a/Library/Homebrew/sorbet/rbi/dsl/cask/dsl.rbi +++ b/Library/Homebrew/sorbet/rbi/dsl/cask/dsl.rbi @@ -16,7 +16,7 @@ class Cask::DSL def disabled?; end sig { returns(T::Boolean) } - def livecheckable?; end + def livecheck_defined?; end sig { returns(T::Boolean) } def on_system_blocks_exist?; end diff --git a/Library/Homebrew/sorbet/rbi/dsl/formula.rbi b/Library/Homebrew/sorbet/rbi/dsl/formula.rbi index c8ebc68cbd840..3ced914c9ce9c 100644 --- a/Library/Homebrew/sorbet/rbi/dsl/formula.rbi +++ b/Library/Homebrew/sorbet/rbi/dsl/formula.rbi @@ -90,6 +90,9 @@ class Formula sig { params(args: T.untyped, block: T.untyped).returns(T.untyped) } def livecheck(*args, &block); end + sig { params(args: T.untyped, block: T.untyped).returns(T::Boolean) } + def livecheck_defined?(*args, &block); end + sig { params(args: T.untyped, block: T.untyped).returns(T::Boolean) } def livecheckable?(*args, &block); end diff --git a/Library/Homebrew/test/formula_spec.rb b/Library/Homebrew/test/formula_spec.rb index f2f9a993fbae5..69529c1e8d4d1 100644 --- a/Library/Homebrew/test/formula_spec.rb +++ b/Library/Homebrew/test/formula_spec.rb @@ -704,13 +704,13 @@ def post_install expect(f.livecheck.regex).to eq(/test-v?(\d+(?:\.\d+)+)\.t/i) end - describe "#livecheckable?" do + describe "#livecheck_defined?" do specify "no livecheck block defined" do f = formula do url "https://brew.sh/test-1.0.tbz" end - expect(f.livecheckable?).to be false + expect(f.livecheck_defined?).to be false end specify "livecheck block defined" do @@ -721,7 +721,7 @@ def post_install end end - expect(f.livecheckable?).to be true + expect(f.livecheck_defined?).to be true end specify "livecheck references Formula URL" do diff --git a/Library/Homebrew/test/livecheck/livecheck_spec.rb b/Library/Homebrew/test/livecheck/livecheck_spec.rb index ecd5a0902d6bd..c91caebb693eb 100644 --- a/Library/Homebrew/test/livecheck/livecheck_spec.rb +++ b/Library/Homebrew/test/livecheck/livecheck_spec.rb @@ -111,7 +111,7 @@ status: "error", messages: ["Unable to get versions"], meta: { - livecheckable: true, + livecheck_defined: true, }, }) end @@ -123,7 +123,7 @@ status: "error", messages: ["Unable to get versions"], meta: { - livecheckable: true, + livecheck_defined: true, }, }) end diff --git a/Library/Homebrew/test/livecheck/skip_conditions_spec.rb b/Library/Homebrew/test/livecheck/skip_conditions_spec.rb index 7187ef7dada24..0ea8445649199 100644 --- a/Library/Homebrew/test/livecheck/skip_conditions_spec.rb +++ b/Library/Homebrew/test/livecheck/skip_conditions_spec.rb @@ -178,30 +178,30 @@ formula: "test_deprecated", status: "deprecated", meta: { - livecheckable: false, + livecheck_defined: false, }, }, disabled: { formula: "test_disabled", status: "disabled", meta: { - livecheckable: false, + livecheck_defined: false, }, }, versioned: { formula: "test@0.0.1", status: "versioned", meta: { - livecheckable: false, + livecheck_defined: false, }, }, head_only: { formula: "test_head_only", status: "error", - messages: ["HEAD only formula must be installed to be livecheckable"], + messages: ["HEAD only formula must be installed to be checkable"], meta: { - head_only: true, - livecheckable: false, + livecheck_defined: false, + head_only: true, }, }, gist: { @@ -209,7 +209,7 @@ status: "skipped", messages: ["Stable URL is a GitHub Gist"], meta: { - livecheckable: false, + livecheck_defined: false, }, }, google_code_archive: { @@ -217,7 +217,7 @@ status: "skipped", messages: ["Stable URL is from Google Code Archive"], meta: { - livecheckable: false, + livecheck_defined: false, }, }, internet_archive: { @@ -225,14 +225,14 @@ status: "skipped", messages: ["Stable URL is from Internet Archive"], meta: { - livecheckable: false, + livecheck_defined: false, }, }, skip: { formula: "test_skip", status: "skipped", meta: { - livecheckable: true, + livecheck_defined: true, }, }, skip_with_message: { @@ -240,7 +240,7 @@ status: "skipped", messages: ["Not maintained"], meta: { - livecheckable: true, + livecheck_defined: true, }, }, }, @@ -249,14 +249,14 @@ cask: "test_deprecated", status: "deprecated", meta: { - livecheckable: false, + livecheck_defined: false, }, }, disabled: { cask: "test_disabled", status: "disabled", meta: { - livecheckable: false, + livecheck_defined: false, }, }, extract_plist: { @@ -264,28 +264,28 @@ status: "skipped", messages: ["Use `--extract-plist` to enable checking multiple casks with ExtractPlist strategy"], meta: { - livecheckable: true, + livecheck_defined: true, }, }, latest: { cask: "test_latest", status: "latest", meta: { - livecheckable: false, + livecheck_defined: false, }, }, unversioned: { cask: "test_unversioned", status: "unversioned", meta: { - livecheckable: false, + livecheck_defined: false, }, }, skip: { cask: "test_skip", status: "skipped", meta: { - livecheckable: true, + livecheck_defined: true, }, }, skip_with_message: { @@ -293,7 +293,7 @@ status: "skipped", messages: ["Not maintained"], meta: { - livecheckable: true, + livecheck_defined: true, }, }, }, @@ -301,21 +301,21 @@ end describe "::skip_information" do - context "when a formula without a livecheckable is deprecated" do + context "when a formula without a `livecheck` block is deprecated" do it "skips" do expect(skip_conditions.skip_information(formulae[:deprecated])) .to eq(status_hashes[:formula][:deprecated]) end end - context "when a formula without a livecheckable is disabled" do + context "when a formula without a `livecheck` block is disabled" do it "skips" do expect(skip_conditions.skip_information(formulae[:disabled])) .to eq(status_hashes[:formula][:disabled]) end end - context "when a formula without a livecheckable is versioned" do + context "when a formula without a `livecheck` block is versioned" do it "skips" do expect(skip_conditions.skip_information(formulae[:versioned])) .to eq(status_hashes[:formula][:versioned]) @@ -329,21 +329,21 @@ end end - context "when a formula without a livecheckable has a GitHub Gist stable URL" do + context "when a formula without a `livecheck` block has a GitHub Gist stable URL" do it "skips" do expect(skip_conditions.skip_information(formulae[:gist])) .to eq(status_hashes[:formula][:gist]) end end - context "when a formula without a livecheckable has a Google Code Archive stable URL" do + context "when a formula without a `livecheck` block has a Google Code Archive stable URL" do it "skips" do expect(skip_conditions.skip_information(formulae[:google_code_archive])) .to eq(status_hashes[:formula][:google_code_archive]) end end - context "when a formula without a livecheckable has an Internet Archive stable URL" do + context "when a formula without a `livecheck` block has an Internet Archive stable URL" do it "skips" do expect(skip_conditions.skip_information(formulae[:internet_archive])) .to eq(status_hashes[:formula][:internet_archive]) @@ -360,14 +360,14 @@ end end - context "when a cask without a livecheckable is deprecated" do + context "when a cask without a `livecheck` block is deprecated" do it "skips" do expect(skip_conditions.skip_information(casks[:deprecated])) .to eq(status_hashes[:cask][:deprecated]) end end - context "when a cask without a livecheckable is disabled" do + context "when a cask without a `livecheck` block is disabled" do it "skips" do expect(skip_conditions.skip_information(casks[:disabled])) .to eq(status_hashes[:cask][:disabled]) @@ -381,14 +381,14 @@ end end - context "when a cask without a livecheckable has `version :latest`" do + context "when a cask without a `livecheck` block has `version :latest`" do it "skips" do expect(skip_conditions.skip_information(casks[:latest])) .to eq(status_hashes[:cask][:latest]) end end - context "when a cask without a livecheckable has an unversioned URL" do + context "when a cask without a `livecheck` block has an unversioned URL" do it "skips" do expect(skip_conditions.skip_information(casks[:unversioned])) .to eq(status_hashes[:cask][:unversioned]) @@ -417,21 +417,21 @@ describe "::referenced_skip_information" do let(:original_name) { "original" } - context "when a formula without a livecheckable is deprecated" do + context "when a formula without a `livecheck` block is deprecated" do it "errors" do expect { skip_conditions.referenced_skip_information(formulae[:deprecated], original_name) } .to raise_error(RuntimeError, "Referenced formula (test_deprecated) is skipped as deprecated") end end - context "when a formula without a livecheckable is disabled" do + context "when a formula without a `livecheck` block is disabled" do it "errors" do expect { skip_conditions.referenced_skip_information(formulae[:disabled], original_name) } .to raise_error(RuntimeError, "Referenced formula (test_disabled) is skipped as disabled") end end - context "when a formula without a livecheckable is versioned" do + context "when a formula without a `livecheck` block is versioned" do it "errors" do expect { skip_conditions.referenced_skip_information(formulae[:versioned], original_name) } .to raise_error(RuntimeError, "Referenced formula (test@0.0.1) is skipped as versioned") @@ -445,21 +445,21 @@ end end - context "when a formula without a livecheckable has a GitHub Gist stable URL" do + context "when a formula without a `livecheck` block has a GitHub Gist stable URL" do it "errors" do expect { skip_conditions.referenced_skip_information(formulae[:gist], original_name) } .to raise_error(RuntimeError, "Referenced formula (test_gist) is automatically skipped") end end - context "when a formula without a livecheckable has a Google Code Archive stable URL" do + context "when a formula without a `livecheck` block has a Google Code Archive stable URL" do it "errors" do expect { skip_conditions.referenced_skip_information(formulae[:google_code_archive], original_name) } .to raise_error(RuntimeError, "Referenced formula (test_google_code_archive) is automatically skipped") end end - context "when a formula without a livecheckable has an Internet Archive stable URL" do + context "when a formula without a `livecheck` block has an Internet Archive stable URL" do it "errors" do expect { skip_conditions.referenced_skip_information(formulae[:internet_archive], original_name) } .to raise_error(RuntimeError, "Referenced formula (test_internet_archive) is automatically skipped") @@ -476,14 +476,14 @@ end end - context "when a cask without a livecheckable is deprecated" do + context "when a cask without a `livecheck` block is deprecated" do it "errors" do expect { skip_conditions.referenced_skip_information(casks[:deprecated], original_name) } .to raise_error(RuntimeError, "Referenced cask (test_deprecated) is skipped as deprecated") end end - context "when a cask without a livecheckable is disabled" do + context "when a cask without a `livecheck` block is disabled" do it "errors" do expect { skip_conditions.referenced_skip_information(casks[:disabled], original_name) } .to raise_error(RuntimeError, "Referenced cask (test_disabled) is skipped as disabled") @@ -499,14 +499,14 @@ end end - context "when a cask without a livecheckable has `version :latest`" do + context "when a cask without a `livecheck` block has `version :latest`" do it "errors" do expect { skip_conditions.referenced_skip_information(casks[:latest], original_name) } .to raise_error(RuntimeError, "Referenced cask (test_latest) is skipped as latest") end end - context "when a cask without a livecheckable has an unversioned URL" do + context "when a cask without a `livecheck` block has an unversioned URL" do it "errors" do expect { skip_conditions.referenced_skip_information(casks[:unversioned], original_name) } .to raise_error(RuntimeError, "Referenced cask (test_unversioned) is skipped as unversioned") @@ -533,7 +533,7 @@ end describe "::print_skip_information" do - context "when a formula without a livecheckable is deprecated" do + context "when a formula without a `livecheck` block is deprecated" do it "prints skip information" do expect { skip_conditions.print_skip_information(status_hashes[:formula][:deprecated]) } .to output("test_deprecated: deprecated\n").to_stdout @@ -541,7 +541,7 @@ end end - context "when a formula without a livecheckable is disabled" do + context "when a formula without a `livecheck` block is disabled" do it "prints skip information" do expect { skip_conditions.print_skip_information(status_hashes[:formula][:disabled]) } .to output("test_disabled: disabled\n").to_stdout @@ -549,7 +549,7 @@ end end - context "when a formula without a livecheckable is versioned" do + context "when a formula without a `livecheck` block is versioned" do it "prints skip information" do expect { skip_conditions.print_skip_information(status_hashes[:formula][:versioned]) } .to output("test@0.0.1: versioned\n").to_stdout @@ -560,7 +560,7 @@ context "when a formula is HEAD-only and not installed" do it "prints skip information" do expect { skip_conditions.print_skip_information(status_hashes[:formula][:head_only]) } - .to output("test_head_only: HEAD only formula must be installed to be livecheckable\n").to_stdout + .to output("test_head_only: HEAD only formula must be installed to be checkable\n").to_stdout .and not_to_output.to_stderr end end @@ -601,7 +601,7 @@ end end - context "when the cask is deprecated without a livecheckable" do + context "when the cask is deprecated without a `livecheck` block" do it "prints skip information" do expect { skip_conditions.print_skip_information(status_hashes[:cask][:deprecated]) } .to output("test_deprecated: deprecated\n").to_stdout @@ -609,7 +609,7 @@ end end - context "when the cask is disabled without a livecheckable" do + context "when the cask is disabled without a `livecheck` block" do it "prints skip information" do expect { skip_conditions.print_skip_information(status_hashes[:cask][:disabled]) } .to output("test_disabled: disabled\n").to_stdout @@ -617,7 +617,7 @@ end end - context "when the cask has `version :latest` without a livecheckable" do + context "when the cask has `version :latest` without a `livecheck` block" do it "prints skip information" do expect { skip_conditions.print_skip_information(status_hashes[:cask][:latest]) } .to output("test_latest: latest\n").to_stdout @@ -625,7 +625,7 @@ end end - context "when the cask has an unversioned URL without a livecheckable" do + context "when the cask has an unversioned URL without a `livecheck` block" do it "prints skip information" do expect { skip_conditions.print_skip_information(status_hashes[:cask][:unversioned]) } .to output("test_unversioned: unversioned\n").to_stdout diff --git a/Library/Homebrew/test/livecheck_spec.rb b/Library/Homebrew/test/livecheck_spec.rb index f0136ca886e1b..51f0e1c9290a7 100644 --- a/Library/Homebrew/test/livecheck_spec.rb +++ b/Library/Homebrew/test/livecheck_spec.rb @@ -11,7 +11,7 @@ head "https://github.com/Homebrew/brew.git" end end - let(:livecheckable_f) { described_class.new(f.class) } + let(:livecheck_f) { described_class.new(f.class) } let(:c) do Cask::CaskLoader.load(+<<-RUBY) @@ -25,89 +25,89 @@ end RUBY end - let(:livecheckable_c) { described_class.new(c) } + let(:livecheck_c) { described_class.new(c) } describe "#formula" do it "returns nil if not set" do - expect(livecheckable_f.formula).to be_nil + expect(livecheck_f.formula).to be_nil end it "returns the String if set" do - livecheckable_f.formula("other-formula") - expect(livecheckable_f.formula).to eq("other-formula") + livecheck_f.formula("other-formula") + expect(livecheck_f.formula).to eq("other-formula") end it "raises a TypeError if the argument isn't a String" do expect do - livecheckable_f.formula(123) + livecheck_f.formula(123) end.to raise_error TypeError end end describe "#cask" do it "returns nil if not set" do - expect(livecheckable_c.cask).to be_nil + expect(livecheck_c.cask).to be_nil end it "returns the String if set" do - livecheckable_c.cask("other-cask") - expect(livecheckable_c.cask).to eq("other-cask") + livecheck_c.cask("other-cask") + expect(livecheck_c.cask).to eq("other-cask") end end describe "#regex" do it "returns nil if not set" do - expect(livecheckable_f.regex).to be_nil + expect(livecheck_f.regex).to be_nil end it "returns the Regexp if set" do - livecheckable_f.regex(/foo/) - expect(livecheckable_f.regex).to eq(/foo/) + livecheck_f.regex(/foo/) + expect(livecheck_f.regex).to eq(/foo/) end end describe "#skip" do it "sets @skip to true when no argument is provided" do - expect(livecheckable_f.skip).to be true - expect(livecheckable_f.instance_variable_get(:@skip)).to be true - expect(livecheckable_f.instance_variable_get(:@skip_msg)).to be_nil + expect(livecheck_f.skip).to be true + expect(livecheck_f.instance_variable_get(:@skip)).to be true + expect(livecheck_f.instance_variable_get(:@skip_msg)).to be_nil end it "sets @skip to true and @skip_msg to the provided String" do - expect(livecheckable_f.skip("foo")).to be true - expect(livecheckable_f.instance_variable_get(:@skip)).to be true - expect(livecheckable_f.instance_variable_get(:@skip_msg)).to eq("foo") + expect(livecheck_f.skip("foo")).to be true + expect(livecheck_f.instance_variable_get(:@skip)).to be true + expect(livecheck_f.instance_variable_get(:@skip_msg)).to eq("foo") end end describe "#skip?" do it "returns the value of @skip" do - expect(livecheckable_f.skip?).to be false + expect(livecheck_f.skip?).to be false - livecheckable_f.skip - expect(livecheckable_f.skip?).to be true + livecheck_f.skip + expect(livecheck_f.skip?).to be true end end describe "#strategy" do it "returns nil if not set" do - expect(livecheckable_f.strategy).to be_nil + expect(livecheck_f.strategy).to be_nil end it "returns the Symbol if set" do - livecheckable_f.strategy(:page_match) - expect(livecheckable_f.strategy).to eq(:page_match) + livecheck_f.strategy(:page_match) + expect(livecheck_f.strategy).to eq(:page_match) end end describe "#throttle" do it "returns nil if not set" do - expect(livecheckable_f.throttle).to be_nil + expect(livecheck_f.throttle).to be_nil end it "returns the Integer if set" do - livecheckable_f.throttle(10) - expect(livecheckable_f.throttle).to eq(10) + livecheck_f.throttle(10) + expect(livecheck_f.throttle).to eq(10) end end @@ -115,38 +115,38 @@ let(:url_string) { "https://brew.sh" } it "returns nil if not set" do - expect(livecheckable_f.url).to be_nil + expect(livecheck_f.url).to be_nil end it "returns a string when set to a string" do - livecheckable_f.url(url_string) - expect(livecheckable_f.url).to eq(url_string) + livecheck_f.url(url_string) + expect(livecheck_f.url).to eq(url_string) end it "returns the URL symbol if valid" do - livecheckable_f.url(:head) - expect(livecheckable_f.url).to eq(:head) + livecheck_f.url(:head) + expect(livecheck_f.url).to eq(:head) - livecheckable_f.url(:homepage) - expect(livecheckable_f.url).to eq(:homepage) + livecheck_f.url(:homepage) + expect(livecheck_f.url).to eq(:homepage) - livecheckable_f.url(:stable) - expect(livecheckable_f.url).to eq(:stable) + livecheck_f.url(:stable) + expect(livecheck_f.url).to eq(:stable) - livecheckable_c.url(:url) - expect(livecheckable_c.url).to eq(:url) + livecheck_c.url(:url) + expect(livecheck_c.url).to eq(:url) end it "raises an ArgumentError if the argument isn't a valid Symbol" do expect do - livecheckable_f.url(:not_a_valid_symbol) + livecheck_f.url(:not_a_valid_symbol) end.to raise_error ArgumentError end end describe "#to_hash" do it "returns a Hash of all instance variables" do - expect(livecheckable_f.to_hash).to eq( + expect(livecheck_f.to_hash).to eq( { "cask" => nil, "formula" => nil, diff --git a/Library/Homebrew/test/resource_spec.rb b/Library/Homebrew/test/resource_spec.rb index e509902bdee30..699772053954e 100644 --- a/Library/Homebrew/test/resource_spec.rb +++ b/Library/Homebrew/test/resource_spec.rb @@ -71,13 +71,13 @@ end end - describe "#livecheckable?" do + describe "#livecheck_defined?" do it "returns false if livecheck block is not set in resource" do - expect(resource.livecheckable?).to be false + expect(resource.livecheck_defined?).to be false end specify "livecheck block defined in resources" do - expect(livecheck_resource.livecheckable?).to be true + expect(livecheck_resource.livecheck_defined?).to be true end end From 79e20b351277e6ada36d15fffd05405b029eb315 Mon Sep 17 00:00:00 2001 From: Sam Ford <1584702+samford@users.noreply.github.com> Date: Mon, 2 Dec 2024 10:06:14 -0500 Subject: [PATCH 2/2] Standardize `livecheck` block language formatting --- Library/Homebrew/formula.rb | 2 +- Library/Homebrew/livecheck.rb | 4 ++-- Library/Homebrew/livecheck/livecheck.rb | 2 +- Library/Homebrew/resource.rb | 2 +- Library/Homebrew/rubocops/cask/no_overrides.rb | 3 ++- Library/Homebrew/test/cask/audit_spec.rb | 12 ++++++------ Library/Homebrew/test/formula_spec.rb | 4 ++-- Library/Homebrew/test/livecheck/livecheck_spec.rb | 2 +- Library/Homebrew/test/resource_spec.rb | 6 +++--- .../rubocops/livecheck/regex_parentheses_spec.rb | 4 ++-- .../Homebrew/test/rubocops/livecheck/skip_spec.rb | 4 ++-- .../test/rubocops/livecheck/url_provided_spec.rb | 6 +++--- .../test/rubocops/livecheck/url_symbol_spec.rb | 4 ++-- 13 files changed, 28 insertions(+), 27 deletions(-) diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb index 4196ed290e915..ff28c685ca61b 100644 --- a/Library/Homebrew/formula.rb +++ b/Library/Homebrew/formula.rb @@ -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. diff --git a/Library/Homebrew/livecheck.rb b/Library/Homebrew/livecheck.rb index e3a0b5d48db77..e1f1a72d55347 100644 --- a/Library/Homebrew/livecheck.rb +++ b/Library/Homebrew/livecheck.rb @@ -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. @@ -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. diff --git a/Library/Homebrew/livecheck/livecheck.rb b/Library/Homebrew/livecheck/livecheck.rb index 3aa03953379f2..42158cd324674 100644 --- a/Library/Homebrew/livecheck/livecheck.rb +++ b/Library/Homebrew/livecheck/livecheck.rb @@ -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 diff --git a/Library/Homebrew/resource.rb b/Library/Homebrew/resource.rb index 636cd0705b1a6..df691aac827ba 100644 --- a/Library/Homebrew/resource.rb +++ b/Library/Homebrew/resource.rb @@ -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. diff --git a/Library/Homebrew/rubocops/cask/no_overrides.rb b/Library/Homebrew/rubocops/cask/no_overrides.rb index e1bdb5e77cc8c..294091927e835 100644 --- a/Library/Homebrew/rubocops/cask/no_overrides.rb +++ b/Library/Homebrew/rubocops/cask/no_overrides.rb @@ -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? } diff --git a/Library/Homebrew/test/cask/audit_spec.rb b/Library/Homebrew/test/cask/audit_spec.rb index 800d1fa51d48a..43a7c6be40506 100644 --- a/Library/Homebrew/test/cask/audit_spec.rb +++ b/Library/Homebrew/test/cask/audit_spec.rb @@ -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) } @@ -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) } @@ -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) } @@ -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) } @@ -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) } diff --git a/Library/Homebrew/test/formula_spec.rb b/Library/Homebrew/test/formula_spec.rb index 69529c1e8d4d1..819bb0065b103 100644 --- a/Library/Homebrew/test/formula_spec.rb +++ b/Library/Homebrew/test/formula_spec.rb @@ -705,7 +705,7 @@ 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 @@ -713,7 +713,7 @@ def post_install 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 diff --git a/Library/Homebrew/test/livecheck/livecheck_spec.rb b/Library/Homebrew/test/livecheck/livecheck_spec.rb index c91caebb693eb..c7ba95dac82c4 100644 --- a/Library/Homebrew/test/livecheck/livecheck_spec.rb +++ b/Library/Homebrew/test/livecheck/livecheck_spec.rb @@ -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, []]) diff --git a/Library/Homebrew/test/resource_spec.rb b/Library/Homebrew/test/resource_spec.rb index 699772053954e..3ae646ce89fc2 100644 --- a/Library/Homebrew/test/resource_spec.rb +++ b/Library/Homebrew/test/resource_spec.rb @@ -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 diff --git a/Library/Homebrew/test/rubocops/livecheck/regex_parentheses_spec.rb b/Library/Homebrew/test/rubocops/livecheck/regex_parentheses_spec.rb index ec515a9c4d0a9..42e76de5f1e35 100644 --- a/Library/Homebrew/test/rubocops/livecheck/regex_parentheses_spec.rb +++ b/Library/Homebrew/test/rubocops/livecheck/regex_parentheses_spec.rb @@ -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" @@ -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" diff --git a/Library/Homebrew/test/rubocops/livecheck/skip_spec.rb b/Library/Homebrew/test/rubocops/livecheck/skip_spec.rb index d802a008ebe63..0afc224aec06b 100644 --- a/Library/Homebrew/test/rubocops/livecheck/skip_spec.rb +++ b/Library/Homebrew/test/rubocops/livecheck/skip_spec.rb @@ -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" @@ -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" diff --git a/Library/Homebrew/test/rubocops/livecheck/url_provided_spec.rb b/Library/Homebrew/test/rubocops/livecheck/url_provided_spec.rb index 72b41dbb4c41c..cd16f0725e6de 100644 --- a/Library/Homebrew/test/rubocops/livecheck/url_provided_spec.rb +++ b/Library/Homebrew/test/rubocops/livecheck/url_provided_spec.rb @@ -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" @@ -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" @@ -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" diff --git a/Library/Homebrew/test/rubocops/livecheck/url_symbol_spec.rb b/Library/Homebrew/test/rubocops/livecheck/url_symbol_spec.rb index 3d46fa5350767..ec6e17d8b296e 100644 --- a/Library/Homebrew/test/rubocops/livecheck/url_symbol_spec.rb +++ b/Library/Homebrew/test/rubocops/livecheck/url_symbol_spec.rb @@ -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" @@ -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"