From f682147598fe5b617a01582804daf26dd3c42f35 Mon Sep 17 00:00:00 2001 From: Issy Long Date: Thu, 18 Jan 2024 22:18:42 +0000 Subject: [PATCH] Fix RuboCop `Style/RedundantFreeze` offenses --- Library/.rubocop.yml | 2 -- Library/Homebrew/cask/dsl/version.rb | 6 +++--- Library/Homebrew/cli/named_args.rb | 4 ++-- Library/Homebrew/cmd/update-report.rb | 2 +- Library/Homebrew/commands.rb | 2 +- Library/Homebrew/compilers.rb | 2 +- Library/Homebrew/dev-cmd/extract.rb | 2 +- Library/Homebrew/extend/blank.rb | 2 +- Library/Homebrew/extend/os/mac/keg_relocate.rb | 6 +++--- Library/Homebrew/formulary.rb | 2 +- Library/Homebrew/github_packages.rb | 6 +++--- Library/Homebrew/github_releases.rb | 2 +- Library/Homebrew/global.rb | 6 +++--- Library/Homebrew/keg.rb | 4 ++-- Library/Homebrew/keg_relocate.rb | 4 ++-- Library/Homebrew/language/node.rb | 2 +- Library/Homebrew/language/perl.rb | 2 +- Library/Homebrew/language/python.rb | 2 +- Library/Homebrew/livecheck/strategy.rb | 2 +- Library/Homebrew/livecheck/strategy/apache.rb | 2 +- .../Homebrew/livecheck/strategy/bitbucket.rb | 2 +- Library/Homebrew/livecheck/strategy/cpan.rb | 2 +- .../livecheck/strategy/electron_builder.rb | 2 +- .../livecheck/strategy/extract_plist.rb | 2 +- Library/Homebrew/livecheck/strategy/git.rb | 2 +- .../livecheck/strategy/github_releases.rb | 4 ++-- Library/Homebrew/livecheck/strategy/gnome.rb | 2 +- Library/Homebrew/livecheck/strategy/gnu.rb | 2 +- Library/Homebrew/livecheck/strategy/hackage.rb | 6 +++--- .../livecheck/strategy/header_match.rb | 2 +- Library/Homebrew/livecheck/strategy/json.rb | 2 +- .../Homebrew/livecheck/strategy/launchpad.rb | 4 ++-- Library/Homebrew/livecheck/strategy/npm.rb | 2 +- .../Homebrew/livecheck/strategy/page_match.rb | 2 +- Library/Homebrew/livecheck/strategy/pypi.rb | 4 ++-- .../Homebrew/livecheck/strategy/sourceforge.rb | 2 +- Library/Homebrew/livecheck/strategy/sparkle.rb | 2 +- Library/Homebrew/livecheck/strategy/xml.rb | 2 +- Library/Homebrew/livecheck/strategy/xorg.rb | 6 +++--- Library/Homebrew/livecheck/strategy/yaml.rb | 2 +- Library/Homebrew/locale.rb | 8 ++++---- Library/Homebrew/os/mac/sdk.rb | 2 +- Library/Homebrew/pkg_version.rb | 2 +- Library/Homebrew/readall.rb | 2 +- Library/Homebrew/rubocops/livecheck.rb | 2 +- Library/Homebrew/service.rb | 2 +- Library/Homebrew/tap_constants.rb | 12 ++++++------ .../strategy/electron_builder_spec.rb | 2 +- .../test/livecheck/strategy/json_spec.rb | 2 +- .../test/livecheck/strategy/xml_spec.rb | 2 +- .../test/livecheck/strategy/yaml_spec.rb | 2 +- Library/Homebrew/utils/curl.rb | 4 ++-- Library/Homebrew/utils/github.rb | 4 ++-- Library/Homebrew/utils/github/api.rb | 2 +- Library/Homebrew/utils/shell.rb | 2 +- Library/Homebrew/version.rb | 18 +++++++++--------- Library/Homebrew/version/parser.rb | 4 ++-- 57 files changed, 93 insertions(+), 95 deletions(-) diff --git a/Library/.rubocop.yml b/Library/.rubocop.yml index 617d074a00bdd..0b462901469c0 100644 --- a/Library/.rubocop.yml +++ b/Library/.rubocop.yml @@ -461,5 +461,3 @@ Style/ArrayIntersect: Enabled: false Style/HashSyntax: EnforcedShorthandSyntax: either -Style/RedundantFreeze: - Enabled: false diff --git a/Library/Homebrew/cask/dsl/version.rb b/Library/Homebrew/cask/dsl/version.rb index 7c3ec7d3f8aa9..e6488c9c5c944 100644 --- a/Library/Homebrew/cask/dsl/version.rb +++ b/Library/Homebrew/cask/dsl/version.rb @@ -13,11 +13,11 @@ class Version < ::String "_" => :underscores, }.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 private diff --git a/Library/Homebrew/cli/named_args.rb b/Library/Homebrew/cli/named_args.rb index c6f6f6097628f..04f81687ba970 100644 --- a/Library/Homebrew/cli/named_args.rb +++ b/Library/Homebrew/cli/named_args.rb @@ -222,8 +222,8 @@ def to_resolved_formulae_to_casks(only: parent&.only_formula_or_cask) to_formulae_to_casks(only: only, method: :resolve) end - LOCAL_PATH_REGEX = %r{^/|[.]|/$}.freeze - TAP_NAME_REGEX = %r{^[^./]+/[^./]+$}.freeze + LOCAL_PATH_REGEX = %r{^/|[.]|/$} + TAP_NAME_REGEX = %r{^[^./]+/[^./]+$} private_constant :LOCAL_PATH_REGEX, :TAP_NAME_REGEX # Keep existing paths and try to convert others to tap, formula or cask paths. diff --git a/Library/Homebrew/cmd/update-report.rb b/Library/Homebrew/cmd/update-report.rb index 6eef639aa9eeb..97cbfd604c3ab 100644 --- a/Library/Homebrew/cmd/update-report.rb +++ b/Library/Homebrew/cmd/update-report.rb @@ -714,7 +714,7 @@ def diff # 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. 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 diff_output.lines.map do |line| diff --git a/Library/Homebrew/commands.rb b/Library/Homebrew/commands.rb index 89774bfe7cf54..9d8c5bb9c0432 100644 --- a/Library/Homebrew/commands.rb +++ b/Library/Homebrew/commands.rb @@ -35,7 +35,7 @@ module Commands # 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 # middle due to dots in URLs or paths. - DESCRIPTION_SPLITTING_PATTERN = /\.(?>\s|$)/.freeze + DESCRIPTION_SPLITTING_PATTERN = /\.(?>\s|$)/ def self.valid_internal_cmd?(cmd) require?(HOMEBREW_CMD_PATH/cmd) diff --git a/Library/Homebrew/compilers.rb b/Library/Homebrew/compilers.rb index bd49263dd8dea..93c106a1026ac 100644 --- a/Library/Homebrew/compilers.rb +++ b/Library/Homebrew/compilers.rb @@ -4,7 +4,7 @@ # @private module CompilerConstants 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 = { "gcc" => :gcc, "clang" => :clang, diff --git a/Library/Homebrew/dev-cmd/extract.rb b/Library/Homebrew/dev-cmd/extract.rb index 9b17567d75586..1f3aea1c2946e 100644 --- a/Library/Homebrew/dev-cmd/extract.rb +++ b/Library/Homebrew/dev-cmd/extract.rb @@ -69,7 +69,7 @@ def with_monkey_patch end 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) } def self.extract_args diff --git a/Library/Homebrew/extend/blank.rb b/Library/Homebrew/extend/blank.rb index 5aa09c033af57..b13f991f1373d 100644 --- a/Library/Homebrew/extend/blank.rb +++ b/Library/Homebrew/extend/blank.rb @@ -132,7 +132,7 @@ def present? # :nodoc: end class String - BLANK_RE = /\A[[:space:]]*\z/.freeze + BLANK_RE = /\A[[:space:]]*\z/ # This is a cache that is intentionally mutable # rubocop:disable Style/MutableConstant ENCODED_BLANKS_ = T.let(Hash.new do |h, enc| diff --git a/Library/Homebrew/extend/os/mac/keg_relocate.rb b/Library/Homebrew/extend/os/mac/keg_relocate.rb index 1899776990a62..783f391e275fe 100644 --- a/Library/Homebrew/extend/os/mac/keg_relocate.rb +++ b/Library/Homebrew/extend/os/mac/keg_relocate.rb @@ -130,7 +130,7 @@ def fixed_name(file, bad_name) 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) file.public_send(linkage_type, resolve_variable_references: resolve_variable_references) @@ -159,7 +159,7 @@ def relocated_name_for(old_name, relocation) # Matches framework references like `XXX.framework/Versions/YYY/XXX` and # `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) if (framework = bad_name.match(FRAMEWORK_RX)) @@ -233,7 +233,7 @@ def egrep_args private - CELLAR_RX = %r{\A#{HOMEBREW_CELLAR}/(?[^/]+)/[^/]+}.freeze + CELLAR_RX = %r{\A#{HOMEBREW_CELLAR}/(?[^/]+)/[^/]+} # Replace HOMEBREW_CELLAR references with HOMEBREW_PREFIX/opt references # if the Cellar reference is to a different keg. diff --git a/Library/Homebrew/formulary.rb b/Library/Homebrew/formulary.rb index 670696926c267..f473dcb08a5e9 100644 --- a/Library/Homebrew/formulary.rb +++ b/Library/Homebrew/formulary.rb @@ -18,7 +18,7 @@ module Formulary 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 API_SUPPORTED_REQUIREMENTS = [:arch, :linux, :macos, :maximum_macos, :xcode].freeze diff --git a/Library/Homebrew/github_packages.rb b/Library/Homebrew/github_packages.rb index f5f87deed89c4..9d3fc79bcb845 100644 --- a/Library/Homebrew/github_packages.rb +++ b/Library/Homebrew/github_packages.rb @@ -18,12 +18,12 @@ class GitHubPackages private_constant :URL_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 # 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 - INVALID_OCI_TAG_CHARS_REGEX = /[^a-zA-Z0-9._-]/.freeze + VALID_OCI_TAG_REGEX = /^[a-zA-Z0-9_][a-zA-Z0-9._-]{0,127}$/ + INVALID_OCI_TAG_CHARS_REGEX = /[^a-zA-Z0-9._-]/ GZIP_BUFFER_SIZE = 64 * 1024 private_constant :GZIP_BUFFER_SIZE diff --git a/Library/Homebrew/github_releases.rb b/Library/Homebrew/github_releases.rb index e58b1fffbdef8..fdd08efdf8531 100644 --- a/Library/Homebrew/github_releases.rb +++ b/Library/Homebrew/github_releases.rb @@ -10,7 +10,7 @@ class GitHubReleases 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 } def upload_bottles(bottles_hash) diff --git a/Library/Homebrew/global.rb b/Library/Homebrew/global.rb index 691f5a3f983b4..d747954e2bdae 100644 --- a/Library/Homebrew/global.rb +++ b/Library/Homebrew/global.rb @@ -65,10 +65,10 @@ HOMEBREW_MACOS_OLDEST_ALLOWED = ENV.fetch("HOMEBREW_MACOS_OLDEST_ALLOWED").freeze 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 = - %r[https://github\.com/([\w-]+)/([\w-]+)?/(?:pull/(\d+)|commit/[0-9a-fA-F]{4,40})].freeze -HOMEBREW_BOTTLES_EXTNAME_REGEX = /\.([a-z0-9_]+)\.bottle\.(?:(\d+)\.)?tar\.gz$/.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$/ require "extend/module" require "extend/blank" diff --git a/Library/Homebrew/keg.rb b/Library/Homebrew/keg.rb index ea9ce4cb6aa8e..b78ef2e3c9d9f 100644 --- a/Library/Homebrew/keg.rb +++ b/Library/Homebrew/keg.rb @@ -78,8 +78,8 @@ def to_s end # 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 - INFOFILE_RX = %r{info/([^.].*?\.info|dir)$}.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)$} KEG_LINK_DIRECTORIES = %w[ bin etc include lib sbin share var ].freeze diff --git a/Library/Homebrew/keg_relocate.rb b/Library/Homebrew/keg_relocate.rb index 7173c27a74fff..69809a5859f61 100644 --- a/Library/Homebrew/keg_relocate.rb +++ b/Library/Homebrew/keg_relocate.rb @@ -12,7 +12,7 @@ class Keg NULL_BYTE_STRING = "\\x00" class Relocation - RELOCATABLE_PATH_REGEX_PREFIX = /(?:(?<=-F|-I|-L|-isystem)|(?[^/]*?) # Any text in filename or directory before version v?\d+(?:\.\d+)+ # The numeric version (?/|[^/]*) # Any text in filename or directory after version - }ix.freeze + }ix # Whether the strategy can be applied to the provided URL. # diff --git a/Library/Homebrew/livecheck/strategy/bitbucket.rb b/Library/Homebrew/livecheck/strategy/bitbucket.rb index 822b6fe4b992e..f4599dbf517c5 100644 --- a/Library/Homebrew/livecheck/strategy/bitbucket.rb +++ b/Library/Homebrew/livecheck/strategy/bitbucket.rb @@ -36,7 +36,7 @@ class Bitbucket /(?(?:[^/]+?[_-])?) # Filename text before the version v?\d+(?:\.\d+)+ # The numeric version (?[^/]+) # Filename text after the version - }ix.freeze + }ix # Whether the strategy can be applied to the provided URL. # diff --git a/Library/Homebrew/livecheck/strategy/cpan.rb b/Library/Homebrew/livecheck/strategy/cpan.rb index 751e5189b3246..a54128778d15c 100644 --- a/Library/Homebrew/livecheck/strategy/cpan.rb +++ b/Library/Homebrew/livecheck/strategy/cpan.rb @@ -27,7 +27,7 @@ class Cpan (?[^/]+) # Filename text before the version -v?\d+(?:\.\d+)* # The numeric version (?[^/]+) # Filename text after the version - }ix.freeze + }ix # Whether the strategy can be applied to the provided URL. # diff --git a/Library/Homebrew/livecheck/strategy/electron_builder.rb b/Library/Homebrew/livecheck/strategy/electron_builder.rb index 7f9d435262a20..a57027e30ae3b 100644 --- a/Library/Homebrew/livecheck/strategy/electron_builder.rb +++ b/Library/Homebrew/livecheck/strategy/electron_builder.rb @@ -19,7 +19,7 @@ class ElectronBuilder PRIORITY = 0 # 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. # diff --git a/Library/Homebrew/livecheck/strategy/extract_plist.rb b/Library/Homebrew/livecheck/strategy/extract_plist.rb index 96ab1f19a04a7..1e348f7215207 100644 --- a/Library/Homebrew/livecheck/strategy/extract_plist.rb +++ b/Library/Homebrew/livecheck/strategy/extract_plist.rb @@ -24,7 +24,7 @@ class ExtractPlist PRIORITY = 0 # 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. # diff --git a/Library/Homebrew/livecheck/strategy/git.rb b/Library/Homebrew/livecheck/strategy/git.rb index ed669b39f0415..77dc3d2587dff 100644 --- a/Library/Homebrew/livecheck/strategy/git.rb +++ b/Library/Homebrew/livecheck/strategy/git.rb @@ -30,7 +30,7 @@ class Git # The default regex used to naively identify versions from tags when a # regex isn't provided. - DEFAULT_REGEX = /\D*(.+)/.freeze + DEFAULT_REGEX = /\D*(.+)/ # Whether the strategy can be applied to the provided URL. # diff --git a/Library/Homebrew/livecheck/strategy/github_releases.rb b/Library/Homebrew/livecheck/strategy/github_releases.rb index eb18bdbe0f69e..7bd04c024b609 100644 --- a/Library/Homebrew/livecheck/strategy/github_releases.rb +++ b/Library/Homebrew/livecheck/strategy/github_releases.rb @@ -41,11 +41,11 @@ class GithubReleases ^https?://github\.com /(?:downloads/)?(?[^/]+) # The GitHub username /(?[^/]+) # The GitHub repository name - }ix.freeze + }ix # The default regex used to identify a version from a tag when a regex # 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. # The tag name is checked first, to better align with the {Git} diff --git a/Library/Homebrew/livecheck/strategy/gnome.rb b/Library/Homebrew/livecheck/strategy/gnome.rb index 5ef8f27fcd697..d000e546866a7 100644 --- a/Library/Homebrew/livecheck/strategy/gnome.rb +++ b/Library/Homebrew/livecheck/strategy/gnome.rb @@ -32,7 +32,7 @@ class Gnome ^https?://download\.gnome\.org /sources /(?[^/]+)/ # The GNOME package name - }ix.freeze + }ix # Whether the strategy can be applied to the provided URL. # diff --git a/Library/Homebrew/livecheck/strategy/gnu.rb b/Library/Homebrew/livecheck/strategy/gnu.rb index 59c29e22e2cc7..90c39af566d40 100644 --- a/Library/Homebrew/livecheck/strategy/gnu.rb +++ b/Library/Homebrew/livecheck/strategy/gnu.rb @@ -36,7 +36,7 @@ class Gnu ^https?:// (?:(?:[^/]+?\.)*gnu\.org/(?:gnu|software)/(?[^/]+)/ |(?[^/]+)\.gnu\.org/?$) - }ix.freeze + }ix # Whether the strategy can be applied to the provided URL. # diff --git a/Library/Homebrew/livecheck/strategy/hackage.rb b/Library/Homebrew/livecheck/strategy/hackage.rb index 26c5ab6594035..32e37d5412f79 100644 --- a/Library/Homebrew/livecheck/strategy/hackage.rb +++ b/Library/Homebrew/livecheck/strategy/hackage.rb @@ -19,17 +19,17 @@ module Strategy class Hackage # 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. - PACKAGE_NAME_REGEX = /(?.+?)-\d+/i.freeze + PACKAGE_NAME_REGEX = /(?.+?)-\d+/i # 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. URL_MATCH_REGEX = %r{ ^https?://(?:downloads|hackage)\.haskell\.org (?:/[^/]+)+ # Path before the filename #{PACKAGE_NAME_REGEX.source.strip} - }ix.freeze + }ix # Whether the strategy can be applied to the provided URL. # diff --git a/Library/Homebrew/livecheck/strategy/header_match.rb b/Library/Homebrew/livecheck/strategy/header_match.rb index a0d2729bb7008..9af862fa82424 100644 --- a/Library/Homebrew/livecheck/strategy/header_match.rb +++ b/Library/Homebrew/livecheck/strategy/header_match.rb @@ -19,7 +19,7 @@ class HeaderMatch PRIORITY = 0 # 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. DEFAULT_HEADERS_TO_CHECK = ["content-disposition", "location"].freeze diff --git a/Library/Homebrew/livecheck/strategy/json.rb b/Library/Homebrew/livecheck/strategy/json.rb index 3cf1c475ab1d7..7bd8cf8b07719 100644 --- a/Library/Homebrew/livecheck/strategy/json.rb +++ b/Library/Homebrew/livecheck/strategy/json.rb @@ -31,7 +31,7 @@ class Json PRIORITY = 0 # 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. # {Json} will technically match any HTTP URL but is only usable with diff --git a/Library/Homebrew/livecheck/strategy/launchpad.rb b/Library/Homebrew/livecheck/strategy/launchpad.rb index cf6518ac07eb2..811d81e4beea8 100644 --- a/Library/Homebrew/livecheck/strategy/launchpad.rb +++ b/Library/Homebrew/livecheck/strategy/launchpad.rb @@ -27,11 +27,11 @@ class Launchpad URL_MATCH_REGEX = %r{ ^https?://(?:[^/]+?\.)*launchpad\.net /(?[^/]+) # The Launchpad project name - }ix.freeze + }ix # The default regex used to identify the latest version when a regex # isn't provided. - DEFAULT_REGEX = %r{class="[^"]*version[^"]*"[^>]*>\s*Latest version is (.+)\s*]*>\s*Latest version is (.+)\s*.+?)/-/ # The npm package name - }ix.freeze + }ix # Whether the strategy can be applied to the provided URL. # diff --git a/Library/Homebrew/livecheck/strategy/page_match.rb b/Library/Homebrew/livecheck/strategy/page_match.rb index 753b57adef732..821119d81068d 100644 --- a/Library/Homebrew/livecheck/strategy/page_match.rb +++ b/Library/Homebrew/livecheck/strategy/page_match.rb @@ -24,7 +24,7 @@ class PageMatch PRIORITY = 0 # 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. # {PageMatch} will technically match any HTTP URL but is only diff --git a/Library/Homebrew/livecheck/strategy/pypi.rb b/Library/Homebrew/livecheck/strategy/pypi.rb index 4be3eb970a650..1d9cd1c654c2f 100644 --- a/Library/Homebrew/livecheck/strategy/pypi.rb +++ b/Library/Homebrew/livecheck/strategy/pypi.rb @@ -25,7 +25,7 @@ class Pypi (?.+)- # The package name followed by a hyphen .*? # The version string (?\.tar\.[a-z0-9]+|\.[a-z0-9]+)$ # Filename extension - /ix.freeze + /ix # The `Regexp` used to determine if the strategy applies to the URL. URL_MATCH_REGEX = %r{ @@ -33,7 +33,7 @@ class Pypi /packages (?:/[^/]+)+ # The hexadecimal paths before the filename /#{FILENAME_REGEX.source.strip} # The filename - }ix.freeze + }ix # Whether the strategy can be applied to the provided URL. # diff --git a/Library/Homebrew/livecheck/strategy/sourceforge.rb b/Library/Homebrew/livecheck/strategy/sourceforge.rb index aa8d8d9d5cdb5..66d97968cda31 100644 --- a/Library/Homebrew/livecheck/strategy/sourceforge.rb +++ b/Library/Homebrew/livecheck/strategy/sourceforge.rb @@ -39,7 +39,7 @@ class Sourceforge (?:/projects?/(?[^/]+)/ |/p/(?[^/]+)/ |(?::/cvsroot)?/(?[^/]+)) - }ix.freeze + }ix # Whether the strategy can be applied to the provided URL. # diff --git a/Library/Homebrew/livecheck/strategy/sparkle.rb b/Library/Homebrew/livecheck/strategy/sparkle.rb index ece1a4912ab08..dcfaf2f97358f 100644 --- a/Library/Homebrew/livecheck/strategy/sparkle.rb +++ b/Library/Homebrew/livecheck/strategy/sparkle.rb @@ -19,7 +19,7 @@ class Sparkle PRIORITY = 0 # 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. APPCAST_MACOS_STRINGS = ["macos", "osx"].freeze diff --git a/Library/Homebrew/livecheck/strategy/xml.rb b/Library/Homebrew/livecheck/strategy/xml.rb index 128db596ba195..3a535103a082b 100644 --- a/Library/Homebrew/livecheck/strategy/xml.rb +++ b/Library/Homebrew/livecheck/strategy/xml.rb @@ -35,7 +35,7 @@ class Xml PRIORITY = 0 # 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. # {Xml} will technically match any HTTP URL but is only usable with diff --git a/Library/Homebrew/livecheck/strategy/xorg.rb b/Library/Homebrew/livecheck/strategy/xorg.rb index ed73d42bc67a0..79bb2c9766393 100644 --- a/Library/Homebrew/livecheck/strategy/xorg.rb +++ b/Library/Homebrew/livecheck/strategy/xorg.rb @@ -42,17 +42,17 @@ class Xorg # 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. - MODULE_REGEX = /(?.+)-\d+/i.freeze + MODULE_REGEX = /(?.+)-\d+/i # 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. URL_MATCH_REGEX = %r{ ^https?://(?:[^/]+?\.)* # Scheme and any leading subdomains (?:x\.org/(?:[^/]+/)*individual/(?:[^/]+/)*#{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 # repeatedly. diff --git a/Library/Homebrew/livecheck/strategy/yaml.rb b/Library/Homebrew/livecheck/strategy/yaml.rb index 2f75f573782fd..3e3bc16ab3422 100644 --- a/Library/Homebrew/livecheck/strategy/yaml.rb +++ b/Library/Homebrew/livecheck/strategy/yaml.rb @@ -31,7 +31,7 @@ class Yaml PRIORITY = 0 # 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. # {Yaml} will technically match any HTTP URL but is only usable with diff --git a/Library/Homebrew/locale.rb b/Library/Homebrew/locale.rb index 2f2863a7b6a56..df8996c4410b1 100644 --- a/Library/Homebrew/locale.rb +++ b/Library/Homebrew/locale.rb @@ -12,18 +12,18 @@ class ParserError < StandardError end # ISO 639-1 or ISO 639-2 - LANGUAGE_REGEX = /(?:[a-z]{2,3})/.freeze + LANGUAGE_REGEX = /(?:[a-z]{2,3})/ private_constant :LANGUAGE_REGEX # ISO 15924 - SCRIPT_REGEX = /(?:[A-Z][a-z]{3})/.freeze + SCRIPT_REGEX = /(?:[A-Z][a-z]{3})/ private_constant :SCRIPT_REGEX # 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 - 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 def self.parse(string) diff --git a/Library/Homebrew/os/mac/sdk.rb b/Library/Homebrew/os/mac/sdk.rb index baa2b55985887..23c0e52202222 100644 --- a/Library/Homebrew/os/mac/sdk.rb +++ b/Library/Homebrew/os/mac/sdk.rb @@ -8,7 +8,7 @@ module Mac # @api private class SDK # 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) } attr_reader :version diff --git a/Library/Homebrew/pkg_version.rb b/Library/Homebrew/pkg_version.rb index 07425903c65c3..e63877aafca97 100644 --- a/Library/Homebrew/pkg_version.rb +++ b/Library/Homebrew/pkg_version.rb @@ -10,7 +10,7 @@ class PkgVersion include Comparable extend Forwardable - REGEX = /\A(.+?)(?:_(\d+))?\z/.freeze + REGEX = /\A(.+?)(?:_(\d+))?\z/ private_constant :REGEX attr_reader :version, :revision diff --git a/Library/Homebrew/readall.rb b/Library/Homebrew/readall.rb index 8faa67554a6fa..93f2b4ecbc87b 100644 --- a/Library/Homebrew/readall.rb +++ b/Library/Homebrew/readall.rb @@ -12,7 +12,7 @@ class << self include Cachable # 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 :cache diff --git a/Library/Homebrew/rubocops/livecheck.rb b/Library/Homebrew/rubocops/livecheck.rb index b9a45087bf087..24460a9bce4d1 100644 --- a/Library/Homebrew/rubocops/livecheck.rb +++ b/Library/Homebrew/rubocops/livecheck.rb @@ -153,7 +153,7 @@ def audit_formula(_node, _class_node, _parent_class_node, body_node) class LivecheckRegexExtension < FormulaCop 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) livecheck_node = find_block(body_node, :livecheck) diff --git a/Library/Homebrew/service.rb b/Library/Homebrew/service.rb index 09e2fb6b59faf..1fe6e86e6b36b 100644 --- a/Library/Homebrew/service.rb +++ b/Library/Homebrew/service.rb @@ -188,7 +188,7 @@ def run_at_load(value = nil) end end - SOCKET_STRING_REGEX = %r{^([a-z]+)://(.+):([0-9]+)$}i.freeze + SOCKET_STRING_REGEX = %r{^([a-z]+)://(.+):([0-9]+)$}i sig { params(value: T.nilable(T.any(String, T::Hash[Symbol, String]))) diff --git a/Library/Homebrew/tap_constants.rb b/Library/Homebrew/tap_constants.rb index f7d4e7c90f5db..2df0d9a759831 100644 --- a/Library/Homebrew/tap_constants.rb +++ b/Library/Homebrew/tap_constants.rb @@ -2,19 +2,19 @@ # frozen_string_literal: true # 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` -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` -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` HOMEBREW_TAP_DIR_REGEX = T.let( - %r{#{Regexp.escape(HOMEBREW_LIBRARY.to_s)}/Taps/(?[\w-]+)/(?[\w-]+)}.freeze, Regexp + %r{#{Regexp.escape(HOMEBREW_LIBRARY.to_s)}/Taps/(?[\w-]+)/(?[\w-]+)}, Regexp ) # 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) # Match official taps' casks, e.g. `homebrew/cask/somecask or homebrew/cask-versions/somecask` 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) -HOMEBREW_OFFICIAL_REPO_PREFIXES_REGEX = T.let(/^(home|linux)brew-/.freeze, Regexp) +HOMEBREW_OFFICIAL_REPO_PREFIXES_REGEX = T.let(/^(home|linux)brew-/, Regexp) diff --git a/Library/Homebrew/test/livecheck/strategy/electron_builder_spec.rb b/Library/Homebrew/test/livecheck/strategy/electron_builder_spec.rb index 6534d6d5e26b5..b129ed5a5901e 100644 --- a/Library/Homebrew/test/livecheck/strategy/electron_builder_spec.rb +++ b/Library/Homebrew/test/livecheck/strategy/electron_builder_spec.rb @@ -83,7 +83,7 @@ # block here simply to ensure this method works as expected when a # regex isn't provided. 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] end).to eq(find_versions_cached_return_hash) end diff --git a/Library/Homebrew/test/livecheck/strategy/json_spec.rb b/Library/Homebrew/test/livecheck/strategy/json_spec.rb index bdb4c59b96a3d..f92c74afa846d 100644 --- a/Library/Homebrew/test/livecheck/strategy/json_spec.rb +++ b/Library/Homebrew/test/livecheck/strategy/json_spec.rb @@ -130,7 +130,7 @@ # block here simply to ensure this method works as expected when a # regex isn't provided. 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) } .map { |item| item["version"][regex, 1] } end).to eq(find_versions_cached_return_hash.merge({ regex: nil })) diff --git a/Library/Homebrew/test/livecheck/strategy/xml_spec.rb b/Library/Homebrew/test/livecheck/strategy/xml_spec.rb index 5a1f4dab8814f..5794ae40f1fad 100644 --- a/Library/Homebrew/test/livecheck/strategy/xml_spec.rb +++ b/Library/Homebrew/test/livecheck/strategy/xml_spec.rb @@ -222,7 +222,7 @@ # block here simply to ensure this method works as expected when a # regex isn't provided. 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] } end).to eq(find_versions_cached_return_hash.merge({ regex: nil })) end diff --git a/Library/Homebrew/test/livecheck/strategy/yaml_spec.rb b/Library/Homebrew/test/livecheck/strategy/yaml_spec.rb index 87dcf019d4675..40cb9948389c4 100644 --- a/Library/Homebrew/test/livecheck/strategy/yaml_spec.rb +++ b/Library/Homebrew/test/livecheck/strategy/yaml_spec.rb @@ -131,7 +131,7 @@ # block here simply to ensure this method works as expected when a # regex isn't provided. 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) } .map { |item| item["version"][regex, 1] } end).to eq(find_versions_cached_return_hash.merge({ regex: nil })) diff --git a/Library/Homebrew/utils/curl.rb b/Library/Homebrew/utils/curl.rb index 8973d43d3c4f3..98f6f6ed257a3 100644 --- a/Library/Homebrew/utils/curl.rb +++ b/Library/Homebrew/utils/curl.rb @@ -15,7 +15,7 @@ module Curl # This regex is used to extract the part of an ETag within quotation marks, # ignoring any leading weak validator indicator (`W/`). This simplifies # 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 # `CRLF` (whereas HTTP header lines are separated by a single `CRLF`). @@ -24,7 +24,7 @@ module Curl # 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`). - HTTP_STATUS_LINE_REGEX = %r{^HTTP/.* (?\d+)(?: (?[^\r\n]+))?}.freeze + HTTP_STATUS_LINE_REGEX = %r{^HTTP/.* (?\d+)(?: (?[^\r\n]+))?} private_constant :ETAG_VALUE_REGEX, :HTTP_RESPONSE_BODY_SEPARATOR, :HTTP_STATUS_LINE_REGEX diff --git a/Library/Homebrew/utils/github.rb b/Library/Homebrew/utils/github.rb index 17d2dde3c5415..4fef5cf74af78 100644 --- a/Library/Homebrew/utils/github.rb +++ b/Library/Homebrew/utils/github.rb @@ -509,9 +509,9 @@ def self.get_repo_license(user, repo) end 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 def self.fetch_pull_requests(name, tap_remote_repo, state: nil, version: nil) diff --git a/Library/Homebrew/utils/github/api.rb b/Library/Homebrew/utils/github/api.rb index c7c4309805857..07a38e22f5883 100644 --- a/Library/Homebrew/utils/github/api.rb +++ b/Library/Homebrew/utils/github/api.rb @@ -26,7 +26,7 @@ def self.pat_blurb(scopes = ALL_SCOPES) CREATE_ISSUE_FORK_OR_PR_SCOPES = ["repo"].freeze CREATE_WORKFLOW_SCOPES = ["workflow"].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. # diff --git a/Library/Homebrew/utils/shell.rb b/Library/Homebrew/utils/shell.rb index a00337b6d0779..e7c3de42575b4 100644 --- a/Library/Homebrew/utils/shell.rb +++ b/Library/Homebrew/utils/shell.rb @@ -106,7 +106,7 @@ def prepend_path_in_profile(path) zsh: "~/.zshrc", }.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) } def csh_quote(str) diff --git a/Library/Homebrew/version.rb b/Library/Homebrew/version.rb index 34191d95d749a..80862aca98a6b 100644 --- a/Library/Homebrew/version.rb +++ b/Library/Homebrew/version.rb @@ -139,7 +139,7 @@ def inspect # A token string. class StringToken < Token - PATTERN = /[a-z]+/i.freeze + PATTERN = /[a-z]+/i sig { override.returns(String) } attr_reader :value @@ -164,7 +164,7 @@ def <=>(other) # A token consisting of only numbers. class NumericToken < Token - PATTERN = /[0-9]+/i.freeze + PATTERN = /[0-9]+/i sig { override.returns(Integer) } attr_reader :value @@ -204,7 +204,7 @@ def rev # A token representing the part of a version designating it as an alpha release. 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)) } def <=>(other) @@ -223,7 +223,7 @@ def <=>(other) # A token representing the part of a version designating it as a beta release. 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)) } def <=>(other) @@ -244,7 +244,7 @@ def <=>(other) # A token representing the part of a version designating it as a pre-release. class PreToken < CompositeToken - PATTERN = /pre[0-9]*/i.freeze + PATTERN = /pre[0-9]*/i sig { override.params(other: T.untyped).returns(T.nilable(Integer)) } def <=>(other) @@ -265,7 +265,7 @@ def <=>(other) # A token representing the part of a version designating it as a release candidate. class RCToken < CompositeToken - PATTERN = /rc[0-9]*/i.freeze + PATTERN = /rc[0-9]*/i sig { override.params(other: T.untyped).returns(T.nilable(Integer)) } def <=>(other) @@ -286,7 +286,7 @@ def <=>(other) # A token representing the part of a version designating it as a patch release. class PatchToken < CompositeToken - PATTERN = /p[0-9]*/i.freeze + PATTERN = /p[0-9]*/i sig { override.params(other: T.untyped).returns(T.nilable(Integer)) } def <=>(other) @@ -305,7 +305,7 @@ def <=>(other) # A token representing the part of a version designating it as a post release. class PostToken < CompositeToken - PATTERN = /.post[0-9]+/i.freeze + PATTERN = /.post[0-9]+/i sig { override.params(other: T.untyped).returns(T.nilable(Integer)) } def <=>(other) @@ -503,7 +503,7 @@ def detected_from_url? @detected_from_url end - HEAD_VERSION_REGEX = /\AHEAD(?:-(?.*))?\Z/.freeze + HEAD_VERSION_REGEX = /\AHEAD(?:-(?.*))?\Z/ private_constant :HEAD_VERSION_REGEX # Check if this is a HEAD version. diff --git a/Library/Homebrew/version/parser.rb b/Library/Homebrew/version/parser.rb index d8cf50d9b878e..8c7dd9f561c54 100644 --- a/Library/Homebrew/version/parser.rb +++ b/Library/Homebrew/version/parser.rb @@ -49,8 +49,8 @@ def self.process_spec(spec) # @api private class StemParser < RegexParser - SOURCEFORGE_DOWNLOAD_REGEX = %r{(?:sourceforge\.net|sf\.net)/.*/download$}.freeze - NO_FILE_EXTENSION_REGEX = /\.[^a-zA-Z]+$/.freeze + SOURCEFORGE_DOWNLOAD_REGEX = %r{(?:sourceforge\.net|sf\.net)/.*/download$} + NO_FILE_EXTENSION_REGEX = /\.[^a-zA-Z]+$/ sig { override.params(spec: Pathname).returns(String) } def self.process_spec(spec)