Merge pull request #3876 from MikeMcQuaid/homebrew-rubocop-upgrade
RuboCop 0.53.0
This commit is contained in:
commit
74443999f4
@ -26,6 +26,9 @@ Layout/CaseIndentation:
|
|||||||
Layout/EmptyLineBetweenDefs:
|
Layout/EmptyLineBetweenDefs:
|
||||||
AllowAdjacentOneLineDefs: true
|
AllowAdjacentOneLineDefs: true
|
||||||
|
|
||||||
|
Layout/EndAlignment:
|
||||||
|
EnforcedStyleAlignWith: variable
|
||||||
|
|
||||||
Layout/IndentArray:
|
Layout/IndentArray:
|
||||||
EnforcedStyle: special_inside_parentheses
|
EnforcedStyle: special_inside_parentheses
|
||||||
|
|
||||||
@ -52,9 +55,6 @@ Lint/AmbiguousBlockAssociation:
|
|||||||
Lint/AssignmentInCondition:
|
Lint/AssignmentInCondition:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
|
|
||||||
Lint/EndAlignment:
|
|
||||||
EnforcedStyleAlignWith: variable
|
|
||||||
|
|
||||||
# so many of these in formulae and can't be autocorrected
|
# so many of these in formulae and can't be autocorrected
|
||||||
Lint/ParenthesesAsGroupedExpression:
|
Lint/ParenthesesAsGroupedExpression:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
@ -205,7 +205,10 @@ Style/TernaryParentheses:
|
|||||||
EnforcedStyle: require_parentheses_when_complex
|
EnforcedStyle: require_parentheses_when_complex
|
||||||
|
|
||||||
# makes diffs nicer
|
# makes diffs nicer
|
||||||
Style/TrailingCommaInLiteral:
|
Style/TrailingCommaInArrayLiteral:
|
||||||
|
EnforcedStyleForMultiline: comma
|
||||||
|
|
||||||
|
Style/TrailingCommaInHashLiteral:
|
||||||
EnforcedStyleForMultiline: comma
|
EnforcedStyleForMultiline: comma
|
||||||
|
|
||||||
Style/TrailingCommaInArguments:
|
Style/TrailingCommaInArguments:
|
||||||
@ -215,6 +218,10 @@ Style/TrailingCommaInArguments:
|
|||||||
Naming/VariableNumber:
|
Naming/VariableNumber:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
|
|
||||||
|
# doesn't make sense for Homebrew/brew but does for taps
|
||||||
|
Naming/UncommunicativeMethodParamName:
|
||||||
|
Enabled: true
|
||||||
|
|
||||||
Style/WordArray:
|
Style/WordArray:
|
||||||
MinSize: 4
|
MinSize: 4
|
||||||
|
|
||||||
|
|||||||
@ -68,6 +68,10 @@ Naming/PredicateName:
|
|||||||
- 'compat/**/*'
|
- 'compat/**/*'
|
||||||
NameWhitelist: is_32_bit?, is_64_bit?
|
NameWhitelist: is_32_bit?, is_64_bit?
|
||||||
|
|
||||||
|
# f meaning formulae is pretty standard
|
||||||
|
Naming/UncommunicativeMethodParamName:
|
||||||
|
Enabled: false
|
||||||
|
|
||||||
Style/BlockDelimiters:
|
Style/BlockDelimiters:
|
||||||
Exclude:
|
Exclude:
|
||||||
- '**/*_spec.rb'
|
- '**/*_spec.rb'
|
||||||
|
|||||||
@ -1,3 +1,5 @@
|
|||||||
|
require "uri"
|
||||||
|
|
||||||
module Hbc
|
module Hbc
|
||||||
module CaskLoader
|
module CaskLoader
|
||||||
class FromContentLoader
|
class FromContentLoader
|
||||||
|
|||||||
@ -113,14 +113,14 @@ module Homebrew
|
|||||||
url = "https://api.github.com/gists"
|
url = "https://api.github.com/gists"
|
||||||
data = { "public" => true, "files" => files, "description" => description }
|
data = { "public" => true, "files" => files, "description" => description }
|
||||||
scopes = GitHub::CREATE_GIST_SCOPES
|
scopes = GitHub::CREATE_GIST_SCOPES
|
||||||
GitHub.open(url, data: data, scopes: scopes)["html_url"]
|
GitHub.open_api(url, data: data, scopes: scopes)["html_url"]
|
||||||
end
|
end
|
||||||
|
|
||||||
def create_issue(repo, title, body)
|
def create_issue(repo, title, body)
|
||||||
url = "https://api.github.com/repos/#{repo}/issues"
|
url = "https://api.github.com/repos/#{repo}/issues"
|
||||||
data = { "title" => title, "body" => body }
|
data = { "title" => title, "body" => body }
|
||||||
scopes = GitHub::CREATE_ISSUE_SCOPES
|
scopes = GitHub::CREATE_ISSUE_SCOPES
|
||||||
GitHub.open(url, data: data, scopes: scopes)["html_url"]
|
GitHub.open_api(url, data: data, scopes: scopes)["html_url"]
|
||||||
end
|
end
|
||||||
|
|
||||||
def gist_logs
|
def gist_logs
|
||||||
|
|||||||
@ -344,7 +344,7 @@ module Homebrew
|
|||||||
rescue FormulaInstallationAlreadyAttemptedError
|
rescue FormulaInstallationAlreadyAttemptedError
|
||||||
# We already attempted to install f as part of the dependency tree of
|
# We already attempted to install f as part of the dependency tree of
|
||||||
# another formula. In that case, don't generate an error, just move on.
|
# another formula. In that case, don't generate an error, just move on.
|
||||||
return
|
nil
|
||||||
rescue CannotInstallFormulaError => e
|
rescue CannotInstallFormulaError => e
|
||||||
ofail e.message
|
ofail e.message
|
||||||
end
|
end
|
||||||
|
|||||||
@ -47,7 +47,7 @@ module Homebrew
|
|||||||
fi.install
|
fi.install
|
||||||
fi.finish
|
fi.finish
|
||||||
rescue FormulaInstallationAlreadyAttemptedError
|
rescue FormulaInstallationAlreadyAttemptedError
|
||||||
return
|
nil
|
||||||
rescue Exception # rubocop:disable Lint/RescueException
|
rescue Exception # rubocop:disable Lint/RescueException
|
||||||
ignore_interrupts { restore_backup(keg, keg_was_linked) }
|
ignore_interrupts { restore_backup(keg, keg_was_linked) }
|
||||||
raise
|
raise
|
||||||
|
|||||||
@ -13,7 +13,7 @@ module Homebrew
|
|||||||
module_function
|
module_function
|
||||||
|
|
||||||
def update_preinstall_header
|
def update_preinstall_header
|
||||||
@header_already_printed ||= begin
|
@update_preinstall_header ||= begin
|
||||||
ohai "Auto-updated Homebrew!" if ARGV.include?("--preinstall")
|
ohai "Auto-updated Homebrew!" if ARGV.include?("--preinstall")
|
||||||
true
|
true
|
||||||
end
|
end
|
||||||
|
|||||||
@ -139,7 +139,7 @@ module Homebrew
|
|||||||
rescue FormulaInstallationAlreadyAttemptedError
|
rescue FormulaInstallationAlreadyAttemptedError
|
||||||
# We already attempted to upgrade f as part of the dependency tree of
|
# We already attempted to upgrade f as part of the dependency tree of
|
||||||
# another formula. In that case, don't generate an error, just move on.
|
# another formula. In that case, don't generate an error, just move on.
|
||||||
return
|
nil
|
||||||
rescue CannotInstallFormulaError => e
|
rescue CannotInstallFormulaError => e
|
||||||
ofail e
|
ofail e
|
||||||
rescue BuildError => e
|
rescue BuildError => e
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# RuboCop version used for `brew style` and `brew cask style`
|
# RuboCop version used for `brew style` and `brew cask style`
|
||||||
HOMEBREW_RUBOCOP_VERSION = "0.52.1"
|
HOMEBREW_RUBOCOP_VERSION = "0.53.0"
|
||||||
HOMEBREW_RUBOCOP_CASK_VERSION = "~> 0.16.0" # has to be updated when RuboCop version changes
|
HOMEBREW_RUBOCOP_CASK_VERSION = "~> 0.17.0" # has to be updated when RuboCop version changes
|
||||||
|
|||||||
@ -966,7 +966,7 @@ module Homebrew
|
|||||||
Putting non-prefixed coreutils in your path can cause gmp builds to fail.
|
Putting non-prefixed coreutils in your path can cause gmp builds to fail.
|
||||||
EOS
|
EOS
|
||||||
rescue FormulaUnavailableError
|
rescue FormulaUnavailableError
|
||||||
return
|
nil
|
||||||
end
|
end
|
||||||
|
|
||||||
def check_for_non_prefixed_findutils
|
def check_for_non_prefixed_findutils
|
||||||
@ -981,7 +981,7 @@ module Homebrew
|
|||||||
Putting non-prefixed findutils in your path can cause python builds to fail.
|
Putting non-prefixed findutils in your path can cause python builds to fail.
|
||||||
EOS
|
EOS
|
||||||
rescue FormulaUnavailableError
|
rescue FormulaUnavailableError
|
||||||
return
|
nil
|
||||||
end
|
end
|
||||||
|
|
||||||
def check_for_pydistutils_cfg_in_home
|
def check_for_pydistutils_cfg_in_home
|
||||||
|
|||||||
@ -604,7 +604,7 @@ class GitHubPrivateRepositoryReleaseDownloadStrategy < GitHubPrivateRepositoryDo
|
|||||||
|
|
||||||
def fetch_release_metadata
|
def fetch_release_metadata
|
||||||
release_url = "https://api.github.com/repos/#{@owner}/#{@repo}/releases/tags/#{@tag}"
|
release_url = "https://api.github.com/repos/#{@owner}/#{@repo}/releases/tags/#{@tag}"
|
||||||
GitHub.open(release_url)
|
GitHub.open_api(release_url)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -31,7 +31,7 @@ class SystemConfig
|
|||||||
return "N/A" unless CoreTap.instance.installed?
|
return "N/A" unless CoreTap.instance.installed?
|
||||||
Formulary.factory(formula).linked_version || "N/A"
|
Formulary.factory(formula).linked_version || "N/A"
|
||||||
rescue FormulaUnavailableError
|
rescue FormulaUnavailableError
|
||||||
return "N/A"
|
"N/A"
|
||||||
end
|
end
|
||||||
|
|
||||||
def dump_verbose_config(out = $stdout)
|
def dump_verbose_config(out = $stdout)
|
||||||
|
|||||||
@ -44,7 +44,7 @@ class FormulaVersions
|
|||||||
# continue walking the history
|
# continue walking the history
|
||||||
ohai "#{e} in #{name} at revision #{rev}", e.backtrace if ARGV.debug?
|
ohai "#{e} in #{name} at revision #{rev}", e.backtrace if ARGV.debug?
|
||||||
rescue FormulaUnavailableError
|
rescue FormulaUnavailableError
|
||||||
return
|
nil
|
||||||
ensure
|
ensure
|
||||||
Homebrew.raise_deprecation_exceptions = false
|
Homebrew.raise_deprecation_exceptions = false
|
||||||
end
|
end
|
||||||
|
|||||||
@ -4,6 +4,8 @@ require_relative "../../extend/string"
|
|||||||
module RuboCop
|
module RuboCop
|
||||||
module Cop
|
module Cop
|
||||||
class FormulaCop < Cop
|
class FormulaCop < Cop
|
||||||
|
include RangeHelp
|
||||||
|
|
||||||
attr_accessor :file_path
|
attr_accessor :file_path
|
||||||
@registry = Cop.registry
|
@registry = Cop.registry
|
||||||
|
|
||||||
|
|||||||
@ -108,10 +108,10 @@ class Sandbox
|
|||||||
|
|
||||||
unless logs.empty?
|
unless logs.empty?
|
||||||
if @logfile
|
if @logfile
|
||||||
log = open(@logfile, "w")
|
File.open(@logfile, "w") do |log|
|
||||||
log.write logs
|
log.write logs
|
||||||
log.write "\nWe use time to filter sandbox log. Therefore, unrelated logs may be recorded.\n"
|
log.write "\nWe use time to filter sandbox log. Therefore, unrelated logs may be recorded.\n"
|
||||||
log.close
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if @failed && ARGV.verbose?
|
if @failed && ARGV.verbose?
|
||||||
|
|||||||
@ -326,8 +326,8 @@ class Tab < OpenStruct
|
|||||||
"time" => time,
|
"time" => time,
|
||||||
"source_modified_time" => source_modified_time.to_i,
|
"source_modified_time" => source_modified_time.to_i,
|
||||||
"HEAD" => self.HEAD,
|
"HEAD" => self.HEAD,
|
||||||
"stdlib" => (stdlib.to_s if stdlib),
|
"stdlib" => (stdlib&.to_s),
|
||||||
"compiler" => (compiler.to_s if compiler),
|
"compiler" => (compiler&.to_s),
|
||||||
"aliases" => aliases,
|
"aliases" => aliases,
|
||||||
"runtime_dependencies" => runtime_dependencies,
|
"runtime_dependencies" => runtime_dependencies,
|
||||||
"source" => source,
|
"source" => source,
|
||||||
|
|||||||
@ -36,9 +36,9 @@ GEM
|
|||||||
rspec-support (3.7.1)
|
rspec-support (3.7.1)
|
||||||
rspec-wait (0.0.9)
|
rspec-wait (0.0.9)
|
||||||
rspec (>= 3, < 4)
|
rspec (>= 3, < 4)
|
||||||
rubocop (0.52.1)
|
rubocop (0.53.0)
|
||||||
parallel (~> 1.10)
|
parallel (~> 1.10)
|
||||||
parser (>= 2.4.0.2, < 3.0)
|
parser (>= 2.5)
|
||||||
powerpack (~> 0.1)
|
powerpack (~> 0.1)
|
||||||
rainbow (>= 2.2.2, < 4.0)
|
rainbow (>= 2.2.2, < 4.0)
|
||||||
ruby-progressbar (~> 1.7)
|
ruby-progressbar (~> 1.7)
|
||||||
@ -62,7 +62,7 @@ DEPENDENCIES
|
|||||||
rspec-its
|
rspec-its
|
||||||
rspec-retry
|
rspec-retry
|
||||||
rspec-wait
|
rspec-wait
|
||||||
rubocop (= 0.52.1)
|
rubocop (= 0.53.0)
|
||||||
simplecov
|
simplecov
|
||||||
|
|
||||||
BUNDLED WITH
|
BUNDLED WITH
|
||||||
|
|||||||
@ -16,7 +16,7 @@ describe Homebrew do
|
|||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
|
||||||
allow(GitHub).to receive(:open).and_yield(json_response)
|
allow(GitHub).to receive(:open_api).and_yield(json_response)
|
||||||
|
|
||||||
expect(described_class.search_taps("some-formula"))
|
expect(described_class.search_taps("some-formula"))
|
||||||
.to match(["homebrew/foo/some-formula"])
|
.to match(["homebrew/foo/some-formula"])
|
||||||
|
|||||||
@ -116,7 +116,7 @@ describe GitHubPrivateRepositoryReleaseDownloadStrategy do
|
|||||||
describe "#fetch_release_metadata" do
|
describe "#fetch_release_metadata" do
|
||||||
it "fetches release metadata from GitHub" do
|
it "fetches release metadata from GitHub" do
|
||||||
expected_release_url = "https://api.github.com/repos/owner/repo/releases/tags/tag"
|
expected_release_url = "https://api.github.com/repos/owner/repo/releases/tags/tag"
|
||||||
expect(GitHub).to receive(:open).with(expected_release_url).and_return({})
|
expect(GitHub).to receive(:open_api).with(expected_release_url).and_return({})
|
||||||
subject.send(:fetch_release_metadata)
|
subject.send(:fetch_release_metadata)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -16,9 +16,9 @@ TEST_TMPDIR = ENV.fetch("HOMEBREW_TEST_TMPDIR") do |k|
|
|||||||
end
|
end
|
||||||
|
|
||||||
# Paths pointing into the Homebrew code base that persist across test runs
|
# Paths pointing into the Homebrew code base that persist across test runs
|
||||||
HOMEBREW_LIBRARY_PATH = Pathname.new(File.expand_path("../../../..", __FILE__))
|
HOMEBREW_LIBRARY_PATH = Pathname.new(File.expand_path("../../..", __dir__))
|
||||||
HOMEBREW_SHIMS_PATH = HOMEBREW_LIBRARY_PATH.parent+"Homebrew/shims"
|
HOMEBREW_SHIMS_PATH = HOMEBREW_LIBRARY_PATH.parent+"Homebrew/shims"
|
||||||
HOMEBREW_LOAD_PATH = [File.expand_path("..", __FILE__), HOMEBREW_LIBRARY_PATH].join(":")
|
HOMEBREW_LOAD_PATH = [File.expand_path(__dir__), HOMEBREW_LIBRARY_PATH].join(":")
|
||||||
|
|
||||||
# Paths redirected to a temporary directory and wiped at the end of the test run
|
# Paths redirected to a temporary directory and wiped at the end of the test run
|
||||||
HOMEBREW_PREFIX = Pathname.new(TEST_TMPDIR).join("prefix")
|
HOMEBREW_PREFIX = Pathname.new(TEST_TMPDIR).join("prefix")
|
||||||
|
|||||||
@ -3,9 +3,9 @@ require "formula_installer"
|
|||||||
|
|
||||||
describe Utils::Analytics do
|
describe Utils::Analytics do
|
||||||
describe "::os_prefix_ci" do
|
describe "::os_prefix_ci" do
|
||||||
context "when anonymous_os_prefix_ci is not set" do
|
context "when os_prefix_ci is not set" do
|
||||||
before(:each) do
|
before(:each) do
|
||||||
described_class.clear_anonymous_os_prefix_ci_cache
|
described_class.clear_os_prefix_ci
|
||||||
end
|
end
|
||||||
|
|
||||||
it "returns OS_VERSION and prefix when HOMEBREW_PREFIX is not /usr/local" do
|
it "returns OS_VERSION and prefix when HOMEBREW_PREFIX is not /usr/local" do
|
||||||
|
|||||||
@ -3,13 +3,13 @@ require "erb"
|
|||||||
module Utils
|
module Utils
|
||||||
module Analytics
|
module Analytics
|
||||||
class << self
|
class << self
|
||||||
def clear_anonymous_os_prefix_ci_cache
|
def clear_os_prefix_ci
|
||||||
return unless instance_variable_defined?(:@anonymous_os_prefix_ci)
|
return unless instance_variable_defined?(:@os_prefix_ci)
|
||||||
remove_instance_variable(:@anonymous_os_prefix_ci)
|
remove_instance_variable(:@os_prefix_ci)
|
||||||
end
|
end
|
||||||
|
|
||||||
def os_prefix_ci
|
def os_prefix_ci
|
||||||
@anonymous_os_prefix_ci ||= begin
|
@os_prefix_ci ||= begin
|
||||||
os = OS_VERSION
|
os = OS_VERSION
|
||||||
prefix = ", non-/usr/local" if HOMEBREW_PREFIX.to_s != "/usr/local"
|
prefix = ", non-/usr/local" if HOMEBREW_PREFIX.to_s != "/usr/local"
|
||||||
ci = ", CI" if ENV["CI"]
|
ci = ", CI" if ENV["CI"]
|
||||||
|
|||||||
@ -5,7 +5,7 @@ module Utils
|
|||||||
class Bottles
|
class Bottles
|
||||||
class << self
|
class << self
|
||||||
def tag
|
def tag
|
||||||
@bottle_tag ||= "#{ENV["HOMEBREW_PROCESSOR"]}_#{ENV["HOMEBREW_SYSTEM"]}".downcase.to_sym
|
@tag ||= "#{ENV["HOMEBREW_PROCESSOR"]}_#{ENV["HOMEBREW_SYSTEM"]}".downcase.to_sym
|
||||||
end
|
end
|
||||||
|
|
||||||
def built_as?(f)
|
def built_as?(f)
|
||||||
|
|||||||
@ -27,7 +27,7 @@ end
|
|||||||
|
|
||||||
module Utils
|
module Utils
|
||||||
def self.git_available?
|
def self.git_available?
|
||||||
@git ||= quiet_system HOMEBREW_SHIMS_PATH/"scm/git", "--version"
|
@git_available ||= quiet_system HOMEBREW_SHIMS_PATH/"scm/git", "--version"
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.git_path
|
def self.git_path
|
||||||
@ -61,7 +61,7 @@ module Utils
|
|||||||
end
|
end
|
||||||
|
|
||||||
def self.clear_git_available_cache
|
def self.clear_git_available_cache
|
||||||
@git = nil
|
@git_available = nil
|
||||||
@git_path = nil
|
@git_path = nil
|
||||||
@git_version = nil
|
@git_version = nil
|
||||||
end
|
end
|
||||||
|
|||||||
@ -94,7 +94,7 @@ module GitHub
|
|||||||
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_printed ||= begin
|
@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(", ")
|
||||||
needed_human_scopes = needed_scopes.join(", ")
|
needed_human_scopes = needed_scopes.join(", ")
|
||||||
@ -125,7 +125,7 @@ module GitHub
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def open(url, data: nil, scopes: [].freeze)
|
def open_api(url, data: nil, scopes: [].freeze)
|
||||||
# This is a no-op if the user is opting out of using the GitHub API.
|
# This is a no-op if the user is opting out of using the GitHub API.
|
||||||
return block_given? ? yield({}) : {} if ENV["HOMEBREW_NO_GITHUB_API"]
|
return block_given? ? yield({}) : {} if ENV["HOMEBREW_NO_GITHUB_API"]
|
||||||
|
|
||||||
@ -226,7 +226,7 @@ module GitHub
|
|||||||
end
|
end
|
||||||
|
|
||||||
def repository(user, repo)
|
def repository(user, repo)
|
||||||
open(url_to("repos", user, repo))
|
open_api(url_to("repos", user, repo))
|
||||||
end
|
end
|
||||||
|
|
||||||
def search_code(**qualifiers)
|
def search_code(**qualifiers)
|
||||||
@ -255,7 +255,7 @@ module GitHub
|
|||||||
|
|
||||||
def private_repo?(full_name)
|
def private_repo?(full_name)
|
||||||
uri = url_to "repos", full_name
|
uri = url_to "repos", full_name
|
||||||
open(uri) { |json| json["private"] }
|
open_api(uri) { |json| json["private"] }
|
||||||
end
|
end
|
||||||
|
|
||||||
def query_string(*main_params, **qualifiers)
|
def query_string(*main_params, **qualifiers)
|
||||||
@ -275,6 +275,6 @@ module GitHub
|
|||||||
def search(entity, *queries, **qualifiers)
|
def search(entity, *queries, **qualifiers)
|
||||||
uri = url_to "search", entity
|
uri = url_to "search", entity
|
||||||
uri.query = query_string(*queries, **qualifiers)
|
uri.query = query_string(*queries, **qualifiers)
|
||||||
open(uri) { |json| json.fetch("items", []) }
|
open_api(uri) { |json| json.fetch("items", []) }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user