From 88eae0633b1bdbdead23bbf638267f53c6c0be9c Mon Sep 17 00:00:00 2001 From: lionellloh Date: Thu, 9 Jul 2020 13:01:10 +0800 Subject: [PATCH 01/16] overwrote license attr_rw with a special license method --- Library/Homebrew/formula.rb | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb index c1e1fc8f0d..6cf72c71a8 100644 --- a/Library/Homebrew/formula.rb +++ b/Library/Homebrew/formula.rb @@ -1682,7 +1682,7 @@ class Formula "aliases" => aliases.sort, "versioned_formulae" => versioned_formulae.map(&:name), "desc" => desc, - "license" => license, + "license" => license.class == String ? [license] : license, "homepage" => homepage, "versions" => { "stable" => stable&.version&.to_s, @@ -2210,7 +2210,17 @@ class Formula # Shows when running `brew info`. # #
license "BSD-2-Clause"
- attr_rw :license + def license args=nil + if args.blank? + return @licenses + else + @licenses = args.class == String ? [args] : args + puts @licenses + # license. + end + end + + # attr_rw :license # @!attribute [w] homepage # The homepage for the software. Used by users to get more information From 3d27894015962a780dc3624ea6284eb303824bef Mon Sep 17 00:00:00 2001 From: Lionell Loh Jian An Date: Sun, 12 Jul 2020 11:12:10 +0800 Subject: [PATCH 02/16] Apply suggestions from code review Code review changes Co-authored-by: Mike McQuaid --- Library/Homebrew/formula.rb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb index 6cf72c71a8..f29013b75f 100644 --- a/Library/Homebrew/formula.rb +++ b/Library/Homebrew/formula.rb @@ -2208,13 +2208,15 @@ class Formula # @!attribute [w] # The SPDX ID of the open-source license that the formula uses. # Shows when running `brew info`. + # Multiple licenses means that the software is licensed under multiple licenses. + # Do not use multiple licenses if e.g. different parts are under different licenses. # #
license "BSD-2-Clause"
- def license args=nil - if args.blank? + def license(args = nil) + if args.nil? return @licenses else - @licenses = args.class == String ? [args] : args + @licenses = Array(args) puts @licenses # license. end From 9a2f84d4a553b79e5f08e7c440a3d2108033a946 Mon Sep 17 00:00:00 2001 From: lionellloh Date: Sun, 12 Jul 2020 11:18:02 +0800 Subject: [PATCH 03/16] Modify to_hash output --- Library/Homebrew/formula.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb index f29013b75f..38896711bf 100644 --- a/Library/Homebrew/formula.rb +++ b/Library/Homebrew/formula.rb @@ -1682,7 +1682,7 @@ class Formula "aliases" => aliases.sort, "versioned_formulae" => versioned_formulae.map(&:name), "desc" => desc, - "license" => license.class == String ? [license] : license, + "license" => license, "homepage" => homepage, "versions" => { "stable" => stable&.version&.to_s, From b91587d1716636b345f13e6829e04ab3a684d5ed Mon Sep 17 00:00:00 2001 From: lionellloh Date: Sun, 12 Jul 2020 11:40:02 +0800 Subject: [PATCH 04/16] audit-license: adapt code to use Array of licenses --- Library/Homebrew/dev-cmd/audit.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb index 2b17297200..4655594847 100644 --- a/Library/Homebrew/dev-cmd/audit.rb +++ b/Library/Homebrew/dev-cmd/audit.rb @@ -330,16 +330,16 @@ module Homebrew def audit_license if formula.license.present? - if @spdx_data["licenses"].any? { |lic| lic["licenseId"] == formula.license } + if formula.license.any? { |lic| @spdx_data["licenses"].any? { |standard_lic| standard_lic["licenseId"] == lic } } return unless @online user, repo = get_repo_data(%r{https?://github\.com/([^/]+)/([^/]+)/?.*}) if @new_formula return if user.blank? github_license = GitHub.get_repo_license(user, repo) - return if github_license && [formula.license, "NOASSERTION"].include?(github_license) + return if github_license && (formula.license + ["NOASSERTION"]).include?(github_license) - problem "License mismatch - GitHub license is: #{github_license}, "\ + problem "License mismatch - GitHub license is: #{Array(github_license)}, "\ "but Formulae license states: #{formula.license}." else problem "#{formula.license} is not a standard SPDX license." From 557b1d09a2c228a38d9c0792e5685541d0b8a6cc Mon Sep 17 00:00:00 2001 From: lionellloh Date: Sun, 12 Jul 2020 12:35:27 +0800 Subject: [PATCH 05/16] correct logic for standard license checking --- Library/Homebrew/dev-cmd/audit.rb | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb index 4655594847..961f64d3d1 100644 --- a/Library/Homebrew/dev-cmd/audit.rb +++ b/Library/Homebrew/dev-cmd/audit.rb @@ -330,7 +330,16 @@ module Homebrew def audit_license if formula.license.present? - if formula.license.any? { |lic| @spdx_data["licenses"].any? { |standard_lic| standard_lic["licenseId"] == lic } } + non_standard_licenses = [] + formula.license.each do |lic| + next if @spdx_data["licenses"].any? { |standard_lic| standard_lic["licenseId"] == lic } + non_standard_licenses << lic + end + + if non_standard_licenses.present? + problem "Formula #{formula.name} contains non standard SPDX license: #{non_standard_licenses} " + end + return unless @online user, repo = get_repo_data(%r{https?://github\.com/([^/]+)/([^/]+)/?.*}) if @new_formula @@ -341,9 +350,8 @@ module Homebrew problem "License mismatch - GitHub license is: #{Array(github_license)}, "\ "but Formulae license states: #{formula.license}." - else - problem "#{formula.license} is not a standard SPDX license." - end + + elsif @new_formula problem "No license specified for package." end From 14d18a97319348dd2b457c7b279522c19a75c21e Mon Sep 17 00:00:00 2001 From: lionellloh Date: Sun, 12 Jul 2020 12:50:50 +0800 Subject: [PATCH 06/16] Forbidden license logic adapt to Array --- Library/Homebrew/formula_installer.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Library/Homebrew/formula_installer.rb b/Library/Homebrew/formula_installer.rb index 5ac720ebee..30a572c617 100644 --- a/Library/Homebrew/formula_installer.rb +++ b/Library/Homebrew/formula_installer.rb @@ -1123,18 +1123,18 @@ class FormulaInstaller next if @ignore_deps dep_f = dep.to_formula - next unless forbidden_licenses.include? dep_f.license + next unless dep_f.license.all?{ |lic| forbidden_licenses.include? lic } raise CannotInstallFormulaError, <<~EOS - The installation of #{formula.name} has a dependency on #{dep.name} with a forbidden license #{dep_f.license}. + The installation of #{formula.name} has a dependency on #{dep.name} where all its licenses are forbidden: #{dep_f.license}. EOS end return if @only_deps - return unless forbidden_licenses.include? formula.license + return unless formula.license.all? { |lic| forbidden_licenses.include? lic } raise CannotInstallFormulaError, <<~EOS - #{formula.name} has a forbidden license #{formula.license}. + #{formula.name}'s licenses are all forbidden: #{formula.license}. EOS end end From 797a07d55503388d2ea1e70c2f0ae922138aac31 Mon Sep 17 00:00:00 2001 From: lionellloh Date: Sun, 12 Jul 2020 13:18:30 +0800 Subject: [PATCH 07/16] All tests adapted to pass --- Library/Homebrew/dev-cmd/audit.rb | 2 +- Library/Homebrew/formula.rb | 2 +- Library/Homebrew/test/dev-cmd/audit_spec.rb | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb index 961f64d3d1..176aae7720 100644 --- a/Library/Homebrew/dev-cmd/audit.rb +++ b/Library/Homebrew/dev-cmd/audit.rb @@ -337,7 +337,7 @@ module Homebrew end if non_standard_licenses.present? - problem "Formula #{formula.name} contains non standard SPDX license: #{non_standard_licenses} " + problem "Formula #{formula.name} contains non standard SPDX license: #{non_standard_licenses}." end return unless @online diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb index 38896711bf..4cb64c7add 100644 --- a/Library/Homebrew/formula.rb +++ b/Library/Homebrew/formula.rb @@ -2216,7 +2216,7 @@ class Formula if args.nil? return @licenses else - @licenses = Array(args) + @licenses = Array(args) unless args == "" puts @licenses # license. end diff --git a/Library/Homebrew/test/dev-cmd/audit_spec.rb b/Library/Homebrew/test/dev-cmd/audit_spec.rb index 9c78bde60f..368550c320 100644 --- a/Library/Homebrew/test/dev-cmd/audit_spec.rb +++ b/Library/Homebrew/test/dev-cmd/audit_spec.rb @@ -120,7 +120,7 @@ module Homebrew RUBY fa.audit_license - expect(fa.problems.first).to match "#{custom_spdx_id} is not a standard SPDX license." + expect(fa.problems.first).to match "Formula foo contains non standard SPDX license: [\"zzz\"]." end it "verifies that a license info is a standard spdx id" do @@ -160,8 +160,8 @@ module Homebrew RUBY fa.audit_license - expect(fa.problems.first).to match "License mismatch - GitHub license is: GPL-3.0, "\ - "but Formulae license states: #{standard_mismatch_spdx_id}." + expect(fa.problems.first).to match "License mismatch - GitHub license is: [\"GPL-3.0\"], "\ + "but Formulae license states: #{Array(standard_mismatch_spdx_id)}." end end From 3982810eab1d04a98d811180608553074883f274 Mon Sep 17 00:00:00 2001 From: lionellloh Date: Sun, 12 Jul 2020 13:21:42 +0800 Subject: [PATCH 08/16] brew style --fix --- Library/Homebrew/dev-cmd/audit.rb | 16 ++++++++-------- Library/Homebrew/formula.rb | 4 ++-- Library/Homebrew/formula_installer.rb | 2 +- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb index 176aae7720..c90a229f74 100644 --- a/Library/Homebrew/dev-cmd/audit.rb +++ b/Library/Homebrew/dev-cmd/audit.rb @@ -333,6 +333,7 @@ module Homebrew non_standard_licenses = [] formula.license.each do |lic| next if @spdx_data["licenses"].any? { |standard_lic| standard_lic["licenseId"] == lic } + non_standard_licenses << lic end @@ -340,17 +341,16 @@ module Homebrew problem "Formula #{formula.name} contains non standard SPDX license: #{non_standard_licenses}." end - return unless @online + return unless @online - user, repo = get_repo_data(%r{https?://github\.com/([^/]+)/([^/]+)/?.*}) if @new_formula - return if user.blank? + user, repo = get_repo_data(%r{https?://github\.com/([^/]+)/([^/]+)/?.*}) if @new_formula + return if user.blank? - github_license = GitHub.get_repo_license(user, repo) - return if github_license && (formula.license + ["NOASSERTION"]).include?(github_license) - - problem "License mismatch - GitHub license is: #{Array(github_license)}, "\ - "but Formulae license states: #{formula.license}." + github_license = GitHub.get_repo_license(user, repo) + return if github_license && (formula.license + ["NOASSERTION"]).include?(github_license) + problem "License mismatch - GitHub license is: #{Array(github_license)}, "\ + "but Formulae license states: #{formula.license}." elsif @new_formula problem "No license specified for package." diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb index 4cb64c7add..fc790ab329 100644 --- a/Library/Homebrew/formula.rb +++ b/Library/Homebrew/formula.rb @@ -2214,11 +2214,11 @@ class Formula #
license "BSD-2-Clause"
def license(args = nil) if args.nil? - return @licenses + @licenses else @licenses = Array(args) unless args == "" puts @licenses - # license. + # license. end end diff --git a/Library/Homebrew/formula_installer.rb b/Library/Homebrew/formula_installer.rb index 30a572c617..7d7938a8fb 100644 --- a/Library/Homebrew/formula_installer.rb +++ b/Library/Homebrew/formula_installer.rb @@ -1123,7 +1123,7 @@ class FormulaInstaller next if @ignore_deps dep_f = dep.to_formula - next unless dep_f.license.all?{ |lic| forbidden_licenses.include? lic } + next unless dep_f.license.all? { |lic| forbidden_licenses.include? lic } raise CannotInstallFormulaError, <<~EOS The installation of #{formula.name} has a dependency on #{dep.name} where all its licenses are forbidden: #{dep_f.license}. From 4ff3d63978bd30aa898e53641d5fdbb93ab2e63f Mon Sep 17 00:00:00 2001 From: lionellloh Date: Sun, 12 Jul 2020 13:24:51 +0800 Subject: [PATCH 09/16] Clean up --- Library/Homebrew/formula.rb | 5 ----- 1 file changed, 5 deletions(-) diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb index fc790ab329..bd87da7562 100644 --- a/Library/Homebrew/formula.rb +++ b/Library/Homebrew/formula.rb @@ -2210,20 +2210,15 @@ class Formula # Shows when running `brew info`. # Multiple licenses means that the software is licensed under multiple licenses. # Do not use multiple licenses if e.g. different parts are under different licenses. - # #
license "BSD-2-Clause"
def license(args = nil) if args.nil? @licenses else @licenses = Array(args) unless args == "" - puts @licenses - # license. end end - # attr_rw :license - # @!attribute [w] homepage # The homepage for the software. Used by users to get more information # about the software and Homebrew maintainers as a point of contact for From 4a14ae6589c7a7aa111ecac4ce70deccc9c86b1b Mon Sep 17 00:00:00 2001 From: lionellloh Date: Fri, 24 Jul 2020 00:10:47 +0800 Subject: [PATCH 10/16] Audit-license: more tests to ensure behaviour --- Library/Homebrew/test/dev-cmd/audit_spec.rb | 56 +++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/Library/Homebrew/test/dev-cmd/audit_spec.rb b/Library/Homebrew/test/dev-cmd/audit_spec.rb index 368550c320..3f28b0bb4c 100644 --- a/Library/Homebrew/test/dev-cmd/audit_spec.rb +++ b/Library/Homebrew/test/dev-cmd/audit_spec.rb @@ -86,6 +86,9 @@ module Homebrew let(:custom_spdx_id) { "zzz" } let(:standard_mismatch_spdx_id) { "0BSD" } + let(:license_array) { ["0BSD", "GPL-3.0"] } + let(:license_array_mismatch) { ["0BSD", "MIT"] } + let(:license_array_nonstandard) { ["0BSD", "zzz", "MIT"] } it "does not check if the formula is not a new formula" do fa = formula_auditor "foo", <<~RUBY, spdx_data: spdx_data, new_formula: false @@ -123,6 +126,18 @@ module Homebrew expect(fa.problems.first).to match "Formula foo contains non standard SPDX license: [\"zzz\"]." end + it "detects if license array contains a non-standard spdx-id" do + fa = formula_auditor "foo", <<~RUBY, spdx_data: spdx_data, new_formula: true + class Foo < Formula + url "https://brew.sh/foo-1.0.tgz" + license "#{custom_spdx_id}" + end + RUBY + + fa.audit_license + expect(fa.problems.first).to match "Formula foo contains non standard SPDX license: [\"zzz\"]." + end + it "verifies that a license info is a standard spdx id" do fa = formula_auditor "foo", <<~RUBY, spdx_data: spdx_data, new_formula: true class Foo < Formula @@ -135,6 +150,18 @@ module Homebrew expect(fa.problems).to be_empty end + it "verifies that a license array contains only standard spdx id" do + fa = formula_auditor "foo", <<~RUBY, spdx_data: spdx_data, new_formula: true + class Foo < Formula + url "https://brew.sh/foo-1.0.tgz" + license #{license_array} + end + RUBY + + fa.audit_license + expect(fa.problems).to be_empty + end + it "checks online and verifies that a standard license id is the same "\ "as what is indicated on its Github repo" do fa = formula_auditor "cask", <<~RUBY, spdx_data: spdx_data, online: true, core_tap: true, new_formula: true @@ -163,6 +190,35 @@ module Homebrew expect(fa.problems.first).to match "License mismatch - GitHub license is: [\"GPL-3.0\"], "\ "but Formulae license states: #{Array(standard_mismatch_spdx_id)}." end + + it "checks online and detects that an array of license does not contain "\ + "what is indicated on its Github repository" do + fa = formula_auditor "cask", <<~RUBY, online: true, spdx_data: spdx_data, core_tap: true, new_formula: true + class Cask < Formula + url "https://github.com/cask/cask/archive/v0.8.4.tar.gz" + head "https://github.com/cask/cask.git" + license #{license_array_mismatch} + end + RUBY + + fa.audit_license + expect(fa.problems.first).to match "License mismatch - GitHub license is: [\"GPL-3.0\"], "\ + "but Formulae license states: #{Array(license_array_mismatch)}." + end + + it "checks online and verifies that an array of license contains "\ + "what is indicated on its Github repository" do + fa = formula_auditor "cask", <<~RUBY, online: true, spdx_data: spdx_data, core_tap: true, new_formula: true + class Cask < Formula + url "https://github.com/cask/cask/archive/v0.8.4.tar.gz" + head "https://github.com/cask/cask.git" + license #{license_array} + end + RUBY + + fa.audit_license + expect(fa.problems).to be_empty + end end describe "#audit_file" do From 721c9b06cdc5b7acaea022d200a9bb5b88cd4874 Mon Sep 17 00:00:00 2001 From: Lionell Date: Fri, 24 Jul 2020 21:50:59 +0800 Subject: [PATCH 11/16] audit-license: Small change to use license_array --- Library/Homebrew/test/dev-cmd/audit_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Library/Homebrew/test/dev-cmd/audit_spec.rb b/Library/Homebrew/test/dev-cmd/audit_spec.rb index 3f28b0bb4c..0d1c2097f1 100644 --- a/Library/Homebrew/test/dev-cmd/audit_spec.rb +++ b/Library/Homebrew/test/dev-cmd/audit_spec.rb @@ -130,7 +130,7 @@ module Homebrew fa = formula_auditor "foo", <<~RUBY, spdx_data: spdx_data, new_formula: true class Foo < Formula url "https://brew.sh/foo-1.0.tgz" - license "#{custom_spdx_id}" + license "#{license_array}" end RUBY From 52321b4fcdf4bea64ca5c57e0171a5d36f37085f Mon Sep 17 00:00:00 2001 From: Lionell Loh Jian An Date: Sat, 25 Jul 2020 21:39:29 +0800 Subject: [PATCH 12/16] Apply suggestions from code review Code review changes Co-authored-by: Mike McQuaid --- Library/Homebrew/dev-cmd/audit.rb | 8 ++++---- Library/Homebrew/formula.rb | 2 +- Library/Homebrew/formula_installer.rb | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb index c90a229f74..b97a79fbc9 100644 --- a/Library/Homebrew/dev-cmd/audit.rb +++ b/Library/Homebrew/dev-cmd/audit.rb @@ -331,14 +331,14 @@ module Homebrew def audit_license if formula.license.present? non_standard_licenses = [] - formula.license.each do |lic| - next if @spdx_data["licenses"].any? { |standard_lic| standard_lic["licenseId"] == lic } + formula.license.each do |license| + next if @spdx_data["licenses"].any? { |spdx| spdx["licenseId"] == license } - non_standard_licenses << lic + non_standard_licenses << license end if non_standard_licenses.present? - problem "Formula #{formula.name} contains non standard SPDX license: #{non_standard_licenses}." + problem "Formula #{formula.name} contains non-standard SPDX licenses: #{non_standard_licenses}." end return unless @online diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb index bd87da7562..ab4734cf57 100644 --- a/Library/Homebrew/formula.rb +++ b/Library/Homebrew/formula.rb @@ -2215,7 +2215,7 @@ class Formula if args.nil? @licenses else - @licenses = Array(args) unless args == "" + @licenses = Array(args) end end diff --git a/Library/Homebrew/formula_installer.rb b/Library/Homebrew/formula_installer.rb index 7d7938a8fb..a288fa5f3e 100644 --- a/Library/Homebrew/formula_installer.rb +++ b/Library/Homebrew/formula_installer.rb @@ -1131,7 +1131,7 @@ class FormulaInstaller end return if @only_deps - return unless formula.license.all? { |lic| forbidden_licenses.include? lic } + return unless formula.license.all? { |license| forbidden_licenses.include? license } raise CannotInstallFormulaError, <<~EOS #{formula.name}'s licenses are all forbidden: #{formula.license}. From 0d6ea9e26c17b4776f7707db19ff1eae12456b39 Mon Sep 17 00:00:00 2001 From: Lionell Date: Sat, 25 Jul 2020 22:49:57 +0800 Subject: [PATCH 13/16] Updated tests to pass --- Library/Homebrew/test/dev-cmd/audit_spec.rb | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/Library/Homebrew/test/dev-cmd/audit_spec.rb b/Library/Homebrew/test/dev-cmd/audit_spec.rb index 0d1c2097f1..87c65925b3 100644 --- a/Library/Homebrew/test/dev-cmd/audit_spec.rb +++ b/Library/Homebrew/test/dev-cmd/audit_spec.rb @@ -94,7 +94,6 @@ module Homebrew fa = formula_auditor "foo", <<~RUBY, spdx_data: spdx_data, new_formula: false class Foo < Formula url "https://brew.sh/foo-1.0.tgz" - license "" end RUBY @@ -106,7 +105,6 @@ module Homebrew fa = formula_auditor "foo", <<~RUBY, spdx_data: spdx_data, new_formula: true class Foo < Formula url "https://brew.sh/foo-1.0.tgz" - license "" end RUBY @@ -123,19 +121,19 @@ module Homebrew RUBY fa.audit_license - expect(fa.problems.first).to match "Formula foo contains non standard SPDX license: [\"zzz\"]." + expect(fa.problems.first).to match "Formula foo contains non-standard SPDX licenses: [\"zzz\"]." end it "detects if license array contains a non-standard spdx-id" do fa = formula_auditor "foo", <<~RUBY, spdx_data: spdx_data, new_formula: true class Foo < Formula url "https://brew.sh/foo-1.0.tgz" - license "#{license_array}" + license #{license_array_nonstandard} end RUBY fa.audit_license - expect(fa.problems.first).to match "Formula foo contains non standard SPDX license: [\"zzz\"]." + expect(fa.problems.first).to match "Formula foo contains non-standard SPDX licenses: [\"zzz\"]." end it "verifies that a license info is a standard spdx id" do From 26c786fc0a99c758c54a3fcd5075acd97985c689 Mon Sep 17 00:00:00 2001 From: lionellloh Date: Tue, 28 Jul 2020 20:57:39 +0800 Subject: [PATCH 14/16] double quotes to single quotes --- Library/Homebrew/test/dev-cmd/audit_spec.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Library/Homebrew/test/dev-cmd/audit_spec.rb b/Library/Homebrew/test/dev-cmd/audit_spec.rb index 87c65925b3..c91fee04ef 100644 --- a/Library/Homebrew/test/dev-cmd/audit_spec.rb +++ b/Library/Homebrew/test/dev-cmd/audit_spec.rb @@ -86,9 +86,9 @@ module Homebrew let(:custom_spdx_id) { "zzz" } let(:standard_mismatch_spdx_id) { "0BSD" } - let(:license_array) { ["0BSD", "GPL-3.0"] } - let(:license_array_mismatch) { ["0BSD", "MIT"] } - let(:license_array_nonstandard) { ["0BSD", "zzz", "MIT"] } + let(:license_array) { ['0BSD', 'GPL-3.0'] } + let(:license_array_mismatch) { ['0BSD', 'MIT'] } + let(:license_array_nonstandard) { ['0BSD', 'zzz', 'MIT'] } it "does not check if the formula is not a new formula" do fa = formula_auditor "foo", <<~RUBY, spdx_data: spdx_data, new_formula: false From 67a974455be98319deb2f384750c98e19f9d0571 Mon Sep 17 00:00:00 2001 From: Lionell Loh Jian An Date: Tue, 28 Jul 2020 21:01:09 +0800 Subject: [PATCH 15/16] Apply suggestions from code review Co-authored-by: Mike McQuaid --- Library/Homebrew/formula_installer.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Library/Homebrew/formula_installer.rb b/Library/Homebrew/formula_installer.rb index a288fa5f3e..c07d59b976 100644 --- a/Library/Homebrew/formula_installer.rb +++ b/Library/Homebrew/formula_installer.rb @@ -1123,7 +1123,7 @@ class FormulaInstaller next if @ignore_deps dep_f = dep.to_formula - next unless dep_f.license.all? { |lic| forbidden_licenses.include? lic } + next unless dep_f.license.all? { |license| forbidden_licenses.include? license } raise CannotInstallFormulaError, <<~EOS The installation of #{formula.name} has a dependency on #{dep.name} where all its licenses are forbidden: #{dep_f.license}. From 4f45ddd55b4ed56366b116f8e682055e18793f3c Mon Sep 17 00:00:00 2001 From: lionellloh Date: Tue, 28 Jul 2020 21:04:45 +0800 Subject: [PATCH 16/16] brew style --fix --- Library/Homebrew/test/dev-cmd/audit_spec.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Library/Homebrew/test/dev-cmd/audit_spec.rb b/Library/Homebrew/test/dev-cmd/audit_spec.rb index c91fee04ef..87c65925b3 100644 --- a/Library/Homebrew/test/dev-cmd/audit_spec.rb +++ b/Library/Homebrew/test/dev-cmd/audit_spec.rb @@ -86,9 +86,9 @@ module Homebrew let(:custom_spdx_id) { "zzz" } let(:standard_mismatch_spdx_id) { "0BSD" } - let(:license_array) { ['0BSD', 'GPL-3.0'] } - let(:license_array_mismatch) { ['0BSD', 'MIT'] } - let(:license_array_nonstandard) { ['0BSD', 'zzz', 'MIT'] } + let(:license_array) { ["0BSD", "GPL-3.0"] } + let(:license_array_mismatch) { ["0BSD", "MIT"] } + let(:license_array_nonstandard) { ["0BSD", "zzz", "MIT"] } it "does not check if the formula is not a new formula" do fa = formula_auditor "foo", <<~RUBY, spdx_data: spdx_data, new_formula: false