From d84246c36c592461bc836d7c63a534e1fdfc9ce8 Mon Sep 17 00:00:00 2001 From: Ryan Rotter Date: Sat, 29 Jun 2024 00:19:31 -0400 Subject: [PATCH] Apply suggestions from code review Co-authored-by: Mike McQuaid --- Library/Homebrew/descriptions.rb | 7 ++++--- Library/Homebrew/search.rb | 4 ++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/Library/Homebrew/descriptions.rb b/Library/Homebrew/descriptions.rb index 7785cffc7b2230..967c0d7c22010b 100644 --- a/Library/Homebrew/descriptions.rb +++ b/Library/Homebrew/descriptions.rb @@ -8,9 +8,10 @@ # Helper class for printing and searching descriptions. class Descriptions # Given a regex, find all formulae whose specified fields contain a match. - def self.search(string_or_regex, field, cache_store, eval_all = Homebrew::EnvConfig.eval_all?) - # allow searching a simple hash, not only cache_store objects - cache_store.populate_if_empty!(eval_all:) if cache_store.methods.include?(:populate_if_empty!) + def self.search(string_or_regex, field, cache_store, + eval_all = Homebrew::EnvConfig.eval_all?, cache_store_hash: false) + + cache_store.populate_if_empty!(eval_all:) unless cache_store_hash results = case field when :name diff --git a/Library/Homebrew/search.rb b/Library/Homebrew/search.rb index 058dfb1931f334..63c53e5b528fc6 100644 --- a/Library/Homebrew/search.rb +++ b/Library/Homebrew/search.rb @@ -29,7 +29,7 @@ def self.search_descriptions(string_or_regex, args, search_type: :desc) end else descriptions = Homebrew::API::Formula.all_formulae.transform_values { |data| data["desc"] } - Descriptions.search(string_or_regex, search_type, descriptions, eval_all).print + Descriptions.search(string_or_regex, search_type, descriptions, eval_all, cache_store_hash: true).print end end return if !args.cask? && !both @@ -44,7 +44,7 @@ def self.search_descriptions(string_or_regex, args, search_type: :desc) end else descriptions = Homebrew::API::Cask.all_casks.transform_values { |data| data["desc"] } - Descriptions.search(string_or_regex, search_type, descriptions, eval_all).print + Descriptions.search(string_or_regex, search_type, descriptions, eval_all, cache_store_hash: true).print end end