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 1/2] 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 From 4917fb2c93a9b91c65ba5246a44fb72811b0a6f2 Mon Sep 17 00:00:00 2001 From: Sam Ford <1584702+samford@users.noreply.github.com> Date: Wed, 23 Apr 2025 09:34:08 -0400 Subject: [PATCH 2/2] Cask::DSL: Remove duplicate token definition I inadvertently duplicated the `@token` instance variable definition in `Cask::DSL#initiailize`, so this removes the duplicate. This didn't have any noticeable effect because it was redefined afterward, so this is just a bit of tidying up. --- Library/Homebrew/cask/dsl.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/Library/Homebrew/cask/dsl.rb b/Library/Homebrew/cask/dsl.rb index 684df3cb74..cf9f3ee108 100644 --- a/Library/Homebrew/cask/dsl.rb +++ b/Library/Homebrew/cask/dsl.rb @@ -149,7 +149,6 @@ module Cask @name = T.let([], T::Array[String]) @on_system_blocks_exist = T.let(false, T::Boolean) @os = T.let(nil, T.nilable(String)) - @token = cask.token @on_system_block_min_os = T.let(nil, T.nilable(MacOSVersion)) @sha256 = T.let(nil, T.nilable(T.any(Checksum, Symbol))) @staged_path = T.let(nil, T.nilable(Pathname))