From 5e99ecfbdb0a33fd4cb831232abfd824b5b5ecb7 Mon Sep 17 00:00:00 2001 From: Lionell Loh Jian An Date: Wed, 8 Jul 2020 23:55:48 +0800 Subject: [PATCH] Apply suggestions from code review Code review changes Co-authored-by: Mike McQuaid --- Library/Homebrew/env_config.rb | 2 +- Library/Homebrew/formula_installer.rb | 18 ++++++------------ 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/Library/Homebrew/env_config.rb b/Library/Homebrew/env_config.rb index 7f613779fb..79b6999992 100644 --- a/Library/Homebrew/env_config.rb +++ b/Library/Homebrew/env_config.rb @@ -112,7 +112,7 @@ module Homebrew default: 15, }, HOMEBREW_FORBIDDEN_LICENSES: { - description: "Use this environment variable to define a blacklist of space separated licenses and Homebrew " \ + description: "Use this environment variable to define a denylist of space separated licenses and Homebrew " \ "will avoid installing the packages with those licenses.", }, HOMEBREW_FORCE_BREWED_CURL: { diff --git a/Library/Homebrew/formula_installer.rb b/Library/Homebrew/formula_installer.rb index 83b49c4d40..0a906b3020 100644 --- a/Library/Homebrew/formula_installer.rb +++ b/Library/Homebrew/formula_installer.rb @@ -1106,23 +1106,17 @@ class FormulaInstaller $stderr.puts @requirement_messages end - def env_forbidden_licenses - Homebrew::EnvConfig.forbidden_licenses.split(" ") - end + def forbidden_license_check + forbidden_licenses = Homebrew::EnvConfig.forbidden_licenses.split(" ") + return if forbidden_licenses.blank? - def forbidden_license_check(f) - return if ENV["HOMEBREW_FORBIDDEN_LICENSES"].blank? - - forbidden_licenses = env_forbidden_licenses - - if forbidden_licenses.include? f.license + if forbidden_licenses.include? formula.license raise CannotInstallFormulaError, <<~EOS - #{f.name} has a forbidden license #{f.license}. + #{formula.name} has a forbidden license #{formula.license}. EOS end - fi = FormulaInstaller.new(f) - fi.compute_dependencies.each do |dep, _| + compute_dependencies.each do |dep, _| dep_f = dep.to_formula next unless forbidden_licenses.include? dep_f.license