diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 12c6f8444b..1633277162 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -78,7 +78,7 @@ jobs: run: brew style --display-cop-names homebrew/core - name: Run brew audit --skip-style on all taps - run: brew audit --skip-style --display-failures-only + run: brew audit --skip-style --except=version --display-failures-only - name: Set up all Homebrew taps run: | @@ -112,7 +112,7 @@ jobs: HOMEBREW_SIMULATE_MACOS_ON_LINUX: 1 - name: Run brew audit --skip-style on homebrew-core - run: brew audit --skip-style --tap=homebrew/core + run: brew audit --skip-style --except=version --tap=homebrew/core env: HOMEBREW_SIMULATE_MACOS_ON_LINUX: 1 diff --git a/Library/Homebrew/formula_auditor.rb b/Library/Homebrew/formula_auditor.rb index 06b54db3c0..c942c0c97d 100644 --- a/Library/Homebrew/formula_auditor.rb +++ b/Library/Homebrew/formula_auditor.rb @@ -500,7 +500,10 @@ module Homebrew spec_name = name.downcase.to_sym next unless (spec = formula.send(spec_name)) - ra = ResourceAuditor.new(spec, spec_name, online: @online, strict: @strict).audit + ra = ResourceAuditor.new( + spec, spec_name, + online: @online, strict: @strict, only: @only, except: @except + ).audit ra.problems.each do |message| problem "#{name}: #{message}" end @@ -508,7 +511,10 @@ module Homebrew spec.resources.each_value do |resource| problem "Resource name should be different from the formula name" if resource.name == formula.name - ra = ResourceAuditor.new(resource, spec_name, online: @online, strict: @strict).audit + ra = ResourceAuditor.new( + resource, spec_name, + online: @online, strict: @strict, only: @only, except: @except + ).audit ra.problems.each do |message| problem "#{name} resource #{resource.name.inspect}: #{message}" end @@ -746,11 +752,9 @@ module Homebrew methods.map(&:to_s).grep(/^audit_/).each do |audit_method_name| name = audit_method_name.delete_prefix("audit_") - if only_audits - next unless only_audits.include?(name) - elsif except_audits - next if except_audits.include?(name) - end + next if only_audits&.exclude?(name) + next if except_audits&.include?(name) + send(audit_method_name) end end diff --git a/Library/Homebrew/resource_auditor.rb b/Library/Homebrew/resource_auditor.rb index f18652715f..a8b54ee80c 100644 --- a/Library/Homebrew/resource_auditor.rb +++ b/Library/Homebrew/resource_auditor.rb @@ -20,14 +20,23 @@ module Homebrew @spec_name = spec_name @online = options[:online] @strict = options[:strict] + @only = options[:only] + @except = options[:except] @problems = [] end def audit - audit_version - audit_download_strategy - audit_checksum - audit_urls + only_audits = @only + except_audits = @except + + methods.map(&:to_s).grep(/^audit_/).each do |audit_method_name| + name = audit_method_name.delete_prefix("audit_") + next if only_audits&.exclude?(name) + next if except_audits&.include?(name) + + send(audit_method_name) + end + self end