From c0f23acdcd071327f2acaaa1687720940614976c Mon Sep 17 00:00:00 2001 From: Sam Ford <1584702+samford@users.noreply.github.com> Date: Wed, 23 Apr 2025 09:16:38 -0400 Subject: [PATCH] Cask::Auditor: update language_blocks condition I recently modified `Cask::DSL` to define instance variables in the `#initialize` method and this involved some changes to the `language`, `language_eval`, and `languages` methods. One of those was to initialize `@language_blocks` to an empty hash instead of using a `nil` default. I updated the related condition in the `language_eval` method but I missed that `language_blocks` is used in `Cask::Auditor` and it specifically relies on a false-y value to check if the variable is set. An empty hash isn't false-y, so this is causing issues for `brew audit`. This updates the condition in `Cask::Auditor` to check for a non-empty hash instead, which resolves the issue. --- Library/Homebrew/cask/auditor.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Library/Homebrew/cask/auditor.rb b/Library/Homebrew/cask/auditor.rb index 0af5f20860..9fd21f2154 100644 --- a/Library/Homebrew/cask/auditor.rb +++ b/Library/Homebrew/cask/auditor.rb @@ -74,7 +74,7 @@ module Cask def audit errors = Set.new - if !language && (blocks = language_blocks) + if !language && !(blocks = language_blocks).empty? sample_languages = if blocks.length > LANGUAGE_BLOCK_LIMIT && !@audit_new_cask sample_keys = T.must(blocks.keys.sample(LANGUAGE_BLOCK_LIMIT)) ohai "Auditing a sample of available languages for #{cask}: " \ @@ -140,7 +140,7 @@ module Cask audit.run! end - sig { returns(T.nilable(T::Hash[T::Array[String], T.proc.returns(T.untyped)])) } + sig { returns(T::Hash[T::Array[String], T.proc.returns(T.untyped)]) } def language_blocks cask.instance_variable_get(:@dsl).instance_variable_get(:@language_blocks) end