diff --git a/Library/Homebrew/dev-cmd/spdx.json b/Library/Homebrew/data/spdx.json similarity index 100% rename from Library/Homebrew/dev-cmd/spdx.json rename to Library/Homebrew/data/spdx.json diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb index cebaa0766d..002c9d637d 100644 --- a/Library/Homebrew/dev-cmd/audit.rb +++ b/Library/Homebrew/dev-cmd/audit.rb @@ -111,8 +111,10 @@ module Homebrew # Check style in a single batch run up front for performance style_results = Style.check_style_json(style_files, options) if style_files # load licenses - path = File.join(File.dirname(__FILE__), "spdx.json") - spdx_ids = JSON.parse(File.open(File.expand_path(path)).read) + full_path = File.join(File.dirname(__FILE__), "../data/spdx.json") + spdx_ids = File.open(full_path, "r") do |f| + JSON.parse(f.read) + end new_formula_problem_lines = [] audit_formulae.sort.each do |f| only = only_cops ? ["style"] : args.only @@ -347,7 +349,7 @@ module Homebrew ].freeze def audit_license - if ! formula.license.blank? + if !formula.license.blank? if @spdx_ids.key?(formula.license) return unless @online diff --git a/Library/Homebrew/test/dev-cmd/audit_spec.rb b/Library/Homebrew/test/dev-cmd/audit_spec.rb index 09ca81f4f1..215d711845 100644 --- a/Library/Homebrew/test/dev-cmd/audit_spec.rb +++ b/Library/Homebrew/test/dev-cmd/audit_spec.rb @@ -97,8 +97,12 @@ module Homebrew describe "#audit_license" do let(:spdx_ids) { - full_path = File.join(File.expand_path(File.dirname(__FILE__) + "../../../dev-cmd/"), "spdx.json") - JSON.parse(File.open(full_path).read) + # full_path = File.join(File.expand_path(File.dirname(__FILE__) + "../../../data/"), "spdx.json") + full_path = File.join(File.dirname(__FILE__), "../../data/spdx.json") + p full_path + File.open(full_path, "r") do |f| + JSON.parse(f.read) + end } let(:custom_spdx_id) { "zzz" } @@ -145,9 +149,9 @@ module Homebrew "as what is indicated on its Github repo" do fa = formula_auditor "cask", <<~RUBY, spdx_ids: spdx_ids, online: true, core_tap: true class Cask < Formula - url "https://github.com/cask/cask/archive/v0.8.4.tar.gz" - head "https://github.com/cask/cask.git" - license "GPL-3.0" + url "https://github.com/cask/cask/archive/v0.8.4.tar.gz" + head "https://github.com/cask/cask.git" + license "GPL-3.0" end RUBY @@ -157,12 +161,11 @@ module Homebrew it "checks online and detects that a formula-specified license is not "\ "the same as what is indicated on its Github repository" do - # odie "lol" fa = formula_auditor "cask", <<~RUBY, online: true, spdx_ids: spdx_ids, core_tap: true class Cask < Formula - url "https://github.com/cask/cask/archive/v0.8.4.tar.gz" - head "https://github.com/cask/cask.git" - license "#{standard_mismatch_spdx_id}" + url "https://github.com/cask/cask/archive/v0.8.4.tar.gz" + head "https://github.com/cask/cask.git" + license "#{standard_mismatch_spdx_id}" end RUBY