Merge pull request #2767 from MikeMcQuaid/rubocop-no-special-global-vars
rubocop: don’t allow special global variables.
This commit is contained in:
commit
22c431d221
@ -183,10 +183,6 @@ Style/RaiseArgs:
|
|||||||
Style/RegexpLiteral:
|
Style/RegexpLiteral:
|
||||||
EnforcedStyle: slashes
|
EnforcedStyle: slashes
|
||||||
|
|
||||||
# not a problem for typical shell users
|
|
||||||
Style/SpecialGlobalVars:
|
|
||||||
Enabled: false
|
|
||||||
|
|
||||||
# ruby style guide favorite
|
# ruby style guide favorite
|
||||||
Style/StringLiterals:
|
Style/StringLiterals:
|
||||||
EnforcedStyle: double_quotes
|
EnforcedStyle: double_quotes
|
||||||
|
|||||||
@ -10,7 +10,8 @@ raise "Homebrew must be run under Ruby 2!" unless RUBY_TWO
|
|||||||
|
|
||||||
require "pathname"
|
require "pathname"
|
||||||
HOMEBREW_LIBRARY_PATH = Pathname.new(__FILE__).realpath.parent
|
HOMEBREW_LIBRARY_PATH = Pathname.new(__FILE__).realpath.parent
|
||||||
$:.unshift(HOMEBREW_LIBRARY_PATH.to_s)
|
require "English"
|
||||||
|
$LOAD_PATH.unshift(HOMEBREW_LIBRARY_PATH.to_s)
|
||||||
require "global"
|
require "global"
|
||||||
require "tap"
|
require "tap"
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,3 @@
|
|||||||
require "English"
|
|
||||||
|
|
||||||
module Hbc
|
module Hbc
|
||||||
class CLI
|
class CLI
|
||||||
class Style < AbstractCommand
|
class Style < AbstractCommand
|
||||||
|
|||||||
@ -112,7 +112,7 @@ module Homebrew
|
|||||||
args << "--display-cop-names" if ARGV.include? "--display-cop-names"
|
args << "--display-cop-names" if ARGV.include? "--display-cop-names"
|
||||||
args << "--format" << "simple" if files
|
args << "--format" << "simple" if files
|
||||||
system(cache_env, "rubocop", *args)
|
system(cache_env, "rubocop", *args)
|
||||||
!$?.success?
|
!$CHILD_STATUS.success?
|
||||||
when :json
|
when :json
|
||||||
json, _, status = Open3.capture3(cache_env, "rubocop", "--format", "json", *args)
|
json, _, status = Open3.capture3(cache_env, "rubocop", "--format", "json", *args)
|
||||||
# exit status of 1 just means violations were found; other numbers mean
|
# exit status of 1 just means violations were found; other numbers mean
|
||||||
|
|||||||
@ -265,10 +265,10 @@ module Homebrew
|
|||||||
failed_audit = false
|
failed_audit = false
|
||||||
if ARGV.include? "--strict"
|
if ARGV.include? "--strict"
|
||||||
system HOMEBREW_BREW_FILE, "audit", "--strict", formula.path
|
system HOMEBREW_BREW_FILE, "audit", "--strict", formula.path
|
||||||
failed_audit = !$?.success?
|
failed_audit = !$CHILD_STATUS.success?
|
||||||
elsif ARGV.include? "--audit"
|
elsif ARGV.include? "--audit"
|
||||||
system HOMEBREW_BREW_FILE, "audit", formula.path
|
system HOMEBREW_BREW_FILE, "audit", formula.path
|
||||||
failed_audit = !$?.success?
|
failed_audit = !$CHILD_STATUS.success?
|
||||||
end
|
end
|
||||||
if failed_audit
|
if failed_audit
|
||||||
formula.path.atomic_write(backup_file)
|
formula.path.atomic_write(backup_file)
|
||||||
|
|||||||
@ -459,7 +459,7 @@ module Homebrew
|
|||||||
def self.lookup(name)
|
def self.lookup(name)
|
||||||
json = Utils.popen_read(HOMEBREW_BREW_FILE, "info", "--json=v1", name)
|
json = Utils.popen_read(HOMEBREW_BREW_FILE, "info", "--json=v1", name)
|
||||||
|
|
||||||
return nil unless $?.success?
|
return nil unless $CHILD_STATUS.success?
|
||||||
|
|
||||||
Homebrew.force_utf8!(json)
|
Homebrew.force_utf8!(json)
|
||||||
FormulaInfoFromJson.new(JSON.parse(json)[0])
|
FormulaInfoFromJson.new(JSON.parse(json)[0])
|
||||||
|
|||||||
@ -111,7 +111,7 @@ module Homebrew
|
|||||||
system "bundle", "exec", "rspec", *args, "--", *files
|
system "bundle", "exec", "rspec", *args, "--", *files
|
||||||
end
|
end
|
||||||
|
|
||||||
return if $?.success?
|
return if $CHILD_STATUS.success?
|
||||||
Homebrew.failed = true
|
Homebrew.failed = true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -338,7 +338,7 @@ class CurlDownloadStrategy < AbstractFileDownloadStrategy
|
|||||||
rescue ErrorDuringExecution
|
rescue ErrorDuringExecution
|
||||||
# 33 == range not supported
|
# 33 == range not supported
|
||||||
# try wiping the incomplete download and retrying once
|
# try wiping the incomplete download and retrying once
|
||||||
unless $?.exitstatus == 33 && had_incomplete_download
|
unless $CHILD_STATUS.exitstatus == 33 && had_incomplete_download
|
||||||
raise CurlDownloadStrategyError, @url
|
raise CurlDownloadStrategyError, @url
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -271,7 +271,7 @@ module Homebrew
|
|||||||
def check_xcode_license_approved
|
def check_xcode_license_approved
|
||||||
# If the user installs Xcode-only, they have to approve the
|
# If the user installs Xcode-only, they have to approve the
|
||||||
# license or no "xc*" tool will work.
|
# license or no "xc*" tool will work.
|
||||||
return unless `/usr/bin/xcrun clang 2>&1` =~ /license/ && !$?.success?
|
return unless `/usr/bin/xcrun clang 2>&1` =~ /license/ && !$CHILD_STATUS.success?
|
||||||
|
|
||||||
<<-EOS.undent
|
<<-EOS.undent
|
||||||
You have not agreed to the Xcode license.
|
You have not agreed to the Xcode license.
|
||||||
|
|||||||
@ -23,7 +23,7 @@ class JavaRequirement < Requirement
|
|||||||
args = %w[--failfast]
|
args = %w[--failfast]
|
||||||
args << "--version" << @version.to_s if @version
|
args << "--version" << @version.to_s if @version
|
||||||
java_home = Utils.popen_read("/usr/libexec/java_home", *args).chomp
|
java_home = Utils.popen_read("/usr/libexec/java_home", *args).chomp
|
||||||
return nil unless $?.success?
|
return nil unless $CHILD_STATUS.success?
|
||||||
Pathname.new(java_home)/"bin/java"
|
Pathname.new(java_home)/"bin/java"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -1836,7 +1836,7 @@ class Formula
|
|||||||
|
|
||||||
$stdout.flush
|
$stdout.flush
|
||||||
|
|
||||||
unless $?.success?
|
unless $CHILD_STATUS.success?
|
||||||
log_lines = ENV["HOMEBREW_FAIL_LOG_LINES"]
|
log_lines = ENV["HOMEBREW_FAIL_LOG_LINES"]
|
||||||
log_lines ||= "15"
|
log_lines ||= "15"
|
||||||
|
|
||||||
|
|||||||
@ -27,7 +27,7 @@ module Homebrew
|
|||||||
def shell_output(cmd, result = 0)
|
def shell_output(cmd, result = 0)
|
||||||
ohai cmd
|
ohai cmd
|
||||||
output = `#{cmd}`
|
output = `#{cmd}`
|
||||||
assert_equal result, $?.exitstatus
|
assert_equal result, $CHILD_STATUS.exitstatus
|
||||||
output
|
output
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -40,7 +40,7 @@ module Homebrew
|
|||||||
pipe.close_write
|
pipe.close_write
|
||||||
pipe.read
|
pipe.read
|
||||||
end
|
end
|
||||||
assert_equal result, $?.exitstatus unless result.nil?
|
assert_equal result, $CHILD_STATUS.exitstatus unless result.nil?
|
||||||
output
|
output
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -96,7 +96,7 @@ module Formulary
|
|||||||
private
|
private
|
||||||
|
|
||||||
def load_file
|
def load_file
|
||||||
$stderr.puts "#{$0} (#{self.class.name}): loading #{path}" if ARGV.debug?
|
$stderr.puts "#{$PROGRAM_NAME} (#{self.class.name}): loading #{path}" if ARGV.debug?
|
||||||
raise FormulaUnavailableError, name unless path.file?
|
raise FormulaUnavailableError, name unless path.file?
|
||||||
Formulary.load_formula_from_path(name, path)
|
Formulary.load_formula_from_path(name, path)
|
||||||
end
|
end
|
||||||
@ -258,7 +258,7 @@ module Formulary
|
|||||||
end
|
end
|
||||||
|
|
||||||
def klass
|
def klass
|
||||||
$stderr.puts "#{$0} (#{self.class.name}): loading #{path}" if ARGV.debug?
|
$stderr.puts "#{$PROGRAM_NAME} (#{self.class.name}): loading #{path}" if ARGV.debug?
|
||||||
namespace = "FormulaNamespace#{Digest::MD5.hexdigest(contents)}"
|
namespace = "FormulaNamespace#{Digest::MD5.hexdigest(contents)}"
|
||||||
Formulary.load_formula(name, path, contents, namespace)
|
Formulary.load_formula(name, path, contents, namespace)
|
||||||
end
|
end
|
||||||
|
|||||||
@ -12,6 +12,7 @@ require "set"
|
|||||||
require "rbconfig"
|
require "rbconfig"
|
||||||
require "official_taps"
|
require "official_taps"
|
||||||
require "pp"
|
require "pp"
|
||||||
|
require "English"
|
||||||
|
|
||||||
ARGV.extend(HomebrewArgvExtension)
|
ARGV.extend(HomebrewArgvExtension)
|
||||||
|
|
||||||
|
|||||||
@ -11,7 +11,7 @@ module Language
|
|||||||
# directory, consequently breaking that assumption. We require a tarball
|
# directory, consequently breaking that assumption. We require a tarball
|
||||||
# because npm install creates a "real" installation when fed a tarball.
|
# because npm install creates a "real" installation when fed a tarball.
|
||||||
output = Utils.popen_read("npm pack").chomp
|
output = Utils.popen_read("npm pack").chomp
|
||||||
raise "npm failed to pack #{Dir.pwd}" unless $?.exitstatus.zero?
|
raise "npm failed to pack #{Dir.pwd}" unless $CHILD_STATUS.exitstatus.zero?
|
||||||
output
|
output
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -118,7 +118,7 @@ module OS
|
|||||||
].uniq.each do |xcodebuild_path|
|
].uniq.each do |xcodebuild_path|
|
||||||
next unless File.executable? xcodebuild_path
|
next unless File.executable? xcodebuild_path
|
||||||
xcodebuild_output = Utils.popen_read(xcodebuild_path, "-version")
|
xcodebuild_output = Utils.popen_read(xcodebuild_path, "-version")
|
||||||
next unless $?.success?
|
next unless $CHILD_STATUS.success?
|
||||||
|
|
||||||
xcode_version = xcodebuild_output[/Xcode (\d(\.\d)*)/, 1]
|
xcode_version = xcodebuild_output[/Xcode (\d(\.\d)*)/, 1]
|
||||||
return xcode_version if xcode_version
|
return xcode_version if xcode_version
|
||||||
|
|||||||
@ -68,7 +68,7 @@ class EmbeddedPatch
|
|||||||
cmd = "/usr/bin/patch"
|
cmd = "/usr/bin/patch"
|
||||||
args = %W[-g 0 -f -#{strip}]
|
args = %W[-g 0 -f -#{strip}]
|
||||||
IO.popen("#{cmd} #{args.join(" ")}", "w") { |p| p.write(data) }
|
IO.popen("#{cmd} #{args.join(" ")}", "w") { |p| p.write(data) }
|
||||||
raise ErrorDuringExecution.new(cmd, args) unless $?.success?
|
raise ErrorDuringExecution.new(cmd, args) unless $CHILD_STATUS.success?
|
||||||
end
|
end
|
||||||
|
|
||||||
def inspect
|
def inspect
|
||||||
|
|||||||
@ -82,7 +82,7 @@ module Readall
|
|||||||
|
|
||||||
# Only syntax errors result in a non-zero status code. To detect syntax
|
# Only syntax errors result in a non-zero status code. To detect syntax
|
||||||
# warnings we also need to inspect the output to `$stderr`.
|
# warnings we also need to inspect the output to `$stderr`.
|
||||||
!$?.success? || !messages.chomp.empty?
|
!$CHILD_STATUS.success? || !messages.chomp.empty?
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -128,7 +128,7 @@ class SystemConfig
|
|||||||
return "N/A" unless File.executable? "/usr/libexec/java_home"
|
return "N/A" unless File.executable? "/usr/libexec/java_home"
|
||||||
|
|
||||||
java_xml = Utils.popen_read("/usr/libexec/java_home", "--xml", "--failfast")
|
java_xml = Utils.popen_read("/usr/libexec/java_home", "--xml", "--failfast")
|
||||||
return "N/A" unless $?.success?
|
return "N/A" unless $CHILD_STATUS.success?
|
||||||
javas = []
|
javas = []
|
||||||
REXML::XPath.each(REXML::Document.new(java_xml), "//key[text()='JVMVersion']/following-sibling::string") do |item|
|
REXML::XPath.each(REXML::Document.new(java_xml), "//key[text()='JVMVersion']/following-sibling::string") do |item|
|
||||||
javas << item.text
|
javas << item.text
|
||||||
|
|||||||
@ -1,4 +1,3 @@
|
|||||||
require "English"
|
|
||||||
require "open3"
|
require "open3"
|
||||||
require "rubygems"
|
require "rubygems"
|
||||||
|
|
||||||
|
|||||||
@ -4,7 +4,7 @@ describe Utils do
|
|||||||
describe "::popen_read" do
|
describe "::popen_read" do
|
||||||
it "reads the standard output of a given command" do
|
it "reads the standard output of a given command" do
|
||||||
expect(subject.popen_read("sh", "-c", "echo success").chomp).to eq("success")
|
expect(subject.popen_read("sh", "-c", "echo success").chomp).to eq("success")
|
||||||
expect($?).to be_a_success
|
expect($CHILD_STATUS).to be_a_success
|
||||||
end
|
end
|
||||||
|
|
||||||
it "can be given a block to manually read from the pipe" do
|
it "can be given a block to manually read from the pipe" do
|
||||||
@ -13,7 +13,7 @@ describe Utils do
|
|||||||
pipe.read.chomp
|
pipe.read.chomp
|
||||||
end,
|
end,
|
||||||
).to eq("success")
|
).to eq("success")
|
||||||
expect($?).to be_a_success
|
expect($CHILD_STATUS).to be_a_success
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -22,7 +22,7 @@ describe Utils do
|
|||||||
subject.popen_write("grep", "-q", "success") do |pipe|
|
subject.popen_write("grep", "-q", "success") do |pipe|
|
||||||
pipe.write("success\n")
|
pipe.write("success\n")
|
||||||
end
|
end
|
||||||
expect($?).to be_a_success
|
expect($CHILD_STATUS).to be_a_success
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -151,9 +151,9 @@ def interactive_shell(f = nil)
|
|||||||
|
|
||||||
Process.wait fork { exec ENV["SHELL"] }
|
Process.wait fork { exec ENV["SHELL"] }
|
||||||
|
|
||||||
return if $?.success?
|
return if $CHILD_STATUS.success?
|
||||||
raise "Aborted due to non-zero exit status (#{$?.exitstatus})" if $?.exited?
|
raise "Aborted due to non-zero exit status (#{$CHILD_STATUS.exitstatus})" if $CHILD_STATUS.exited?
|
||||||
raise $?.inspect
|
raise $CHILD_STATUS.inspect
|
||||||
end
|
end
|
||||||
|
|
||||||
module Homebrew
|
module Homebrew
|
||||||
@ -171,7 +171,7 @@ module Homebrew
|
|||||||
exit! 1 # never gets here unless exec failed
|
exit! 1 # never gets here unless exec failed
|
||||||
end
|
end
|
||||||
Process.wait(pid)
|
Process.wait(pid)
|
||||||
$?.success?
|
$CHILD_STATUS.success?
|
||||||
end
|
end
|
||||||
|
|
||||||
def system(cmd, *args)
|
def system(cmd, *args)
|
||||||
|
|||||||
@ -37,8 +37,8 @@ module Utils
|
|||||||
read.close
|
read.close
|
||||||
Process.wait(pid) unless socket.nil?
|
Process.wait(pid) unless socket.nil?
|
||||||
raise Marshal.load(data) unless data.nil? || data.empty?
|
raise Marshal.load(data) unless data.nil? || data.empty?
|
||||||
raise Interrupt if $?.exitstatus == 130
|
raise Interrupt if $CHILD_STATUS.exitstatus == 130
|
||||||
raise "Suspicious failure" unless $?.success?
|
raise "Suspicious failure" unless $CHILD_STATUS.success?
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user