diff --git a/Library/Homebrew/livecheck/strategy.rb b/Library/Homebrew/livecheck/strategy.rb index 0040bc4821..b77610d0c4 100644 --- a/Library/Homebrew/livecheck/strategy.rb +++ b/Library/Homebrew/livecheck/strategy.rb @@ -86,6 +86,7 @@ module Homebrew # At present, this should only be called after tap strategies have been # loaded, otherwise livecheck won't be able to use them. # @return [Hash] + sig { returns(T::Hash[Symbol, T.untyped]) } def strategies return @strategies if defined? @strategies @@ -107,8 +108,9 @@ module Homebrew # @param symbol [Symbol] the strategy name in snake case as a `Symbol` # (e.g. `:page_match`) # @return [Strategy, nil] + sig { params(symbol: T.nilable(Symbol)).returns(T.nilable(T.untyped)) } def from_symbol(symbol) - strategies[symbol] + strategies[symbol] if symbol.present? end # Returns an array of strategies that apply to the provided URL. @@ -119,7 +121,16 @@ module Homebrew # @param regex_provided [Boolean] whether a regex is provided in the # `livecheck` block # @return [Array] - def from_url(url, livecheck_strategy: nil, url_provided: nil, regex_provided: nil, block_provided: nil) + sig { + params( + url: String, + livecheck_strategy: T.nilable(Symbol), + url_provided: T::Boolean, + regex_provided: T::Boolean, + block_provided: T::Boolean, + ).returns(T::Array[T.untyped]) + } + def from_url(url, livecheck_strategy: nil, url_provided: false, regex_provided: false, block_provided: false) usable_strategies = strategies.values.select do |strategy| if strategy == PageMatch # Only treat the `PageMatch` strategy as usable if a regex is @@ -143,6 +154,7 @@ module Homebrew end end + sig { params(url: String).returns(T::Array[T::Hash[String, String]]) } def self.page_headers(url) headers = [] diff --git a/Library/Homebrew/livecheck/strategy/apache.rb b/Library/Homebrew/livecheck/strategy/apache.rb index 36b2395094..6cd4e29416 100644 --- a/Library/Homebrew/livecheck/strategy/apache.rb +++ b/Library/Homebrew/livecheck/strategy/apache.rb @@ -37,6 +37,7 @@ module Homebrew # # @param url [String] the URL to match against # @return [Boolean] + sig { params(url: String).returns(T::Boolean) } def self.match?(url) URL_MATCH_REGEX.match?(url) end diff --git a/Library/Homebrew/livecheck/strategy/bitbucket.rb b/Library/Homebrew/livecheck/strategy/bitbucket.rb index 4072748aed..a3fc074af2 100644 --- a/Library/Homebrew/livecheck/strategy/bitbucket.rb +++ b/Library/Homebrew/livecheck/strategy/bitbucket.rb @@ -44,6 +44,7 @@ module Homebrew # # @param url [String] the URL to match against # @return [Boolean] + sig { params(url: String).returns(T::Boolean) } def self.match?(url) URL_MATCH_REGEX.match?(url) end diff --git a/Library/Homebrew/livecheck/strategy/cpan.rb b/Library/Homebrew/livecheck/strategy/cpan.rb index 88965bd8d6..f1fd982822 100644 --- a/Library/Homebrew/livecheck/strategy/cpan.rb +++ b/Library/Homebrew/livecheck/strategy/cpan.rb @@ -35,6 +35,7 @@ module Homebrew # # @param url [String] the URL to match against # @return [Boolean] + sig { params(url: String).returns(T::Boolean) } def self.match?(url) URL_MATCH_REGEX.match?(url) end diff --git a/Library/Homebrew/livecheck/strategy/git.rb b/Library/Homebrew/livecheck/strategy/git.rb index 55c3c05562..d68853ab9b 100644 --- a/Library/Homebrew/livecheck/strategy/git.rb +++ b/Library/Homebrew/livecheck/strategy/git.rb @@ -50,6 +50,7 @@ module Homebrew # @param url [String] the URL of the Git repository to check # @param regex [Regexp] the regex to use for filtering tags # @return [Hash] + sig { params(url: String, regex: T.nilable(Regexp)).returns(T::Hash[Symbol, T.untyped]) } def self.tag_info(url, regex = nil) # Open3#capture3 is used here because we need to capture stderr # output and handle it in an appropriate manner. Alternatives like diff --git a/Library/Homebrew/livecheck/strategy/github_latest.rb b/Library/Homebrew/livecheck/strategy/github_latest.rb index 68a9657448..c575bf55bb 100644 --- a/Library/Homebrew/livecheck/strategy/github_latest.rb +++ b/Library/Homebrew/livecheck/strategy/github_latest.rb @@ -52,6 +52,7 @@ module Homebrew # # @param url [String] the URL to match against # @return [Boolean] + sig { params(url: String).returns(T::Boolean) } def self.match?(url) URL_MATCH_REGEX.match?(url) end diff --git a/Library/Homebrew/livecheck/strategy/gnome.rb b/Library/Homebrew/livecheck/strategy/gnome.rb index 7af002b9f5..b8bd9621cb 100644 --- a/Library/Homebrew/livecheck/strategy/gnome.rb +++ b/Library/Homebrew/livecheck/strategy/gnome.rb @@ -40,6 +40,7 @@ module Homebrew # # @param url [String] the URL to match against # @return [Boolean] + sig { params(url: String).returns(T::Boolean) } def self.match?(url) URL_MATCH_REGEX.match?(url) end diff --git a/Library/Homebrew/livecheck/strategy/gnu.rb b/Library/Homebrew/livecheck/strategy/gnu.rb index dac3db3ef6..71c778bc0a 100644 --- a/Library/Homebrew/livecheck/strategy/gnu.rb +++ b/Library/Homebrew/livecheck/strategy/gnu.rb @@ -44,6 +44,7 @@ module Homebrew # # @param url [String] the URL to match against # @return [Boolean] + sig { params(url: String).returns(T::Boolean) } def self.match?(url) URL_MATCH_REGEX.match?(url) && url.exclude?("savannah.") end diff --git a/Library/Homebrew/livecheck/strategy/hackage.rb b/Library/Homebrew/livecheck/strategy/hackage.rb index 025ebe266a..fe99e66fe5 100644 --- a/Library/Homebrew/livecheck/strategy/hackage.rb +++ b/Library/Homebrew/livecheck/strategy/hackage.rb @@ -37,6 +37,7 @@ module Homebrew # # @param url [String] the URL to match against # @return [Boolean] + sig { params(url: String).returns(T::Boolean) } def self.match?(url) URL_MATCH_REGEX.match?(url) end diff --git a/Library/Homebrew/livecheck/strategy/launchpad.rb b/Library/Homebrew/livecheck/strategy/launchpad.rb index d4f935b90e..ee91769c8c 100644 --- a/Library/Homebrew/livecheck/strategy/launchpad.rb +++ b/Library/Homebrew/livecheck/strategy/launchpad.rb @@ -35,6 +35,7 @@ module Homebrew # # @param url [String] the URL to match against # @return [Boolean] + sig { params(url: String).returns(T::Boolean) } def self.match?(url) URL_MATCH_REGEX.match?(url) end diff --git a/Library/Homebrew/livecheck/strategy/npm.rb b/Library/Homebrew/livecheck/strategy/npm.rb index db3b062247..4faab03ca2 100644 --- a/Library/Homebrew/livecheck/strategy/npm.rb +++ b/Library/Homebrew/livecheck/strategy/npm.rb @@ -31,6 +31,7 @@ module Homebrew # # @param url [String] the URL to match against # @return [Boolean] + sig { params(url: String).returns(T::Boolean) } def self.match?(url) URL_MATCH_REGEX.match?(url) end diff --git a/Library/Homebrew/livecheck/strategy/pypi.rb b/Library/Homebrew/livecheck/strategy/pypi.rb index ecbd14c505..96a5b1fbf7 100644 --- a/Library/Homebrew/livecheck/strategy/pypi.rb +++ b/Library/Homebrew/livecheck/strategy/pypi.rb @@ -41,6 +41,7 @@ module Homebrew # # @param url [String] the URL to match against # @return [Boolean] + sig { params(url: String).returns(T::Boolean) } def self.match?(url) URL_MATCH_REGEX.match?(url) end diff --git a/Library/Homebrew/livecheck/strategy/sourceforge.rb b/Library/Homebrew/livecheck/strategy/sourceforge.rb index a6a9a9add2..0ffcdb0d2e 100644 --- a/Library/Homebrew/livecheck/strategy/sourceforge.rb +++ b/Library/Homebrew/livecheck/strategy/sourceforge.rb @@ -47,6 +47,7 @@ module Homebrew # # @param url [String] the URL to match against # @return [Boolean] + sig { params(url: String).returns(T::Boolean) } def self.match?(url) URL_MATCH_REGEX.match?(url) end diff --git a/Library/Homebrew/livecheck/strategy/xorg.rb b/Library/Homebrew/livecheck/strategy/xorg.rb index 6f6b94b0a4..5fcbbdd449 100644 --- a/Library/Homebrew/livecheck/strategy/xorg.rb +++ b/Library/Homebrew/livecheck/strategy/xorg.rb @@ -64,6 +64,7 @@ module Homebrew # # @param url [String] the URL to match against # @return [Boolean] + sig { params(url: String).returns(T::Boolean) } def self.match?(url) URL_MATCH_REGEX.match?(url) end