From caf8259ae62d5b9c54b5a59f134ed2cbd5ecbe42 Mon Sep 17 00:00:00 2001 From: Douglas Eichelberger Date: Wed, 27 Dec 2023 15:29:33 -0800 Subject: [PATCH] Code review changes --- Library/Homebrew/cask/audit.rb | 2 +- Library/Homebrew/dev-cmd/bottle.rb | 2 +- Library/Homebrew/formula_text_auditor.rb | 4 ++-- Library/Homebrew/keg_relocate.rb | 2 +- Library/Homebrew/livecheck/strategy/git.rb | 2 +- Library/Homebrew/rubocops/extend/formula_cop.rb | 2 +- Library/Homebrew/test/cask/audit_spec.rb | 2 +- Library/Homebrew/utils/curl.rb | 2 +- 8 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Library/Homebrew/cask/audit.rb b/Library/Homebrew/cask/audit.rb index 0974f12bf0..67ae10e22c 100644 --- a/Library/Homebrew/cask/audit.rb +++ b/Library/Homebrew/cask/audit.rb @@ -843,7 +843,7 @@ module Cask def bad_url_format?(regex, valid_formats_array) return false unless cask.url.to_s.match?(regex) - valid_formats_array.none? { |format| cask.url.to_s&.match?(format) } + valid_formats_array.none? { |format| cask.url.to_s.match?(format) } end sig { returns(T::Boolean) } diff --git a/Library/Homebrew/dev-cmd/bottle.rb b/Library/Homebrew/dev-cmd/bottle.rb index 453b9df8ea..6a51a21e1e 100644 --- a/Library/Homebrew/dev-cmd/bottle.rb +++ b/Library/Homebrew/dev-cmd/bottle.rb @@ -294,7 +294,7 @@ module Homebrew # Ignore matches to go keg, because all go binaries are statically linked. any_go_deps = formula.deps.any? do |dep| - dep.name&.match?(Version.formula_optionally_versioned_regex(:go)) + Version.formula_optionally_versioned_regex(:go).match?(dep.name) end if any_go_deps go_regex = Version.formula_optionally_versioned_regex(:go, full: false) diff --git a/Library/Homebrew/formula_text_auditor.rb b/Library/Homebrew/formula_text_auditor.rb index 31569ff333..495fa87015 100644 --- a/Library/Homebrew/formula_text_auditor.rb +++ b/Library/Homebrew/formula_text_auditor.rb @@ -32,12 +32,12 @@ module Homebrew end def line_number(regex, skip = 0) - index = @lines.drop(skip).index { |line| line&.match?(regex) } + index = @lines.drop(skip).index { |line| line.match?(regex) } index ? index + 1 : nil end def reverse_line_number(regex) - index = @lines.reverse.index { |line| line&.match?(regex) } + index = @lines.reverse.index { |line| line.match?(regex) } index ? @lines.count - index : nil end end diff --git a/Library/Homebrew/keg_relocate.rb b/Library/Homebrew/keg_relocate.rb index dec59b5daf..7173c27a74 100644 --- a/Library/Homebrew/keg_relocate.rb +++ b/Library/Homebrew/keg_relocate.rb @@ -328,7 +328,7 @@ class Keg Utils.popen_read("strings", "-t", "x", "-", file.to_s) do |io| until io.eof? str = io.readline.chomp - next if ignores.any? { |i| i&.match?(str) } + next if ignores.any? { |i| str.match?(i) } next unless str.match? path_regex offset, match = str.split(" ", 2) diff --git a/Library/Homebrew/livecheck/strategy/git.rb b/Library/Homebrew/livecheck/strategy/git.rb index 393e600dbf..ed669b39f0 100644 --- a/Library/Homebrew/livecheck/strategy/git.rb +++ b/Library/Homebrew/livecheck/strategy/git.rb @@ -66,7 +66,7 @@ module Homebrew # Isolate tag strings and filter by regex tags = stdout.gsub(%r{^.*\trefs/tags/|\^{}$}, "").split("\n").uniq.sort - tags.select! { |t| t&.match?(regex) } if regex + tags.select! { |t| regex.match?(t) } if regex tags_data[:tags] = tags tags_data diff --git a/Library/Homebrew/rubocops/extend/formula_cop.rb b/Library/Homebrew/rubocops/extend/formula_cop.rb index 04e81333e7..6cfaa7b9f6 100644 --- a/Library/Homebrew/rubocops/extend/formula_cop.rb +++ b/Library/Homebrew/rubocops/extend/formula_cop.rb @@ -233,7 +233,7 @@ module RuboCop paths_to_exclude = [%r{/Library/Homebrew/test/}] return true if @file_path.nil? # file_path is nil when source is directly passed to the cop, e.g. in specs - !@file_path&.match?(Regexp.union(paths_to_exclude)) + !@file_path.match?(Regexp.union(paths_to_exclude)) end def on_system_methods diff --git a/Library/Homebrew/test/cask/audit_spec.rb b/Library/Homebrew/test/cask/audit_spec.rb index df5bc8f6b0..af6d944420 100644 --- a/Library/Homebrew/test/cask/audit_spec.rb +++ b/Library/Homebrew/test/cask/audit_spec.rb @@ -5,7 +5,7 @@ require "cask/audit" describe Cask::Audit, :cask do def include_msg?(problems, msg) if msg.is_a?(Regexp) - Array(problems).any? { |problem| problem[:message]&.match?(msg) } + Array(problems).any? { |problem| msg.match?(problem[:message]) } else Array(problems).any? { |problem| problem[:message] == msg } end diff --git a/Library/Homebrew/utils/curl.rb b/Library/Homebrew/utils/curl.rb index efc9bcbf1e..8973d43d3c 100644 --- a/Library/Homebrew/utils/curl.rb +++ b/Library/Homebrew/utils/curl.rb @@ -335,7 +335,7 @@ module Utils # Strategy: # If the `:homepage` 404s, it's a GitHub link, and we have a token then # check the API (which does use tokens) for the repository - repo_details = url.match?(%r{https?://github\.com/(?[^/]+)/(?[^/]+)/?.*}) + repo_details = url.match(%r{https?://github\.com/(?[^/]+)/(?[^/]+)/?.*}) check_github_api = url_type == SharedAudits::URL_TYPE_HOMEPAGE && details[:status_code] == "404" && repo_details &&