Apply suggestions from code review

license: code review changes

Co-authored-by: Mike McQuaid <mike@mikemcquaid.com>
This commit is contained in:
Lionell Loh Jian An 2020-06-24 18:32:53 +08:00 committed by GitHub
parent 127d67e745
commit 9845091f4d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 14 additions and 19 deletions

View File

@ -13,7 +13,6 @@ gem "rspec-retry", require: false
gem "rspec-wait", require: false
gem "rubocop"
gem "simplecov", require: false
if ENV["HOMEBREW_SORBET"]
gem "sorbet"
gem "sorbet-runtime"

View File

@ -128,7 +128,6 @@ DEPENDENCIES
byebug
concurrent-ruby
coveralls (~> 0.8)
json
mechanize
parallel_tests
plist

View File

@ -111,21 +111,19 @@ 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
full_path = File.join(File.dirname(__FILE__), "../data/spdx.json")
spdx_data = File.open(full_path, "r") do |file|
JSON.parse(file.read)
end
spdx = HOMEBREW_LIBRARY_PATH/"data/spdx.json"
JSON.parse(spdx.read)
new_formula_problem_lines = []
audit_formulae.sort.each do |f|
only = only_cops ? ["style"] : args.only
options = {
new_formula: new_formula,
strict: strict,
online: online,
git: git,
only: only,
except: args.except,
spdx_data: spdx_data,
new_formula: new_formula,
strict: strict,
online: online,
git: git,
only: only,
except: args.except,
spdx_data: spdx_data,
}
options[:style_offenses] = style_results.file_offenses(f.path) if style_results
options[:display_cop_names] = args.display_cop_names?
@ -350,7 +348,7 @@ module Homebrew
def audit_license
if formula.license.present?
if @spdx_data["licenses"].any?{|lic| lic["licenseId"] == formula.license}
if @spdx_data["licenses"].any? { |lic| lic["licenseId"] == formula.license }
return unless @online
user, repo = get_repo_data(%r{https?://github\.com/([^/]+)/([^/]+)/?.*})
@ -360,9 +358,9 @@ module Homebrew
return if github_license && (github_license == formula.license)
problem "License mismatch - GitHub license is: #{github_license}, "\
"but Formulae license states: #{formula.license}."
"but formula license states: #{formula.license}."
else
problem "#{formula.license} is not a standard SPDX license."
problem "#{formula.license} is not a SPDX license."
end
elsif @new_formula
problem "No license specified for package."

View File

@ -49,7 +49,6 @@ module Homebrew
description: "Explicitly set the <license> of the new formula."
flag "--tap=",
description: "Generate the new formula within the given tap, specified as <user>`/`<repo>."
switch :force
switch :verbose
switch :debug

View File

@ -19,7 +19,7 @@ module Homebrew
Update SPDX license data in the Homebrew repository.
EOS
switch "--fail-if-outdated",
switch "--fail-if-changed",
description: "Return a failing status code if current license data's version is different from the upstream. This "\
"can be used to notify CI when the SPDX license data is out of date."

View File

@ -2207,7 +2207,7 @@ class Formula
# The SPDX ID of the open-source license that the formula uses.
# Shows when running `brew info`.
#
# <pre>license " BSD-2-Clause"</pre>
# <pre>license "BSD-2-Clause"</pre>
attr_rw :license
# @!attribute [w] homepage