Modify code to load spdx data once
This commit is contained in:
parent
998ab162d4
commit
ff1016b729
@ -110,7 +110,9 @@ module Homebrew
|
|||||||
|
|
||||||
# Check style in a single batch run up front for performance
|
# Check style in a single batch run up front for performance
|
||||||
style_results = Style.check_style_json(style_files, options) if style_files
|
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.load( File.open(File.expand_path(path)))
|
||||||
new_formula_problem_lines = []
|
new_formula_problem_lines = []
|
||||||
audit_formulae.sort.each do |f|
|
audit_formulae.sort.each do |f|
|
||||||
only = only_cops ? ["style"] : args.only
|
only = only_cops ? ["style"] : args.only
|
||||||
@ -121,6 +123,7 @@ module Homebrew
|
|||||||
git: git,
|
git: git,
|
||||||
only: only,
|
only: only,
|
||||||
except: args.except,
|
except: args.except,
|
||||||
|
spdx_ids: spdx_ids
|
||||||
}
|
}
|
||||||
options[:style_offenses] = style_results.file_offenses(f.path) if style_results
|
options[:style_offenses] = style_results.file_offenses(f.path) if style_results
|
||||||
options[:display_cop_names] = args.display_cop_names?
|
options[:display_cop_names] = args.display_cop_names?
|
||||||
@ -224,6 +227,7 @@ module Homebrew
|
|||||||
@new_formula_problems = []
|
@new_formula_problems = []
|
||||||
@text = FormulaText.new(formula.path)
|
@text = FormulaText.new(formula.path)
|
||||||
@specs = %w[stable devel head].map { |s| formula.send(s) }.compact
|
@specs = %w[stable devel head].map { |s| formula.send(s) }.compact
|
||||||
|
@spdx_ids = options[:spdx_ids]
|
||||||
end
|
end
|
||||||
|
|
||||||
def audit_style
|
def audit_style
|
||||||
@ -343,11 +347,8 @@ module Homebrew
|
|||||||
].freeze
|
].freeze
|
||||||
|
|
||||||
def audit_licenses
|
def audit_licenses
|
||||||
path = File.join(File.dirname(__FILE__),"spdx.json")
|
|
||||||
file = File.open(File.expand_path(path))
|
|
||||||
valid_licenses = JSON.load(file)
|
|
||||||
unless formula.license.nil?
|
unless formula.license.nil?
|
||||||
if valid_licenses.key?(formula.license)
|
if @spdx_ids.key?(formula.license)
|
||||||
return unless @online
|
return unless @online
|
||||||
user, repo = get_repo_data(%r{https?://github\.com/([^/]+)/([^/]+)/?.*}, false)
|
user, repo = get_repo_data(%r{https?://github\.com/([^/]+)/([^/]+)/?.*}, false)
|
||||||
return if user.nil?
|
return if user.nil?
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user