From 869941bccd84e762f0e12764648a256cb7e2eb1d Mon Sep 17 00:00:00 2001 From: Rylan Polster Date: Tue, 3 Nov 2020 13:06:33 -0500 Subject: [PATCH] audit: migrate throttle list to Homebrew/core --- Library/Homebrew/dev-cmd/audit.rb | 13 +++---------- Library/Homebrew/tap.rb | 20 ++++++++++++++++++++ Library/Homebrew/test/dev-cmd/audit_spec.rb | 1 - 3 files changed, 23 insertions(+), 11 deletions(-) diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb index cae8d1618b..4568fc39c9 100644 --- a/Library/Homebrew/dev-cmd/audit.rb +++ b/Library/Homebrew/dev-cmd/audit.rb @@ -135,6 +135,7 @@ module Homebrew except: args.except, spdx_license_data: spdx_license_data, spdx_exception_data: spdx_exception_data, + audit_exceptions: f.tap.audit_exceptions, } options[:style_offenses] = style_offenses.for_path(f.path) if style_offenses options[:display_cop_names] = args.display_cop_names? @@ -247,6 +248,7 @@ module Homebrew @specs = %w[stable head].map { |s| formula.send(s) }.compact @spdx_license_data = options[:spdx_license_data] @spdx_exception_data = options[:spdx_exception_data] + @audit_exceptions = options[:audit_exceptions] end def audit_style @@ -730,15 +732,6 @@ module Homebrew imagemagick@6 ].freeze - THROTTLED_FORMULAE = { - "aws-sdk-cpp" => 10, - "awscli@1" => 10, - "balena-cli" => 10, - "gatsby-cli" => 10, - "quicktype" => 10, - "vim" => 50, - }.freeze - UNSTABLE_ALLOWLIST = { "aalib" => "1.4rc", "automysqlbackup" => "3.0-rc", @@ -823,7 +816,7 @@ module Homebrew stable_url_minor_version = stable_url_version.minor.to_i formula_suffix = stable.version.patch.to_i - throttled_rate = THROTTLED_FORMULAE[formula.name] + throttled_rate = @audit_exceptions["THROTTLED_FORMULAE"][formula.name] if throttled_rate && formula_suffix.modulo(throttled_rate).nonzero? problem "should only be updated every #{throttled_rate} releases on multiples of #{throttled_rate}" end diff --git a/Library/Homebrew/tap.rb b/Library/Homebrew/tap.rb index 8c6fb892d7..c3df28cc1f 100644 --- a/Library/Homebrew/tap.rb +++ b/Library/Homebrew/tap.rb @@ -99,6 +99,7 @@ class Tap @command_files = nil @formula_renames = nil @tap_migrations = nil + @audit_exceptions = nil @config = nil remove_instance_variable(:@private) if instance_variable_defined?(:@private) end @@ -545,6 +546,17 @@ class Tap end end + # Hash with audit exceptions + def audit_exceptions + require "json" + + @audit_exceptions ||= if (audit_exceptions_file = path/"audit_exceptions.json").file? + JSON.parse(audit_exceptions_file.read) + else + {} + end + end + def ==(other) other = Tap.fetch(other) if other.is_a?(String) self.class == other.class && name == other.name @@ -689,6 +701,14 @@ class CoreTap < Tap end end + # @private + def audit_exceptions + @audit_exceptions ||= begin + self.class.ensure_installed! + super + end + end + # @private def formula_file_to_name(file) file.basename(".rb").to_s diff --git a/Library/Homebrew/test/dev-cmd/audit_spec.rb b/Library/Homebrew/test/dev-cmd/audit_spec.rb index 315066bc5c..13b6e14792 100644 --- a/Library/Homebrew/test/dev-cmd/audit_spec.rb +++ b/Library/Homebrew/test/dev-cmd/audit_spec.rb @@ -870,7 +870,6 @@ module Homebrew include_examples "formulae exist", described_class::VERSIONED_KEG_ONLY_ALLOWLIST include_examples "formulae exist", described_class::VERSIONED_HEAD_SPEC_ALLOWLIST include_examples "formulae exist", described_class::PROVIDED_BY_MACOS_DEPENDS_ON_ALLOWLIST - include_examples "formulae exist", described_class::THROTTLED_FORMULAE.keys include_examples "formulae exist", described_class::UNSTABLE_ALLOWLIST.keys include_examples "formulae exist", described_class::GNOME_DEVEL_ALLOWLIST.keys end