audit: fix callers to call get_repo_data only if @new_formula

This commit is contained in:
lionellloh 2020-06-25 05:09:56 +08:00
parent 221fd4f7c6
commit 3f267a8fc9

View File

@ -112,7 +112,9 @@ module Homebrew
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 # load licenses
spdx = HOMEBREW_LIBRARY_PATH/"data/spdx.json" spdx = HOMEBREW_LIBRARY_PATH/"data/spdx.json"
JSON.parse(spdx.read) spdx_data = open(spdx, "r") do |file|
JSON.parse(file.read)
end
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
@ -351,7 +353,9 @@ module Homebrew
if @spdx_data["licenses"].any? { |lic| lic["licenseId"] == formula.license } if @spdx_data["licenses"].any? { |lic| lic["licenseId"] == formula.license }
return unless @online return unless @online
user, repo = get_repo_data(%r{https?://github\.com/([^/]+)/([^/]+)/?.*}) user, repo = get_repo_data(%r{https?://github\.com/([^/]+)/([^/]+)/?.*}) if @new_formula
user ||= nil
repo ||= nil
return if user.nil? return if user.nil?
github_license = GitHub.get_repo_license(user, repo) github_license = GitHub.get_repo_license(user, repo)
@ -542,7 +546,9 @@ module Homebrew
end end
def audit_github_repository def audit_github_repository
user, repo = get_repo_data(%r{https?://github\.com/([^/]+)/([^/]+)/?.*}) user, repo = get_repo_data(%r{https?://github\.com/([^/]+)/([^/]+)/?.*}) if @new_formula
user ||=nil
repo ||=nil
return if user.nil? return if user.nil?
warning = SharedAudits.github(user, repo) warning = SharedAudits.github(user, repo)
@ -552,7 +558,9 @@ module Homebrew
end end
def audit_gitlab_repository def audit_gitlab_repository
user, repo = get_repo_data(%r{https?://gitlab\.com/([^/]+)/([^/]+)/?.*}) user, repo = get_repo_data(%r{https?://gitlab\.com/([^/]+)/([^/]+)/?.*}) if @new_formula
user ||= nil
repo ||=nil
return if user.nil? return if user.nil?
warning = SharedAudits.gitlab(user, repo) warning = SharedAudits.gitlab(user, repo)
@ -562,7 +570,9 @@ module Homebrew
end end
def audit_bitbucket_repository def audit_bitbucket_repository
user, repo = get_repo_data(%r{https?://bitbucket\.org/([^/]+)/([^/]+)/?.*}) user, repo = get_repo_data(%r{https?://bitbucket\.org/([^/]+)/([^/]+)/?.*}) if @new_formula
user ||= nil
repo ||= nil
return if user.nil? return if user.nil?
warning = SharedAudits.bitbucket(user, repo) warning = SharedAudits.bitbucket(user, repo)