audit: migrate throttle list to Homebrew/core

This commit is contained in:
Rylan Polster 2020-11-03 13:06:33 -05:00
parent 4a505fce31
commit 869941bccd
3 changed files with 23 additions and 11 deletions

View File

@ -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

View File

@ -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

View File

@ -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