Fix RuboCop Style/RedundantFreeze offenses

This commit is contained in:
Issy Long 2024-01-18 22:18:42 +00:00
parent e9587a5ecc
commit f682147598
No known key found for this signature in database
GPG Key ID: 8247C390DADC67D4
57 changed files with 93 additions and 95 deletions

View File

@ -461,5 +461,3 @@ Style/ArrayIntersect:
Enabled: false Enabled: false
Style/HashSyntax: Style/HashSyntax:
EnforcedShorthandSyntax: either EnforcedShorthandSyntax: either
Style/RedundantFreeze:
Enabled: false

View File

@ -13,11 +13,11 @@ module Cask
"_" => :underscores, "_" => :underscores,
}.freeze }.freeze
DIVIDER_REGEX = /(#{DIVIDERS.keys.map { |v| Regexp.quote(v) }.join("|")})/.freeze DIVIDER_REGEX = /(#{DIVIDERS.keys.map { |v| Regexp.quote(v) }.join("|")})/
MAJOR_MINOR_PATCH_REGEX = /^([^.,:]+)(?:.([^.,:]+)(?:.([^.,:]+))?)?/.freeze MAJOR_MINOR_PATCH_REGEX = /^([^.,:]+)(?:.([^.,:]+)(?:.([^.,:]+))?)?/
INVALID_CHARACTERS = /[^0-9a-zA-Z.,:\-_+ ]/.freeze INVALID_CHARACTERS = /[^0-9a-zA-Z.,:\-_+ ]/
class << self class << self
private private

View File

@ -222,8 +222,8 @@ module Homebrew
to_formulae_to_casks(only: only, method: :resolve) to_formulae_to_casks(only: only, method: :resolve)
end end
LOCAL_PATH_REGEX = %r{^/|[.]|/$}.freeze LOCAL_PATH_REGEX = %r{^/|[.]|/$}
TAP_NAME_REGEX = %r{^[^./]+/[^./]+$}.freeze TAP_NAME_REGEX = %r{^[^./]+/[^./]+$}
private_constant :LOCAL_PATH_REGEX, :TAP_NAME_REGEX private_constant :LOCAL_PATH_REGEX, :TAP_NAME_REGEX
# Keep existing paths and try to convert others to tap, formula or cask paths. # Keep existing paths and try to convert others to tap, formula or cask paths.

View File

@ -714,7 +714,7 @@ class Reporter
# Hack `git diff` output with regexes to look like `git diff-tree` output. # Hack `git diff` output with regexes to look like `git diff-tree` output.
# Yes, I know this is a bit filthy but it saves duplicating the #report logic. # Yes, I know this is a bit filthy but it saves duplicating the #report logic.
diff_output = Utils.popen_read("git", "diff", "--no-ext-diff", api_names_before_txt, api_names_txt) diff_output = Utils.popen_read("git", "diff", "--no-ext-diff", api_names_before_txt, api_names_txt)
header_regex = /^(---|\+\+\+) /.freeze header_regex = /^(---|\+\+\+) /
add_delete_characters = ["+", "-"].freeze add_delete_characters = ["+", "-"].freeze
diff_output.lines.map do |line| diff_output.lines.map do |line|

View File

@ -35,7 +35,7 @@ module Commands
# dot as a full stop if it is either followed by a whitespace or at the end of # dot as a full stop if it is either followed by a whitespace or at the end of
# the description. In this way we can prevent cutting off a sentence in the # the description. In this way we can prevent cutting off a sentence in the
# middle due to dots in URLs or paths. # middle due to dots in URLs or paths.
DESCRIPTION_SPLITTING_PATTERN = /\.(?>\s|$)/.freeze DESCRIPTION_SPLITTING_PATTERN = /\.(?>\s|$)/
def self.valid_internal_cmd?(cmd) def self.valid_internal_cmd?(cmd)
require?(HOMEBREW_CMD_PATH/cmd) require?(HOMEBREW_CMD_PATH/cmd)

View File

@ -4,7 +4,7 @@
# @private # @private
module CompilerConstants module CompilerConstants
GNU_GCC_VERSIONS = %w[4.9 5 6 7 8 9 10 11 12 13].freeze GNU_GCC_VERSIONS = %w[4.9 5 6 7 8 9 10 11 12 13].freeze
GNU_GCC_REGEXP = /^gcc-(4\.9|[5-9]|10|11|12|13)$/.freeze GNU_GCC_REGEXP = /^gcc-(4\.9|[5-9]|10|11|12|13)$/
COMPILER_SYMBOL_MAP = { COMPILER_SYMBOL_MAP = {
"gcc" => :gcc, "gcc" => :gcc,
"clang" => :clang, "clang" => :clang,

View File

@ -69,7 +69,7 @@ ensure
end end
module Homebrew module Homebrew
BOTTLE_BLOCK_REGEX = / bottle (?:do.+?end|:[a-z]+)\n\n/m.freeze BOTTLE_BLOCK_REGEX = / bottle (?:do.+?end|:[a-z]+)\n\n/m
sig { returns(CLI::Parser) } sig { returns(CLI::Parser) }
def self.extract_args def self.extract_args

View File

@ -132,7 +132,7 @@ class Symbol
end end
class String class String
BLANK_RE = /\A[[:space:]]*\z/.freeze BLANK_RE = /\A[[:space:]]*\z/
# This is a cache that is intentionally mutable # This is a cache that is intentionally mutable
# rubocop:disable Style/MutableConstant # rubocop:disable Style/MutableConstant
ENCODED_BLANKS_ = T.let(Hash.new do |h, enc| ENCODED_BLANKS_ = T.let(Hash.new do |h, enc|

View File

@ -130,7 +130,7 @@ class Keg
end end
end end
VARIABLE_REFERENCE_RX = /^@(loader_|executable_|r)path/.freeze VARIABLE_REFERENCE_RX = /^@(loader_|executable_|r)path/
def each_linkage_for(file, linkage_type, resolve_variable_references: false, &block) def each_linkage_for(file, linkage_type, resolve_variable_references: false, &block)
file.public_send(linkage_type, resolve_variable_references: resolve_variable_references) file.public_send(linkage_type, resolve_variable_references: resolve_variable_references)
@ -159,7 +159,7 @@ class Keg
# Matches framework references like `XXX.framework/Versions/YYY/XXX` and # Matches framework references like `XXX.framework/Versions/YYY/XXX` and
# `XXX.framework/XXX`, both with or without a slash-delimited prefix. # `XXX.framework/XXX`, both with or without a slash-delimited prefix.
FRAMEWORK_RX = %r{(?:^|/)(([^/]+)\.framework/(?:Versions/[^/]+/)?\2)$}.freeze FRAMEWORK_RX = %r{(?:^|/)(([^/]+)\.framework/(?:Versions/[^/]+/)?\2)$}
def find_dylib_suffix_from(bad_name) def find_dylib_suffix_from(bad_name)
if (framework = bad_name.match(FRAMEWORK_RX)) if (framework = bad_name.match(FRAMEWORK_RX))
@ -233,7 +233,7 @@ class Keg
private private
CELLAR_RX = %r{\A#{HOMEBREW_CELLAR}/(?<formula_name>[^/]+)/[^/]+}.freeze CELLAR_RX = %r{\A#{HOMEBREW_CELLAR}/(?<formula_name>[^/]+)/[^/]+}
# Replace HOMEBREW_CELLAR references with HOMEBREW_PREFIX/opt references # Replace HOMEBREW_CELLAR references with HOMEBREW_PREFIX/opt references
# if the Cellar reference is to a different keg. # if the Cellar reference is to a different keg.

View File

@ -18,7 +18,7 @@ require "active_support/core_ext/hash/deep_transform_values"
module Formulary module Formulary
extend Cachable extend Cachable
URL_START_REGEX = %r{(https?|ftp|file)://}.freeze URL_START_REGEX = %r{(https?|ftp|file)://}
# :codesign and custom requirement classes are not supported # :codesign and custom requirement classes are not supported
API_SUPPORTED_REQUIREMENTS = [:arch, :linux, :macos, :maximum_macos, :xcode].freeze API_SUPPORTED_REQUIREMENTS = [:arch, :linux, :macos, :maximum_macos, :xcode].freeze

View File

@ -18,12 +18,12 @@ class GitHubPackages
private_constant :URL_PREFIX private_constant :URL_PREFIX
private_constant :DOCKER_PREFIX private_constant :DOCKER_PREFIX
URL_REGEX = %r{(?:#{Regexp.escape(URL_PREFIX)}|#{Regexp.escape(DOCKER_PREFIX)})([\w-]+)/([\w-]+)}.freeze URL_REGEX = %r{(?:#{Regexp.escape(URL_PREFIX)}|#{Regexp.escape(DOCKER_PREFIX)})([\w-]+)/([\w-]+)}
# Valid OCI tag characters # Valid OCI tag characters
# https://github.com/opencontainers/distribution-spec/blob/main/spec.md#workflow-categories # https://github.com/opencontainers/distribution-spec/blob/main/spec.md#workflow-categories
VALID_OCI_TAG_REGEX = /^[a-zA-Z0-9_][a-zA-Z0-9._-]{0,127}$/.freeze VALID_OCI_TAG_REGEX = /^[a-zA-Z0-9_][a-zA-Z0-9._-]{0,127}$/
INVALID_OCI_TAG_CHARS_REGEX = /[^a-zA-Z0-9._-]/.freeze INVALID_OCI_TAG_CHARS_REGEX = /[^a-zA-Z0-9._-]/
GZIP_BUFFER_SIZE = 64 * 1024 GZIP_BUFFER_SIZE = 64 * 1024
private_constant :GZIP_BUFFER_SIZE private_constant :GZIP_BUFFER_SIZE

View File

@ -10,7 +10,7 @@ require "json"
class GitHubReleases class GitHubReleases
include Context include Context
URL_REGEX = %r{https://github\.com/([\w-]+)/([\w-]+)?/releases/download/(.+)}.freeze URL_REGEX = %r{https://github\.com/([\w-]+)/([\w-]+)?/releases/download/(.+)}
sig { params(bottles_hash: T::Hash[String, T.untyped]).void } sig { params(bottles_hash: T::Hash[String, T.untyped]).void }
def upload_bottles(bottles_hash) def upload_bottles(bottles_hash)

View File

@ -65,10 +65,10 @@ HOMEBREW_MACOS_OLDEST_SUPPORTED = ENV.fetch("HOMEBREW_MACOS_OLDEST_SUPPORTED").f
HOMEBREW_MACOS_OLDEST_ALLOWED = ENV.fetch("HOMEBREW_MACOS_OLDEST_ALLOWED").freeze HOMEBREW_MACOS_OLDEST_ALLOWED = ENV.fetch("HOMEBREW_MACOS_OLDEST_ALLOWED").freeze
HOMEBREW_PULL_API_REGEX = HOMEBREW_PULL_API_REGEX =
%r{https://api\.github\.com/repos/([\w-]+)/([\w-]+)?/pulls/(\d+)}.freeze %r{https://api\.github\.com/repos/([\w-]+)/([\w-]+)?/pulls/(\d+)}
HOMEBREW_PULL_OR_COMMIT_URL_REGEX = HOMEBREW_PULL_OR_COMMIT_URL_REGEX =
%r[https://github\.com/([\w-]+)/([\w-]+)?/(?:pull/(\d+)|commit/[0-9a-fA-F]{4,40})].freeze %r[https://github\.com/([\w-]+)/([\w-]+)?/(?:pull/(\d+)|commit/[0-9a-fA-F]{4,40})]
HOMEBREW_BOTTLES_EXTNAME_REGEX = /\.([a-z0-9_]+)\.bottle\.(?:(\d+)\.)?tar\.gz$/.freeze HOMEBREW_BOTTLES_EXTNAME_REGEX = /\.([a-z0-9_]+)\.bottle\.(?:(\d+)\.)?tar\.gz$/
require "extend/module" require "extend/module"
require "extend/blank" require "extend/blank"

View File

@ -78,8 +78,8 @@ class Keg
end end
# Locale-specific directories have the form `language[_territory][.codeset][@modifier]` # Locale-specific directories have the form `language[_territory][.codeset][@modifier]`
LOCALEDIR_RX = %r{(locale|man)/([a-z]{2}|C|POSIX)(_[A-Z]{2})?(\.[a-zA-Z\-0-9]+(@.+)?)?}.freeze LOCALEDIR_RX = %r{(locale|man)/([a-z]{2}|C|POSIX)(_[A-Z]{2})?(\.[a-zA-Z\-0-9]+(@.+)?)?}
INFOFILE_RX = %r{info/([^.].*?\.info|dir)$}.freeze INFOFILE_RX = %r{info/([^.].*?\.info|dir)$}
KEG_LINK_DIRECTORIES = %w[ KEG_LINK_DIRECTORIES = %w[
bin etc include lib sbin share var bin etc include lib sbin share var
].freeze ].freeze

View File

@ -12,7 +12,7 @@ class Keg
NULL_BYTE_STRING = "\\x00" NULL_BYTE_STRING = "\\x00"
class Relocation class Relocation
RELOCATABLE_PATH_REGEX_PREFIX = /(?:(?<=-F|-I|-L|-isystem)|(?<![a-zA-Z0-9]))/.freeze RELOCATABLE_PATH_REGEX_PREFIX = /(?:(?<=-F|-I|-L|-isystem)|(?<![a-zA-Z0-9]))/
def initialize def initialize
@replacement_map = {} @replacement_map = {}
@ -83,7 +83,7 @@ class Keg
[] []
end end
JAVA_REGEX = %r{#{HOMEBREW_PREFIX}/opt/openjdk(@\d+(\.\d+)*)?/libexec(/openjdk\.jdk/Contents/Home)?}.freeze JAVA_REGEX = %r{#{HOMEBREW_PREFIX}/opt/openjdk(@\d+(\.\d+)*)?/libexec(/openjdk\.jdk/Contents/Home)?}
def prepare_relocation_to_placeholders def prepare_relocation_to_placeholders
relocation = Relocation.new relocation = Relocation.new

View File

@ -92,7 +92,7 @@ module Language
module_function module_function
# A regex to match potential shebang permutations. # A regex to match potential shebang permutations.
NODE_SHEBANG_REGEX = %r{^#! ?/usr/bin/(?:env )?node( |$)}.freeze NODE_SHEBANG_REGEX = %r{^#! ?/usr/bin/(?:env )?node( |$)}
# The length of the longest shebang matching `SHEBANG_REGEX`. # The length of the longest shebang matching `SHEBANG_REGEX`.
NODE_SHEBANG_MAX_LENGTH = "#! /usr/bin/env node ".length NODE_SHEBANG_MAX_LENGTH = "#! /usr/bin/env node ".length

View File

@ -11,7 +11,7 @@ module Language
module_function module_function
# A regex to match potential shebang permutations. # A regex to match potential shebang permutations.
PERL_SHEBANG_REGEX = %r{^#! ?/usr/bin/(?:env )?perl( |$)}.freeze PERL_SHEBANG_REGEX = %r{^#! ?/usr/bin/(?:env )?perl( |$)}
# The length of the longest shebang matching `SHEBANG_REGEX`. # The length of the longest shebang matching `SHEBANG_REGEX`.
PERL_SHEBANG_MAX_LENGTH = "#! /usr/bin/env perl ".length PERL_SHEBANG_MAX_LENGTH = "#! /usr/bin/env perl ".length

View File

@ -95,7 +95,7 @@ module Language
module_function module_function
# A regex to match potential shebang permutations. # A regex to match potential shebang permutations.
PYTHON_SHEBANG_REGEX = %r{^#! ?/usr/bin/(?:env )?python(?:[23](?:\.\d{1,2})?)?( |$)}.freeze PYTHON_SHEBANG_REGEX = %r{^#! ?/usr/bin/(?:env )?python(?:[23](?:\.\d{1,2})?)?( |$)}
# The length of the longest shebang matching `SHEBANG_REGEX`. # The length of the longest shebang matching `SHEBANG_REGEX`.
PYTHON_SHEBANG_MAX_LENGTH = "#! /usr/bin/env pythonx.yyy ".length PYTHON_SHEBANG_MAX_LENGTH = "#! /usr/bin/env pythonx.yyy ".length

View File

@ -81,7 +81,7 @@ module Homebrew
(?:ar(?:\.(?:bz2|gz|lz|lzma|lzo|xz|Z|zst))?| (?:ar(?:\.(?:bz2|gz|lz|lzma|lzo|xz|Z|zst))?|
b2|bz2?|z2|az|gz|lz|lzma|xz|Z|aZ|zst) b2|bz2?|z2|az|gz|lz|lzma|xz|Z|aZ|zst)
$ $
/ix.freeze /ix
# An error message to use when a `strategy` block returns a value of # An error message to use when a `strategy` block returns a value of
# an inappropriate type. # an inappropriate type.

View File

@ -37,7 +37,7 @@ module Homebrew
(?<prefix>[^/]*?) # Any text in filename or directory before version (?<prefix>[^/]*?) # Any text in filename or directory before version
v?\d+(?:\.\d+)+ # The numeric version v?\d+(?:\.\d+)+ # The numeric version
(?<suffix>/|[^/]*) # Any text in filename or directory after version (?<suffix>/|[^/]*) # Any text in filename or directory after version
}ix.freeze }ix
# Whether the strategy can be applied to the provided URL. # Whether the strategy can be applied to the provided URL.
# #

View File

@ -36,7 +36,7 @@ module Homebrew
/(?<prefix>(?:[^/]+?[_-])?) # Filename text before the version /(?<prefix>(?:[^/]+?[_-])?) # Filename text before the version
v?\d+(?:\.\d+)+ # The numeric version v?\d+(?:\.\d+)+ # The numeric version
(?<suffix>[^/]+) # Filename text after the version (?<suffix>[^/]+) # Filename text after the version
}ix.freeze }ix
# Whether the strategy can be applied to the provided URL. # Whether the strategy can be applied to the provided URL.
# #

View File

@ -27,7 +27,7 @@ module Homebrew
(?<prefix>[^/]+) # Filename text before the version (?<prefix>[^/]+) # Filename text before the version
-v?\d+(?:\.\d+)* # The numeric version -v?\d+(?:\.\d+)* # The numeric version
(?<suffix>[^/]+) # Filename text after the version (?<suffix>[^/]+) # Filename text after the version
}ix.freeze }ix
# Whether the strategy can be applied to the provided URL. # Whether the strategy can be applied to the provided URL.
# #

View File

@ -19,7 +19,7 @@ module Homebrew
PRIORITY = 0 PRIORITY = 0
# The `Regexp` used to determine if the strategy applies to the URL. # The `Regexp` used to determine if the strategy applies to the URL.
URL_MATCH_REGEX = %r{^https?://.+/[^/]+\.ya?ml(?:\?[^/?]+)?$}i.freeze URL_MATCH_REGEX = %r{^https?://.+/[^/]+\.ya?ml(?:\?[^/?]+)?$}i
# Whether the strategy can be applied to the provided URL. # Whether the strategy can be applied to the provided URL.
# #

View File

@ -24,7 +24,7 @@ module Homebrew
PRIORITY = 0 PRIORITY = 0
# The `Regexp` used to determine if the strategy applies to the URL. # The `Regexp` used to determine if the strategy applies to the URL.
URL_MATCH_REGEX = %r{^https?://}i.freeze URL_MATCH_REGEX = %r{^https?://}i
# Whether the strategy can be applied to the provided URL. # Whether the strategy can be applied to the provided URL.
# #

View File

@ -30,7 +30,7 @@ module Homebrew
# The default regex used to naively identify versions from tags when a # The default regex used to naively identify versions from tags when a
# regex isn't provided. # regex isn't provided.
DEFAULT_REGEX = /\D*(.+)/.freeze DEFAULT_REGEX = /\D*(.+)/
# Whether the strategy can be applied to the provided URL. # Whether the strategy can be applied to the provided URL.
# #

View File

@ -41,11 +41,11 @@ module Homebrew
^https?://github\.com ^https?://github\.com
/(?:downloads/)?(?<username>[^/]+) # The GitHub username /(?:downloads/)?(?<username>[^/]+) # The GitHub username
/(?<repository>[^/]+) # The GitHub repository name /(?<repository>[^/]+) # The GitHub repository name
}ix.freeze }ix
# The default regex used to identify a version from a tag when a regex # The default regex used to identify a version from a tag when a regex
# isn't provided. # isn't provided.
DEFAULT_REGEX = /v?(\d+(?:\.\d+)+)/i.freeze DEFAULT_REGEX = /v?(\d+(?:\.\d+)+)/i
# Keys in the release JSON that could contain the version. # Keys in the release JSON that could contain the version.
# The tag name is checked first, to better align with the {Git} # The tag name is checked first, to better align with the {Git}

View File

@ -32,7 +32,7 @@ module Homebrew
^https?://download\.gnome\.org ^https?://download\.gnome\.org
/sources /sources
/(?<package_name>[^/]+)/ # The GNOME package name /(?<package_name>[^/]+)/ # The GNOME package name
}ix.freeze }ix
# Whether the strategy can be applied to the provided URL. # Whether the strategy can be applied to the provided URL.
# #

View File

@ -36,7 +36,7 @@ module Homebrew
^https?:// ^https?://
(?:(?:[^/]+?\.)*gnu\.org/(?:gnu|software)/(?<project_name>[^/]+)/ (?:(?:[^/]+?\.)*gnu\.org/(?:gnu|software)/(?<project_name>[^/]+)/
|(?<project_name>[^/]+)\.gnu\.org/?$) |(?<project_name>[^/]+)\.gnu\.org/?$)
}ix.freeze }ix
# Whether the strategy can be applied to the provided URL. # Whether the strategy can be applied to the provided URL.
# #

View File

@ -19,17 +19,17 @@ module Homebrew
class Hackage class Hackage
# A `Regexp` used in determining if the strategy applies to the URL and # A `Regexp` used in determining if the strategy applies to the URL and
# also as part of extracting the package name from the URL basename. # also as part of extracting the package name from the URL basename.
PACKAGE_NAME_REGEX = /(?<package_name>.+?)-\d+/i.freeze PACKAGE_NAME_REGEX = /(?<package_name>.+?)-\d+/i
# A `Regexp` used to extract the package name from the URL basename. # A `Regexp` used to extract the package name from the URL basename.
FILENAME_REGEX = /^#{PACKAGE_NAME_REGEX.source.strip}/i.freeze FILENAME_REGEX = /^#{PACKAGE_NAME_REGEX.source.strip}/i
# A `Regexp` used in determining if the strategy applies to the URL. # A `Regexp` used in determining if the strategy applies to the URL.
URL_MATCH_REGEX = %r{ URL_MATCH_REGEX = %r{
^https?://(?:downloads|hackage)\.haskell\.org ^https?://(?:downloads|hackage)\.haskell\.org
(?:/[^/]+)+ # Path before the filename (?:/[^/]+)+ # Path before the filename
#{PACKAGE_NAME_REGEX.source.strip} #{PACKAGE_NAME_REGEX.source.strip}
}ix.freeze }ix
# Whether the strategy can be applied to the provided URL. # Whether the strategy can be applied to the provided URL.
# #

View File

@ -19,7 +19,7 @@ module Homebrew
PRIORITY = 0 PRIORITY = 0
# The `Regexp` used to determine if the strategy applies to the URL. # The `Regexp` used to determine if the strategy applies to the URL.
URL_MATCH_REGEX = %r{^https?://}i.freeze URL_MATCH_REGEX = %r{^https?://}i
# The header fields to check when a `strategy` block isn't provided. # The header fields to check when a `strategy` block isn't provided.
DEFAULT_HEADERS_TO_CHECK = ["content-disposition", "location"].freeze DEFAULT_HEADERS_TO_CHECK = ["content-disposition", "location"].freeze

View File

@ -31,7 +31,7 @@ module Homebrew
PRIORITY = 0 PRIORITY = 0
# The `Regexp` used to determine if the strategy applies to the URL. # The `Regexp` used to determine if the strategy applies to the URL.
URL_MATCH_REGEX = %r{^https?://}i.freeze URL_MATCH_REGEX = %r{^https?://}i
# Whether the strategy can be applied to the provided URL. # Whether the strategy can be applied to the provided URL.
# {Json} will technically match any HTTP URL but is only usable with # {Json} will technically match any HTTP URL but is only usable with

View File

@ -27,11 +27,11 @@ module Homebrew
URL_MATCH_REGEX = %r{ URL_MATCH_REGEX = %r{
^https?://(?:[^/]+?\.)*launchpad\.net ^https?://(?:[^/]+?\.)*launchpad\.net
/(?<project_name>[^/]+) # The Launchpad project name /(?<project_name>[^/]+) # The Launchpad project name
}ix.freeze }ix
# The default regex used to identify the latest version when a regex # The default regex used to identify the latest version when a regex
# isn't provided. # isn't provided.
DEFAULT_REGEX = %r{class="[^"]*version[^"]*"[^>]*>\s*Latest version is (.+)\s*</}.freeze DEFAULT_REGEX = %r{class="[^"]*version[^"]*"[^>]*>\s*Latest version is (.+)\s*</}
# Whether the strategy can be applied to the provided URL. # Whether the strategy can be applied to the provided URL.
# #

View File

@ -23,7 +23,7 @@ module Homebrew
URL_MATCH_REGEX = %r{ URL_MATCH_REGEX = %r{
^https?://registry\.npmjs\.org ^https?://registry\.npmjs\.org
/(?<package_name>.+?)/-/ # The npm package name /(?<package_name>.+?)/-/ # The npm package name
}ix.freeze }ix
# Whether the strategy can be applied to the provided URL. # Whether the strategy can be applied to the provided URL.
# #

View File

@ -24,7 +24,7 @@ module Homebrew
PRIORITY = 0 PRIORITY = 0
# The `Regexp` used to determine if the strategy applies to the URL. # The `Regexp` used to determine if the strategy applies to the URL.
URL_MATCH_REGEX = %r{^https?://}i.freeze URL_MATCH_REGEX = %r{^https?://}i
# Whether the strategy can be applied to the provided URL. # Whether the strategy can be applied to the provided URL.
# {PageMatch} will technically match any HTTP URL but is only # {PageMatch} will technically match any HTTP URL but is only

View File

@ -25,7 +25,7 @@ module Homebrew
(?<package_name>.+)- # The package name followed by a hyphen (?<package_name>.+)- # The package name followed by a hyphen
.*? # The version string .*? # The version string
(?<suffix>\.tar\.[a-z0-9]+|\.[a-z0-9]+)$ # Filename extension (?<suffix>\.tar\.[a-z0-9]+|\.[a-z0-9]+)$ # Filename extension
/ix.freeze /ix
# The `Regexp` used to determine if the strategy applies to the URL. # The `Regexp` used to determine if the strategy applies to the URL.
URL_MATCH_REGEX = %r{ URL_MATCH_REGEX = %r{
@ -33,7 +33,7 @@ module Homebrew
/packages /packages
(?:/[^/]+)+ # The hexadecimal paths before the filename (?:/[^/]+)+ # The hexadecimal paths before the filename
/#{FILENAME_REGEX.source.strip} # The filename /#{FILENAME_REGEX.source.strip} # The filename
}ix.freeze }ix
# Whether the strategy can be applied to the provided URL. # Whether the strategy can be applied to the provided URL.
# #

View File

@ -39,7 +39,7 @@ module Homebrew
(?:/projects?/(?<project_name>[^/]+)/ (?:/projects?/(?<project_name>[^/]+)/
|/p/(?<project_name>[^/]+)/ |/p/(?<project_name>[^/]+)/
|(?::/cvsroot)?/(?<project_name>[^/]+)) |(?::/cvsroot)?/(?<project_name>[^/]+))
}ix.freeze }ix
# Whether the strategy can be applied to the provided URL. # Whether the strategy can be applied to the provided URL.
# #

View File

@ -19,7 +19,7 @@ module Homebrew
PRIORITY = 0 PRIORITY = 0
# The `Regexp` used to determine if the strategy applies to the URL. # The `Regexp` used to determine if the strategy applies to the URL.
URL_MATCH_REGEX = %r{^https?://}i.freeze URL_MATCH_REGEX = %r{^https?://}i
# Common `os` values used in appcasts to refer to macOS. # Common `os` values used in appcasts to refer to macOS.
APPCAST_MACOS_STRINGS = ["macos", "osx"].freeze APPCAST_MACOS_STRINGS = ["macos", "osx"].freeze

View File

@ -35,7 +35,7 @@ module Homebrew
PRIORITY = 0 PRIORITY = 0
# The `Regexp` used to determine if the strategy applies to the URL. # The `Regexp` used to determine if the strategy applies to the URL.
URL_MATCH_REGEX = %r{^https?://}i.freeze URL_MATCH_REGEX = %r{^https?://}i
# Whether the strategy can be applied to the provided URL. # Whether the strategy can be applied to the provided URL.
# {Xml} will technically match any HTTP URL but is only usable with # {Xml} will technically match any HTTP URL but is only usable with

View File

@ -42,17 +42,17 @@ module Homebrew
# A `Regexp` used in determining if the strategy applies to the URL and # A `Regexp` used in determining if the strategy applies to the URL and
# also as part of extracting the module name from the URL basename. # also as part of extracting the module name from the URL basename.
MODULE_REGEX = /(?<module_name>.+)-\d+/i.freeze MODULE_REGEX = /(?<module_name>.+)-\d+/i
# A `Regexp` used to extract the module name from the URL basename. # A `Regexp` used to extract the module name from the URL basename.
FILENAME_REGEX = /^#{MODULE_REGEX.source.strip}/i.freeze FILENAME_REGEX = /^#{MODULE_REGEX.source.strip}/i
# The `Regexp` used to determine if the strategy applies to the URL. # The `Regexp` used to determine if the strategy applies to the URL.
URL_MATCH_REGEX = %r{ URL_MATCH_REGEX = %r{
^https?://(?:[^/]+?\.)* # Scheme and any leading subdomains ^https?://(?:[^/]+?\.)* # Scheme and any leading subdomains
(?:x\.org/(?:[^/]+/)*individual/(?:[^/]+/)*#{MODULE_REGEX.source.strip} (?:x\.org/(?:[^/]+/)*individual/(?:[^/]+/)*#{MODULE_REGEX.source.strip}
|freedesktop\.org/(?:archive|dist|software)/(?:[^/]+/)*#{MODULE_REGEX.source.strip}) |freedesktop\.org/(?:archive|dist|software)/(?:[^/]+/)*#{MODULE_REGEX.source.strip})
}ix.freeze }ix
# Used to cache page content, so we don't fetch the same pages # Used to cache page content, so we don't fetch the same pages
# repeatedly. # repeatedly.

View File

@ -31,7 +31,7 @@ module Homebrew
PRIORITY = 0 PRIORITY = 0
# The `Regexp` used to determine if the strategy applies to the URL. # The `Regexp` used to determine if the strategy applies to the URL.
URL_MATCH_REGEX = %r{^https?://}i.freeze URL_MATCH_REGEX = %r{^https?://}i
# Whether the strategy can be applied to the provided URL. # Whether the strategy can be applied to the provided URL.
# {Yaml} will technically match any HTTP URL but is only usable with # {Yaml} will technically match any HTTP URL but is only usable with

View File

@ -12,18 +12,18 @@ class Locale
end end
# ISO 639-1 or ISO 639-2 # ISO 639-1 or ISO 639-2
LANGUAGE_REGEX = /(?:[a-z]{2,3})/.freeze LANGUAGE_REGEX = /(?:[a-z]{2,3})/
private_constant :LANGUAGE_REGEX private_constant :LANGUAGE_REGEX
# ISO 15924 # ISO 15924
SCRIPT_REGEX = /(?:[A-Z][a-z]{3})/.freeze SCRIPT_REGEX = /(?:[A-Z][a-z]{3})/
private_constant :SCRIPT_REGEX private_constant :SCRIPT_REGEX
# ISO 3166-1 or UN M.49 # ISO 3166-1 or UN M.49
REGION_REGEX = /(?:[A-Z]{2}|\d{3})/.freeze REGION_REGEX = /(?:[A-Z]{2}|\d{3})/
private_constant :REGION_REGEX private_constant :REGION_REGEX
LOCALE_REGEX = /\A((?:#{LANGUAGE_REGEX}|#{REGION_REGEX}|#{SCRIPT_REGEX})(?:-|$)){1,3}\Z/.freeze LOCALE_REGEX = /\A((?:#{LANGUAGE_REGEX}|#{REGION_REGEX}|#{SCRIPT_REGEX})(?:-|$)){1,3}\Z/
private_constant :LOCALE_REGEX private_constant :LOCALE_REGEX
def self.parse(string) def self.parse(string)

View File

@ -8,7 +8,7 @@ module OS
# @api private # @api private
class SDK class SDK
# 11.x SDKs are explicitly excluded - we want the MacOSX11.sdk symlink instead. # 11.x SDKs are explicitly excluded - we want the MacOSX11.sdk symlink instead.
VERSIONED_SDK_REGEX = /MacOSX(10\.\d+|\d+)\.sdk$/.freeze VERSIONED_SDK_REGEX = /MacOSX(10\.\d+|\d+)\.sdk$/
sig { returns(MacOSVersion) } sig { returns(MacOSVersion) }
attr_reader :version attr_reader :version

View File

@ -10,7 +10,7 @@ class PkgVersion
include Comparable include Comparable
extend Forwardable extend Forwardable
REGEX = /\A(.+?)(?:_(\d+))?\z/.freeze REGEX = /\A(.+?)(?:_(\d+))?\z/
private_constant :REGEX private_constant :REGEX
attr_reader :version, :revision attr_reader :version, :revision

View File

@ -12,7 +12,7 @@ module Readall
include Cachable include Cachable
# TODO: remove this once the `MacOS` module is undefined on Linux # TODO: remove this once the `MacOS` module is undefined on Linux
MACOS_MODULE_REGEX = /\b(MacOS|OS::Mac)(\.|::)\b/.freeze MACOS_MODULE_REGEX = /\b(MacOS|OS::Mac)(\.|::)\b/
private_constant :MACOS_MODULE_REGEX private_constant :MACOS_MODULE_REGEX
private :cache private :cache

View File

@ -153,7 +153,7 @@ module RuboCop
class LivecheckRegexExtension < FormulaCop class LivecheckRegexExtension < FormulaCop
extend AutoCorrector extend AutoCorrector
TAR_PATTERN = /\\?\.t(ar|(g|l|x)z$|[bz2]{2,4}$)(\\?\.((g|l|x)z)|[bz2]{2,4}|Z)?$/i.freeze TAR_PATTERN = /\\?\.t(ar|(g|l|x)z$|[bz2]{2,4}$)(\\?\.((g|l|x)z)|[bz2]{2,4}|Z)?$/i
def audit_formula(_node, _class_node, _parent_class_node, body_node) def audit_formula(_node, _class_node, _parent_class_node, body_node)
livecheck_node = find_block(body_node, :livecheck) livecheck_node = find_block(body_node, :livecheck)

View File

@ -188,7 +188,7 @@ module Homebrew
end end
end end
SOCKET_STRING_REGEX = %r{^([a-z]+)://(.+):([0-9]+)$}i.freeze SOCKET_STRING_REGEX = %r{^([a-z]+)://(.+):([0-9]+)$}i
sig { sig {
params(value: T.nilable(T.any(String, T::Hash[Symbol, String]))) params(value: T.nilable(T.any(String, T::Hash[Symbol, String])))

View File

@ -2,19 +2,19 @@
# frozen_string_literal: true # frozen_string_literal: true
# Match taps' formulae, e.g. `someuser/sometap/someformula` # Match taps' formulae, e.g. `someuser/sometap/someformula`
HOMEBREW_TAP_FORMULA_REGEX = T.let(%r{^([\w-]+)/([\w-]+)/([\w+-.@]+)$}.freeze, Regexp) HOMEBREW_TAP_FORMULA_REGEX = T.let(%r{^([\w-]+)/([\w-]+)/([\w+-.@]+)$}, Regexp)
# Match taps' casks, e.g. `someuser/sometap/somecask` # Match taps' casks, e.g. `someuser/sometap/somecask`
HOMEBREW_TAP_CASK_REGEX = T.let(%r{^([\w-]+)/([\w-]+)/([a-z0-9\-_]+)$}.freeze, Regexp) HOMEBREW_TAP_CASK_REGEX = T.let(%r{^([\w-]+)/([\w-]+)/([a-z0-9\-_]+)$}, Regexp)
# Match main cask taps' casks, e.g. `homebrew/cask/somecask` or `somecask` # Match main cask taps' casks, e.g. `homebrew/cask/somecask` or `somecask`
HOMEBREW_MAIN_TAP_CASK_REGEX = T.let(%r{^([Hh]omebrew/(?:homebrew-)?cask/)?[a-z0-9\-_]+$}.freeze, Regexp) HOMEBREW_MAIN_TAP_CASK_REGEX = T.let(%r{^([Hh]omebrew/(?:homebrew-)?cask/)?[a-z0-9\-_]+$}, Regexp)
# Match taps' directory paths, e.g. `HOMEBREW_LIBRARY/Taps/someuser/sometap` # Match taps' directory paths, e.g. `HOMEBREW_LIBRARY/Taps/someuser/sometap`
HOMEBREW_TAP_DIR_REGEX = T.let( HOMEBREW_TAP_DIR_REGEX = T.let(
%r{#{Regexp.escape(HOMEBREW_LIBRARY.to_s)}/Taps/(?<user>[\w-]+)/(?<repo>[\w-]+)}.freeze, Regexp %r{#{Regexp.escape(HOMEBREW_LIBRARY.to_s)}/Taps/(?<user>[\w-]+)/(?<repo>[\w-]+)}, Regexp
) )
# Match taps' formula paths, e.g. `HOMEBREW_LIBRARY/Taps/someuser/sometap/someformula` # Match taps' formula paths, e.g. `HOMEBREW_LIBRARY/Taps/someuser/sometap/someformula`
HOMEBREW_TAP_PATH_REGEX = T.let(Regexp.new(HOMEBREW_TAP_DIR_REGEX.source + %r{(?:/.*)?$}.source).freeze, Regexp) HOMEBREW_TAP_PATH_REGEX = T.let(Regexp.new(HOMEBREW_TAP_DIR_REGEX.source + %r{(?:/.*)?$}.source).freeze, Regexp)
# Match official taps' casks, e.g. `homebrew/cask/somecask or homebrew/cask-versions/somecask` # Match official taps' casks, e.g. `homebrew/cask/somecask or homebrew/cask-versions/somecask`
HOMEBREW_CASK_TAP_CASK_REGEX = HOMEBREW_CASK_TAP_CASK_REGEX =
T.let(%r{^(?:([Cc]askroom)/(cask|versions)|([Hh]omebrew)/(?:homebrew-)?(cask|cask-[\w-]+))/([\w+-.]+)$}.freeze, T.let(%r{^(?:([Cc]askroom)/(cask|versions)|([Hh]omebrew)/(?:homebrew-)?(cask|cask-[\w-]+))/([\w+-.]+)$},
Regexp) Regexp)
HOMEBREW_OFFICIAL_REPO_PREFIXES_REGEX = T.let(/^(home|linux)brew-/.freeze, Regexp) HOMEBREW_OFFICIAL_REPO_PREFIXES_REGEX = T.let(/^(home|linux)brew-/, Regexp)

View File

@ -83,7 +83,7 @@ describe Homebrew::Livecheck::Strategy::ElectronBuilder do
# block here simply to ensure this method works as expected when a # block here simply to ensure this method works as expected when a
# regex isn't provided. # regex isn't provided.
expect(electron_builder.find_versions(url: http_url, provided_content: content) do |yaml| expect(electron_builder.find_versions(url: http_url, provided_content: content) do |yaml|
regex = /^v?(\d+(?:\.\d+)+)$/i.freeze regex = /^v?(\d+(?:\.\d+)+)$/i
yaml["version"][regex, 1] yaml["version"][regex, 1]
end).to eq(find_versions_cached_return_hash) end).to eq(find_versions_cached_return_hash)
end end

View File

@ -130,7 +130,7 @@ describe Homebrew::Livecheck::Strategy::Json do
# block here simply to ensure this method works as expected when a # block here simply to ensure this method works as expected when a
# regex isn't provided. # regex isn't provided.
expect(json.find_versions(url: http_url, provided_content: content) do |json| expect(json.find_versions(url: http_url, provided_content: content) do |json|
regex = /^v?(\d+(?:\.\d+)+)$/i.freeze regex = /^v?(\d+(?:\.\d+)+)$/i
json["versions"].select { |item| item["version"]&.match?(regex) } json["versions"].select { |item| item["version"]&.match?(regex) }
.map { |item| item["version"][regex, 1] } .map { |item| item["version"][regex, 1] }
end).to eq(find_versions_cached_return_hash.merge({ regex: nil })) end).to eq(find_versions_cached_return_hash.merge({ regex: nil }))

View File

@ -222,7 +222,7 @@ describe Homebrew::Livecheck::Strategy::Xml do
# block here simply to ensure this method works as expected when a # block here simply to ensure this method works as expected when a
# regex isn't provided. # regex isn't provided.
expect(xml.find_versions(url: http_url, provided_content: content_version_text) do |xml| expect(xml.find_versions(url: http_url, provided_content: content_version_text) do |xml|
regex = /^v?(\d+(?:\.\d+)+)$/i.freeze regex = /^v?(\d+(?:\.\d+)+)$/i
xml.get_elements("/versions/version").map { |item| item.text[regex, 1] } xml.get_elements("/versions/version").map { |item| item.text[regex, 1] }
end).to eq(find_versions_cached_return_hash.merge({ regex: nil })) end).to eq(find_versions_cached_return_hash.merge({ regex: nil }))
end end

View File

@ -131,7 +131,7 @@ describe Homebrew::Livecheck::Strategy::Yaml do
# block here simply to ensure this method works as expected when a # block here simply to ensure this method works as expected when a
# regex isn't provided. # regex isn't provided.
expect(yaml.find_versions(url: http_url, provided_content: content) do |yaml| expect(yaml.find_versions(url: http_url, provided_content: content) do |yaml|
regex = /^v?(\d+(?:\.\d+)+)$/i.freeze regex = /^v?(\d+(?:\.\d+)+)$/i
yaml["versions"].select { |item| item["version"]&.match?(regex) } yaml["versions"].select { |item| item["version"]&.match?(regex) }
.map { |item| item["version"][regex, 1] } .map { |item| item["version"][regex, 1] }
end).to eq(find_versions_cached_return_hash.merge({ regex: nil })) end).to eq(find_versions_cached_return_hash.merge({ regex: nil }))

View File

@ -15,7 +15,7 @@ module Utils
# This regex is used to extract the part of an ETag within quotation marks, # This regex is used to extract the part of an ETag within quotation marks,
# ignoring any leading weak validator indicator (`W/`). This simplifies # ignoring any leading weak validator indicator (`W/`). This simplifies
# ETag comparison in `#curl_check_http_content`. # ETag comparison in `#curl_check_http_content`.
ETAG_VALUE_REGEX = %r{^(?:[wW]/)?"((?:[^"]|\\")*)"}.freeze ETAG_VALUE_REGEX = %r{^(?:[wW]/)?"((?:[^"]|\\")*)"}
# HTTP responses and body content are typically separated by a double # HTTP responses and body content are typically separated by a double
# `CRLF` (whereas HTTP header lines are separated by a single `CRLF`). # `CRLF` (whereas HTTP header lines are separated by a single `CRLF`).
@ -24,7 +24,7 @@ module Utils
# This regex is used to isolate the parts of an HTTP status line, namely # This regex is used to isolate the parts of an HTTP status line, namely
# the status code and any following descriptive text (e.g. `Not Found`). # the status code and any following descriptive text (e.g. `Not Found`).
HTTP_STATUS_LINE_REGEX = %r{^HTTP/.* (?<code>\d+)(?: (?<text>[^\r\n]+))?}.freeze HTTP_STATUS_LINE_REGEX = %r{^HTTP/.* (?<code>\d+)(?: (?<text>[^\r\n]+))?}
private_constant :ETAG_VALUE_REGEX, :HTTP_RESPONSE_BODY_SEPARATOR, :HTTP_STATUS_LINE_REGEX private_constant :ETAG_VALUE_REGEX, :HTTP_RESPONSE_BODY_SEPARATOR, :HTTP_STATUS_LINE_REGEX

View File

@ -509,9 +509,9 @@ module GitHub
end end
def self.pull_request_title_regex(name, version = nil) def self.pull_request_title_regex(name, version = nil)
return /(^|\s)#{Regexp.quote(name)}(:|,|\s|$)/i.freeze if version.blank? return /(^|\s)#{Regexp.quote(name)}(:|,|\s|$)/i if version.blank?
/(^|\s)#{Regexp.quote(name)}(:|,|\s)(.*\s)?#{Regexp.quote(version)}(:|,|\s|$)/i.freeze /(^|\s)#{Regexp.quote(name)}(:|,|\s)(.*\s)?#{Regexp.quote(version)}(:|,|\s|$)/i
end end
def self.fetch_pull_requests(name, tap_remote_repo, state: nil, version: nil) def self.fetch_pull_requests(name, tap_remote_repo, state: nil, version: nil)

View File

@ -26,7 +26,7 @@ module GitHub
CREATE_ISSUE_FORK_OR_PR_SCOPES = ["repo"].freeze CREATE_ISSUE_FORK_OR_PR_SCOPES = ["repo"].freeze
CREATE_WORKFLOW_SCOPES = ["workflow"].freeze CREATE_WORKFLOW_SCOPES = ["workflow"].freeze
ALL_SCOPES = (CREATE_GIST_SCOPES + CREATE_ISSUE_FORK_OR_PR_SCOPES + CREATE_WORKFLOW_SCOPES).freeze ALL_SCOPES = (CREATE_GIST_SCOPES + CREATE_ISSUE_FORK_OR_PR_SCOPES + CREATE_WORKFLOW_SCOPES).freeze
GITHUB_PERSONAL_ACCESS_TOKEN_REGEX = /^(?:[a-f0-9]{40}|gh[po]_\w{36,251})$/.freeze GITHUB_PERSONAL_ACCESS_TOKEN_REGEX = /^(?:[a-f0-9]{40}|gh[po]_\w{36,251})$/
# Helper functions to access the GitHub API. # Helper functions to access the GitHub API.
# #

View File

@ -106,7 +106,7 @@ module Utils
zsh: "~/.zshrc", zsh: "~/.zshrc",
}.freeze }.freeze
UNSAFE_SHELL_CHAR = %r{([^A-Za-z0-9_\-.,:/@~\n])}.freeze UNSAFE_SHELL_CHAR = %r{([^A-Za-z0-9_\-.,:/@~\n])}
sig { params(str: String).returns(String) } sig { params(str: String).returns(String) }
def csh_quote(str) def csh_quote(str)

View File

@ -139,7 +139,7 @@ class Version
# A token string. # A token string.
class StringToken < Token class StringToken < Token
PATTERN = /[a-z]+/i.freeze PATTERN = /[a-z]+/i
sig { override.returns(String) } sig { override.returns(String) }
attr_reader :value attr_reader :value
@ -164,7 +164,7 @@ class Version
# A token consisting of only numbers. # A token consisting of only numbers.
class NumericToken < Token class NumericToken < Token
PATTERN = /[0-9]+/i.freeze PATTERN = /[0-9]+/i
sig { override.returns(Integer) } sig { override.returns(Integer) }
attr_reader :value attr_reader :value
@ -204,7 +204,7 @@ class Version
# A token representing the part of a version designating it as an alpha release. # A token representing the part of a version designating it as an alpha release.
class AlphaToken < CompositeToken class AlphaToken < CompositeToken
PATTERN = /alpha[0-9]*|a[0-9]+/i.freeze PATTERN = /alpha[0-9]*|a[0-9]+/i
sig { override.params(other: T.untyped).returns(T.nilable(Integer)) } sig { override.params(other: T.untyped).returns(T.nilable(Integer)) }
def <=>(other) def <=>(other)
@ -223,7 +223,7 @@ class Version
# A token representing the part of a version designating it as a beta release. # A token representing the part of a version designating it as a beta release.
class BetaToken < CompositeToken class BetaToken < CompositeToken
PATTERN = /beta[0-9]*|b[0-9]+/i.freeze PATTERN = /beta[0-9]*|b[0-9]+/i
sig { override.params(other: T.untyped).returns(T.nilable(Integer)) } sig { override.params(other: T.untyped).returns(T.nilable(Integer)) }
def <=>(other) def <=>(other)
@ -244,7 +244,7 @@ class Version
# A token representing the part of a version designating it as a pre-release. # A token representing the part of a version designating it as a pre-release.
class PreToken < CompositeToken class PreToken < CompositeToken
PATTERN = /pre[0-9]*/i.freeze PATTERN = /pre[0-9]*/i
sig { override.params(other: T.untyped).returns(T.nilable(Integer)) } sig { override.params(other: T.untyped).returns(T.nilable(Integer)) }
def <=>(other) def <=>(other)
@ -265,7 +265,7 @@ class Version
# A token representing the part of a version designating it as a release candidate. # A token representing the part of a version designating it as a release candidate.
class RCToken < CompositeToken class RCToken < CompositeToken
PATTERN = /rc[0-9]*/i.freeze PATTERN = /rc[0-9]*/i
sig { override.params(other: T.untyped).returns(T.nilable(Integer)) } sig { override.params(other: T.untyped).returns(T.nilable(Integer)) }
def <=>(other) def <=>(other)
@ -286,7 +286,7 @@ class Version
# A token representing the part of a version designating it as a patch release. # A token representing the part of a version designating it as a patch release.
class PatchToken < CompositeToken class PatchToken < CompositeToken
PATTERN = /p[0-9]*/i.freeze PATTERN = /p[0-9]*/i
sig { override.params(other: T.untyped).returns(T.nilable(Integer)) } sig { override.params(other: T.untyped).returns(T.nilable(Integer)) }
def <=>(other) def <=>(other)
@ -305,7 +305,7 @@ class Version
# A token representing the part of a version designating it as a post release. # A token representing the part of a version designating it as a post release.
class PostToken < CompositeToken class PostToken < CompositeToken
PATTERN = /.post[0-9]+/i.freeze PATTERN = /.post[0-9]+/i
sig { override.params(other: T.untyped).returns(T.nilable(Integer)) } sig { override.params(other: T.untyped).returns(T.nilable(Integer)) }
def <=>(other) def <=>(other)
@ -503,7 +503,7 @@ class Version
@detected_from_url @detected_from_url
end end
HEAD_VERSION_REGEX = /\AHEAD(?:-(?<commit>.*))?\Z/.freeze HEAD_VERSION_REGEX = /\AHEAD(?:-(?<commit>.*))?\Z/
private_constant :HEAD_VERSION_REGEX private_constant :HEAD_VERSION_REGEX
# Check if this is a HEAD version. # Check if this is a HEAD version.

View File

@ -49,8 +49,8 @@ class Version
# @api private # @api private
class StemParser < RegexParser class StemParser < RegexParser
SOURCEFORGE_DOWNLOAD_REGEX = %r{(?:sourceforge\.net|sf\.net)/.*/download$}.freeze SOURCEFORGE_DOWNLOAD_REGEX = %r{(?:sourceforge\.net|sf\.net)/.*/download$}
NO_FILE_EXTENSION_REGEX = /\.[^a-zA-Z]+$/.freeze NO_FILE_EXTENSION_REGEX = /\.[^a-zA-Z]+$/
sig { override.params(spec: Pathname).returns(String) } sig { override.params(spec: Pathname).returns(String) }
def self.process_spec(spec) def self.process_spec(spec)