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:
|
||||
AllowAdjacentOneLineDefs: true
|
||||
|
||||
Layout/EndAlignment:
|
||||
EnforcedStyleAlignWith: variable
|
||||
|
||||
Layout/IndentArray:
|
||||
EnforcedStyle: special_inside_parentheses
|
||||
|
||||
@ -52,9 +55,6 @@ Lint/AmbiguousBlockAssociation:
|
||||
Lint/AssignmentInCondition:
|
||||
Enabled: false
|
||||
|
||||
Lint/EndAlignment:
|
||||
EnforcedStyleAlignWith: variable
|
||||
|
||||
# so many of these in formulae and can't be autocorrected
|
||||
Lint/ParenthesesAsGroupedExpression:
|
||||
Enabled: false
|
||||
@ -205,7 +205,10 @@ Style/TernaryParentheses:
|
||||
EnforcedStyle: require_parentheses_when_complex
|
||||
|
||||
# makes diffs nicer
|
||||
Style/TrailingCommaInLiteral:
|
||||
Style/TrailingCommaInArrayLiteral:
|
||||
EnforcedStyleForMultiline: comma
|
||||
|
||||
Style/TrailingCommaInHashLiteral:
|
||||
EnforcedStyleForMultiline: comma
|
||||
|
||||
Style/TrailingCommaInArguments:
|
||||
@ -215,6 +218,10 @@ Style/TrailingCommaInArguments:
|
||||
Naming/VariableNumber:
|
||||
Enabled: false
|
||||
|
||||
# doesn't make sense for Homebrew/brew but does for taps
|
||||
Naming/UncommunicativeMethodParamName:
|
||||
Enabled: true
|
||||
|
||||
Style/WordArray:
|
||||
MinSize: 4
|
||||
|
||||
|
||||
@ -68,6 +68,10 @@ Naming/PredicateName:
|
||||
- 'compat/**/*'
|
||||
NameWhitelist: is_32_bit?, is_64_bit?
|
||||
|
||||
# f meaning formulae is pretty standard
|
||||
Naming/UncommunicativeMethodParamName:
|
||||
Enabled: false
|
||||
|
||||
Style/BlockDelimiters:
|
||||
Exclude:
|
||||
- '**/*_spec.rb'
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
require "uri"
|
||||
|
||||
module Hbc
|
||||
module CaskLoader
|
||||
class FromContentLoader
|
||||
|
||||
@ -113,14 +113,14 @@ module Homebrew
|
||||
url = "https://api.github.com/gists"
|
||||
data = { "public" => true, "files" => files, "description" => description }
|
||||
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
|
||||
|
||||
def create_issue(repo, title, body)
|
||||
url = "https://api.github.com/repos/#{repo}/issues"
|
||||
data = { "title" => title, "body" => body }
|
||||
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
|
||||
|
||||
def gist_logs
|
||||
|
||||
@ -344,7 +344,7 @@ module Homebrew
|
||||
rescue FormulaInstallationAlreadyAttemptedError
|
||||
# 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.
|
||||
return
|
||||
nil
|
||||
rescue CannotInstallFormulaError => e
|
||||
ofail e.message
|
||||
end
|
||||
|
||||
@ -47,7 +47,7 @@ module Homebrew
|
||||
fi.install
|
||||
fi.finish
|
||||
rescue FormulaInstallationAlreadyAttemptedError
|
||||
return
|
||||
nil
|
||||
rescue Exception # rubocop:disable Lint/RescueException
|
||||
ignore_interrupts { restore_backup(keg, keg_was_linked) }
|
||||
raise
|
||||
|
||||
@ -13,7 +13,7 @@ module Homebrew
|
||||
module_function
|
||||
|
||||
def update_preinstall_header
|
||||
@header_already_printed ||= begin
|
||||
@update_preinstall_header ||= begin
|
||||
ohai "Auto-updated Homebrew!" if ARGV.include?("--preinstall")
|
||||
true
|
||||
end
|
||||
|
||||
@ -139,7 +139,7 @@ module Homebrew
|
||||
rescue FormulaInstallationAlreadyAttemptedError
|
||||
# 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.
|
||||
return
|
||||
nil
|
||||
rescue CannotInstallFormulaError => e
|
||||
ofail e
|
||||
rescue BuildError => e
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
# RuboCop version used for `brew style` and `brew cask style`
|
||||
HOMEBREW_RUBOCOP_VERSION = "0.52.1"
|
||||
HOMEBREW_RUBOCOP_CASK_VERSION = "~> 0.16.0" # has to be updated when RuboCop version changes
|
||||
HOMEBREW_RUBOCOP_VERSION = "0.53.0"
|
||||
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.
|
||||
EOS
|
||||
rescue FormulaUnavailableError
|
||||
return
|
||||
nil
|
||||
end
|
||||
|
||||
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.
|
||||
EOS
|
||||
rescue FormulaUnavailableError
|
||||
return
|
||||
nil
|
||||
end
|
||||
|
||||
def check_for_pydistutils_cfg_in_home
|
||||
|
||||
@ -604,7 +604,7 @@ class GitHubPrivateRepositoryReleaseDownloadStrategy < GitHubPrivateRepositoryDo
|
||||
|
||||
def fetch_release_metadata
|
||||
release_url = "https://api.github.com/repos/#{@owner}/#{@repo}/releases/tags/#{@tag}"
|
||||
GitHub.open(release_url)
|
||||
GitHub.open_api(release_url)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@ -31,7 +31,7 @@ class SystemConfig
|
||||
return "N/A" unless CoreTap.instance.installed?
|
||||
Formulary.factory(formula).linked_version || "N/A"
|
||||
rescue FormulaUnavailableError
|
||||
return "N/A"
|
||||
"N/A"
|
||||
end
|
||||
|
||||
def dump_verbose_config(out = $stdout)
|
||||
|
||||
@ -44,7 +44,7 @@ class FormulaVersions
|
||||
# continue walking the history
|
||||
ohai "#{e} in #{name} at revision #{rev}", e.backtrace if ARGV.debug?
|
||||
rescue FormulaUnavailableError
|
||||
return
|
||||
nil
|
||||
ensure
|
||||
Homebrew.raise_deprecation_exceptions = false
|
||||
end
|
||||
|
||||
@ -4,6 +4,8 @@ require_relative "../../extend/string"
|
||||
module RuboCop
|
||||
module Cop
|
||||
class FormulaCop < Cop
|
||||
include RangeHelp
|
||||
|
||||
attr_accessor :file_path
|
||||
@registry = Cop.registry
|
||||
|
||||
|
||||
@ -108,10 +108,10 @@ class Sandbox
|
||||
|
||||
unless logs.empty?
|
||||
if @logfile
|
||||
log = open(@logfile, "w")
|
||||
log.write logs
|
||||
log.write "\nWe use time to filter sandbox log. Therefore, unrelated logs may be recorded.\n"
|
||||
log.close
|
||||
File.open(@logfile, "w") do |log|
|
||||
log.write logs
|
||||
log.write "\nWe use time to filter sandbox log. Therefore, unrelated logs may be recorded.\n"
|
||||
end
|
||||
end
|
||||
|
||||
if @failed && ARGV.verbose?
|
||||
|
||||
@ -326,8 +326,8 @@ class Tab < OpenStruct
|
||||
"time" => time,
|
||||
"source_modified_time" => source_modified_time.to_i,
|
||||
"HEAD" => self.HEAD,
|
||||
"stdlib" => (stdlib.to_s if stdlib),
|
||||
"compiler" => (compiler.to_s if compiler),
|
||||
"stdlib" => (stdlib&.to_s),
|
||||
"compiler" => (compiler&.to_s),
|
||||
"aliases" => aliases,
|
||||
"runtime_dependencies" => runtime_dependencies,
|
||||
"source" => source,
|
||||
|
||||
@ -36,9 +36,9 @@ GEM
|
||||
rspec-support (3.7.1)
|
||||
rspec-wait (0.0.9)
|
||||
rspec (>= 3, < 4)
|
||||
rubocop (0.52.1)
|
||||
rubocop (0.53.0)
|
||||
parallel (~> 1.10)
|
||||
parser (>= 2.4.0.2, < 3.0)
|
||||
parser (>= 2.5)
|
||||
powerpack (~> 0.1)
|
||||
rainbow (>= 2.2.2, < 4.0)
|
||||
ruby-progressbar (~> 1.7)
|
||||
@ -62,7 +62,7 @@ DEPENDENCIES
|
||||
rspec-its
|
||||
rspec-retry
|
||||
rspec-wait
|
||||
rubocop (= 0.52.1)
|
||||
rubocop (= 0.53.0)
|
||||
simplecov
|
||||
|
||||
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"))
|
||||
.to match(["homebrew/foo/some-formula"])
|
||||
|
||||
@ -116,7 +116,7 @@ describe GitHubPrivateRepositoryReleaseDownloadStrategy do
|
||||
describe "#fetch_release_metadata" do
|
||||
it "fetches release metadata from GitHub" do
|
||||
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)
|
||||
end
|
||||
end
|
||||
|
||||
@ -16,9 +16,9 @@ TEST_TMPDIR = ENV.fetch("HOMEBREW_TEST_TMPDIR") do |k|
|
||||
end
|
||||
|
||||
# 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_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
|
||||
HOMEBREW_PREFIX = Pathname.new(TEST_TMPDIR).join("prefix")
|
||||
|
||||
@ -3,9 +3,9 @@ require "formula_installer"
|
||||
|
||||
describe Utils::Analytics 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
|
||||
described_class.clear_anonymous_os_prefix_ci_cache
|
||||
described_class.clear_os_prefix_ci
|
||||
end
|
||||
|
||||
it "returns OS_VERSION and prefix when HOMEBREW_PREFIX is not /usr/local" do
|
||||
|
||||
@ -3,13 +3,13 @@ require "erb"
|
||||
module Utils
|
||||
module Analytics
|
||||
class << self
|
||||
def clear_anonymous_os_prefix_ci_cache
|
||||
return unless instance_variable_defined?(:@anonymous_os_prefix_ci)
|
||||
remove_instance_variable(:@anonymous_os_prefix_ci)
|
||||
def clear_os_prefix_ci
|
||||
return unless instance_variable_defined?(:@os_prefix_ci)
|
||||
remove_instance_variable(:@os_prefix_ci)
|
||||
end
|
||||
|
||||
def os_prefix_ci
|
||||
@anonymous_os_prefix_ci ||= begin
|
||||
@os_prefix_ci ||= begin
|
||||
os = OS_VERSION
|
||||
prefix = ", non-/usr/local" if HOMEBREW_PREFIX.to_s != "/usr/local"
|
||||
ci = ", CI" if ENV["CI"]
|
||||
|
||||
@ -5,7 +5,7 @@ module Utils
|
||||
class Bottles
|
||||
class << self
|
||||
def tag
|
||||
@bottle_tag ||= "#{ENV["HOMEBREW_PROCESSOR"]}_#{ENV["HOMEBREW_SYSTEM"]}".downcase.to_sym
|
||||
@tag ||= "#{ENV["HOMEBREW_PROCESSOR"]}_#{ENV["HOMEBREW_SYSTEM"]}".downcase.to_sym
|
||||
end
|
||||
|
||||
def built_as?(f)
|
||||
|
||||
@ -27,7 +27,7 @@ end
|
||||
|
||||
module Utils
|
||||
def self.git_available?
|
||||
@git ||= quiet_system HOMEBREW_SHIMS_PATH/"scm/git", "--version"
|
||||
@git_available ||= quiet_system HOMEBREW_SHIMS_PATH/"scm/git", "--version"
|
||||
end
|
||||
|
||||
def self.git_path
|
||||
@ -61,7 +61,7 @@ module Utils
|
||||
end
|
||||
|
||||
def self.clear_git_available_cache
|
||||
@git = nil
|
||||
@git_available = nil
|
||||
@git_path = nil
|
||||
@git_version = nil
|
||||
end
|
||||
|
||||
@ -94,7 +94,7 @@ module GitHub
|
||||
def api_credentials_error_message(response_headers, needed_scopes)
|
||||
return if response_headers.empty?
|
||||
|
||||
@api_credentials_error_message_printed ||= begin
|
||||
@api_credentials_error_message ||= begin
|
||||
unauthorized = (response_headers["http/1.1"] == "401 Unauthorized")
|
||||
scopes = response_headers["x-accepted-oauth-scopes"].to_s.split(", ")
|
||||
needed_human_scopes = needed_scopes.join(", ")
|
||||
@ -125,7 +125,7 @@ module GitHub
|
||||
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.
|
||||
return block_given? ? yield({}) : {} if ENV["HOMEBREW_NO_GITHUB_API"]
|
||||
|
||||
@ -226,7 +226,7 @@ module GitHub
|
||||
end
|
||||
|
||||
def repository(user, repo)
|
||||
open(url_to("repos", user, repo))
|
||||
open_api(url_to("repos", user, repo))
|
||||
end
|
||||
|
||||
def search_code(**qualifiers)
|
||||
@ -255,7 +255,7 @@ module GitHub
|
||||
|
||||
def private_repo?(full_name)
|
||||
uri = url_to "repos", full_name
|
||||
open(uri) { |json| json["private"] }
|
||||
open_api(uri) { |json| json["private"] }
|
||||
end
|
||||
|
||||
def query_string(*main_params, **qualifiers)
|
||||
@ -275,6 +275,6 @@ module GitHub
|
||||
def search(entity, *queries, **qualifiers)
|
||||
uri = url_to "search", entity
|
||||
uri.query = query_string(*queries, **qualifiers)
|
||||
open(uri) { |json| json.fetch("items", []) }
|
||||
open_api(uri) { |json| json.fetch("items", []) }
|
||||
end
|
||||
end
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user