audit: fix code review changes

This commit is contained in:
lionellloh 2020-06-17 22:13:04 +08:00
parent 3bfca5bcee
commit 0b95f030fd
2 changed files with 16 additions and 11 deletions

View File

@ -112,7 +112,9 @@ module Homebrew
style_results = Style.check_style_json(style_files, options) if style_files
# load licenses
full_path = File.join(File.dirname(__FILE__), "../data/spdx.json")
spdx_ids = JSON.parse(File.open(full_path).read)
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

View File

@ -97,8 +97,12 @@ module Homebrew
describe "#audit_license" do
let(:spdx_ids) {
full_path = File.join(File.expand_path(File.dirname(__FILE__) + "../../../data/"), "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" }
@ -157,7 +161,6 @@ 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"