rubocop: fix Lint/NoReturnInBeginEndBlocks
This commit is contained in:
parent
20b8fcd726
commit
500908ee6f
@ -84,9 +84,11 @@ module Homebrew
|
|||||||
formula = begin
|
formula = begin
|
||||||
Formulary.from_rack(HOMEBREW_CELLAR/formula_name)
|
Formulary.from_rack(HOMEBREW_CELLAR/formula_name)
|
||||||
rescue FormulaUnavailableError, TapFormulaAmbiguityError, TapFormulaWithOldnameAmbiguityError
|
rescue FormulaUnavailableError, TapFormulaAmbiguityError, TapFormulaWithOldnameAmbiguityError
|
||||||
return false
|
nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
return false if formula.blank?
|
||||||
|
|
||||||
resource_name = basename.to_s[/\A.*?--(.*?)--?(?:#{Regexp.escape(version)})/, 1]
|
resource_name = basename.to_s[/\A.*?--(.*?)--?(?:#{Regexp.escape(version)})/, 1]
|
||||||
|
|
||||||
if resource_name == "patch"
|
if resource_name == "patch"
|
||||||
@ -113,9 +115,11 @@ module Homebrew
|
|||||||
cask = begin
|
cask = begin
|
||||||
Cask::CaskLoader.load(name)
|
Cask::CaskLoader.load(name)
|
||||||
rescue Cask::CaskError
|
rescue Cask::CaskError
|
||||||
return false
|
nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
return false if cask.blank?
|
||||||
|
|
||||||
return true unless basename.to_s.match?(/\A#{Regexp.escape(name)}--#{Regexp.escape(cask.version)}\b/)
|
return true unless basename.to_s.match?(/\A#{Regexp.escape(name)}--#{Regexp.escape(cask.version)}\b/)
|
||||||
|
|
||||||
return true if scrub && !cask.versions.include?(cask.version)
|
return true if scrub && !cask.versions.include?(cask.version)
|
||||||
|
|||||||
@ -111,15 +111,19 @@ module Homebrew
|
|||||||
new_formula = begin
|
new_formula = begin
|
||||||
Formulary.from_contents(formula_name, formula_path, new_contents, :stable)
|
Formulary.from_contents(formula_name, formula_path, new_contents, :stable)
|
||||||
rescue FormulaUnavailableError
|
rescue FormulaUnavailableError
|
||||||
return "#{formula_name}: delete #{reason}".strip
|
nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
return "#{formula_name}: delete #{reason}".strip if new_formula.blank?
|
||||||
|
|
||||||
old_formula = begin
|
old_formula = begin
|
||||||
Formulary.from_contents(formula_name, formula_path, old_contents, :stable)
|
Formulary.from_contents(formula_name, formula_path, old_contents, :stable)
|
||||||
rescue FormulaUnavailableError
|
rescue FormulaUnavailableError
|
||||||
return "#{formula_name} #{new_formula.stable.version} (new formula)"
|
nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
return "#{formula_name} #{new_formula.stable.version} (new formula)" if old_formula.blank?
|
||||||
|
|
||||||
if old_formula.stable.version != new_formula.stable.version
|
if old_formula.stable.version != new_formula.stable.version
|
||||||
"#{formula_name} #{new_formula.stable.version}"
|
"#{formula_name} #{new_formula.stable.version}"
|
||||||
elsif old_formula.revision != new_formula.revision
|
elsif old_formula.revision != new_formula.revision
|
||||||
|
|||||||
@ -33,9 +33,11 @@ module UnpackStrategy
|
|||||||
system_command! "ditto",
|
system_command! "ditto",
|
||||||
args: ["-x", "-k", path, unpack_dir],
|
args: ["-x", "-k", path, unpack_dir],
|
||||||
verbose: verbose
|
verbose: verbose
|
||||||
return
|
nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
return if result.blank?
|
||||||
|
|
||||||
volumes = result.stderr.chomp
|
volumes = result.stderr.chomp
|
||||||
.split("\n")
|
.split("\n")
|
||||||
.map { |l| l[/\A skipping: (.+) volume label\Z/, 1] }
|
.map { |l| l[/\A skipping: (.+) volume label\Z/, 1] }
|
||||||
|
|||||||
@ -36,9 +36,11 @@ module Utils
|
|||||||
tag_version = begin
|
tag_version = begin
|
||||||
MacOS::Version.from_symbol(tag)
|
MacOS::Version.from_symbol(tag)
|
||||||
rescue MacOSVersionError
|
rescue MacOSVersionError
|
||||||
return
|
nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
return if tag_version.blank?
|
||||||
|
|
||||||
keys.find do |key|
|
keys.find do |key|
|
||||||
MacOS::Version.from_symbol(key) <= tag_version
|
MacOS::Version.from_symbol(key) <= tag_version
|
||||||
rescue MacOSVersionError
|
rescue MacOSVersionError
|
||||||
|
|||||||
@ -139,9 +139,11 @@ module RuboCop
|
|||||||
URI(remove_non_ascii(host))
|
URI(remove_non_ascii(host))
|
||||||
rescue URI::InvalidURIError
|
rescue URI::InvalidURIError
|
||||||
# Can't check if we can't parse.
|
# Can't check if we can't parse.
|
||||||
return true
|
nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
return true if host_uri.blank?
|
||||||
|
|
||||||
host = if host.match?(/:\d/) && host_uri.port != 80
|
host = if host.match?(/:\d/) && host_uri.port != 80
|
||||||
"#{host_uri.host}:#{host_uri.port}"
|
"#{host_uri.host}:#{host_uri.port}"
|
||||||
else
|
else
|
||||||
|
|||||||
@ -50,9 +50,11 @@ module Homebrew
|
|||||||
)
|
)
|
||||||
rescue GitHub::Error => e
|
rescue GitHub::Error => e
|
||||||
opoo "Error searching on GitHub: #{e}\n"
|
opoo "Error searching on GitHub: #{e}\n"
|
||||||
return results
|
nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
return results if matches.blank?
|
||||||
|
|
||||||
matches.each do |match|
|
matches.each do |match|
|
||||||
name = File.basename(match["path"], ".rb")
|
name = File.basename(match["path"], ".rb")
|
||||||
tap = Tap.fetch(match["repository"]["full_name"])
|
tap = Tap.fetch(match["repository"]["full_name"])
|
||||||
|
|||||||
@ -141,43 +141,37 @@ module GitHub
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Given an API response from GitHub, warn the user if their credentials
|
||||||
|
# have insufficient permissions.
|
||||||
def api_credentials_error_message(response_headers, needed_scopes)
|
def api_credentials_error_message(response_headers, needed_scopes)
|
||||||
return if response_headers.empty?
|
return if response_headers.empty?
|
||||||
|
|
||||||
@api_credentials_error_message ||= begin
|
unauthorized = (response_headers["http/1.1"] == "401 Unauthorized")
|
||||||
unauthorized = (response_headers["http/1.1"] == "401 Unauthorized")
|
scopes = response_headers["x-accepted-oauth-scopes"].to_s.split(", ")
|
||||||
scopes = response_headers["x-accepted-oauth-scopes"].to_s.split(", ")
|
return unless unauthorized && scopes.blank?
|
||||||
if unauthorized && scopes.blank?
|
|
||||||
needed_human_scopes = needed_scopes.join(", ")
|
|
||||||
credentials_scopes = response_headers["x-oauth-scopes"]
|
|
||||||
return if needed_human_scopes.blank? && credentials_scopes.blank?
|
|
||||||
|
|
||||||
needed_human_scopes = "none" if needed_human_scopes.blank?
|
needed_human_scopes = needed_scopes.join(", ")
|
||||||
credentials_scopes = "none" if credentials_scopes.blank?
|
credentials_scopes = response_headers["x-oauth-scopes"]
|
||||||
|
return if needed_human_scopes.blank? && credentials_scopes.blank?
|
||||||
|
|
||||||
case GitHub.api_credentials_type
|
needed_human_scopes = "none" if needed_human_scopes.blank?
|
||||||
when :keychain_username_password
|
credentials_scopes = "none" if credentials_scopes.blank?
|
||||||
onoe <<~EOS
|
|
||||||
Your macOS keychain GitHub credentials do not have sufficient scope!
|
what = case GitHub.api_credentials_type
|
||||||
Scopes they need: #{needed_human_scopes}
|
when :keychain_username_password
|
||||||
Scopes they have: #{credentials_scopes}
|
"macOS keychain GitHub"
|
||||||
Create a personal access token:
|
when :env_token
|
||||||
#{ALL_SCOPES_URL}
|
"HOMEBREW_GITHUB_API_TOKEN"
|
||||||
#{Utils::Shell.set_variable_in_profile("HOMEBREW_GITHUB_API_TOKEN", "your_token_here")}
|
|
||||||
EOS
|
|
||||||
when :env_token
|
|
||||||
onoe <<~EOS
|
|
||||||
Your HOMEBREW_GITHUB_API_TOKEN does not have sufficient scope!
|
|
||||||
Scopes it needs: #{needed_human_scopes}
|
|
||||||
Scopes it has: #{credentials_scopes}
|
|
||||||
Create a new personal access token:
|
|
||||||
#{ALL_SCOPES_URL}
|
|
||||||
#{Utils::Shell.set_variable_in_profile("HOMEBREW_GITHUB_API_TOKEN", "your_token_here")}
|
|
||||||
EOS
|
|
||||||
end
|
|
||||||
end
|
|
||||||
true
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@api_credentials_error_message ||= onoe <<~EOS
|
||||||
|
Your #{what} credentials do not have sufficient scope!
|
||||||
|
Scopes required: #{needed_human_scopes}
|
||||||
|
Scopes present: #{credentials_scopes}
|
||||||
|
Create a personal access token:
|
||||||
|
#{ALL_SCOPES_URL}
|
||||||
|
#{Utils::Shell.set_variable_in_profile("HOMEBREW_GITHUB_API_TOKEN", "your_token_here")}
|
||||||
|
EOS
|
||||||
end
|
end
|
||||||
|
|
||||||
def open_api(url, data: nil, data_binary_path: nil, request_method: nil, scopes: [].freeze, parse_json: true)
|
def open_api(url, data: nil, data_binary_path: nil, request_method: nil, scopes: [].freeze, parse_json: true)
|
||||||
|
|||||||
@ -70,28 +70,20 @@ module SharedAudits
|
|||||||
def gitlab_repo_data(user, repo)
|
def gitlab_repo_data(user, repo)
|
||||||
@gitlab_repo_data ||= {}
|
@gitlab_repo_data ||= {}
|
||||||
@gitlab_repo_data["#{user}/#{repo}"] ||= begin
|
@gitlab_repo_data["#{user}/#{repo}"] ||= begin
|
||||||
out, _, status= curl_output("--request", "GET", "https://gitlab.com/api/v4/projects/#{user}%2F#{repo}")
|
out, _, status = curl_output("https://gitlab.com/api/v4/projects/#{user}%2F#{repo}")
|
||||||
return unless status.success?
|
JSON.parse(out) if status.success?
|
||||||
|
|
||||||
JSON.parse(out)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
@gitlab_repo_data["#{user}/#{repo}"]
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def gitlab_release_data(user, repo, tag)
|
def gitlab_release_data(user, repo, tag)
|
||||||
id = "#{user}/#{repo}/#{tag}"
|
id = "#{user}/#{repo}/#{tag}"
|
||||||
@gitlab_release_data ||= {}
|
@gitlab_release_data ||= {}
|
||||||
@gitlab_release_data[id] ||= begin
|
@gitlab_release_data[id] ||= begin
|
||||||
out, _, status= curl_output(
|
out, _, status = curl_output(
|
||||||
"https://gitlab.com/api/v4/projects/#{user}%2F#{repo}/releases/#{tag}", "--fail"
|
"https://gitlab.com/api/v4/projects/#{user}%2F#{repo}/releases/#{tag}", "--fail"
|
||||||
)
|
)
|
||||||
return unless status.success?
|
JSON.parse(out) if status.success?
|
||||||
|
|
||||||
JSON.parse(out)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
@gitlab_release_data[id]
|
|
||||||
end
|
end
|
||||||
|
|
||||||
GITLAB_PRERELEASE_ALLOWLIST = {}.freeze
|
GITLAB_PRERELEASE_ALLOWLIST = {}.freeze
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user