Auto-fix Style/RedundantBegin offenses

- This also required auto-fixes for Layout/EmptyLinesAroundBlockBody and
  Layout/InconsistentIndentation once the auto-fixer had got rid of the
  "redundant begin"s.
This commit is contained in:
Issy Long 2019-10-13 10:03:26 +01:00
parent b78028b9c2
commit 341ea60807
No known key found for this signature in database
GPG Key ID: 8247C390DADC67D4
40 changed files with 376 additions and 479 deletions

View File

@ -142,7 +142,6 @@ class BottlePublisher
retry_count = 0 retry_count = 0
# We're in the cache; make sure to force re-download # We're in the cache; make sure to force re-download
loop do loop do
begin
curl_download url, to: filename curl_download url, to: filename
break break
rescue rescue
@ -153,7 +152,6 @@ class BottlePublisher
curl_retry_delay_seconds *= 2 curl_retry_delay_seconds *= 2
retry_count += 1 retry_count += 1
end end
end
checksum = Checksum.new(:sha256, bottle_info["sha256"]) checksum = Checksum.new(:sha256, bottle_info["sha256"])
Pathname.new(filename).verify_checksum(checksum) Pathname.new(filename).verify_checksum(checksum)
end end

View File

@ -65,7 +65,6 @@ module Cask
return yield nil if choices.empty? return yield nil if choices.empty?
Tempfile.open(["choices", ".xml"]) do |file| Tempfile.open(["choices", ".xml"]) do |file|
begin
file.write Plist::Emit.dump(choices) file.write Plist::Emit.dump(choices)
file.close file.close
yield file.path yield file.path
@ -76,4 +75,3 @@ module Cask
end end
end end
end end
end

View File

@ -19,13 +19,11 @@ module Cask
return to_enum unless block_given? return to_enum unless block_given?
Tap.flat_map(&:cask_files).each do |f| Tap.flat_map(&:cask_files).each do |f|
begin
yield CaskLoader::FromTapPathLoader.new(f).load yield CaskLoader::FromTapPathLoader.new(f).load
rescue CaskUnreadableError => e rescue CaskUnreadableError => e
opoo e.message opoo e.message
end end
end end
end
def tap def tap
return super if block_given? # Object#tap return super if block_given? # Object#tap

View File

@ -200,12 +200,10 @@ module Cask
end end
remaining = all_args.select do |arg| remaining = all_args.select do |arg|
begin
!process_arguments([arg]).empty? !process_arguments([arg]).empty?
rescue OptionParser::InvalidOption, OptionParser::MissingArgument, OptionParser::AmbiguousOption rescue OptionParser::InvalidOption, OptionParser::MissingArgument, OptionParser::AmbiguousOption
true true
end end
end
remaining + non_options remaining + non_options
end end

View File

@ -14,7 +14,6 @@ module Cask
def run def run
odie "Installing casks is supported only on macOS" unless OS.mac? odie "Installing casks is supported only on macOS" unless OS.mac?
casks.each do |cask| casks.each do |cask|
begin
Installer.new(cask, binaries: binaries?, Installer.new(cask, binaries: binaries?,
verbose: verbose?, verbose: verbose?,
force: force?, force: force?,
@ -25,7 +24,6 @@ module Cask
opoo e.message opoo e.message
end end
end end
end
def self.help def self.help
"installs the given Cask" "installs the given Cask"

View File

@ -45,13 +45,11 @@ module Cask
return if dry_run? return if dry_run?
upgradable_casks.each do |(old_cask, new_cask)| upgradable_casks.each do |(old_cask, new_cask)|
begin
upgrade_cask(old_cask, new_cask) upgrade_cask(old_cask, new_cask)
rescue CaskError => e rescue CaskError => e
caught_exceptions << e caught_exceptions << e
next next
end end
end
return if caught_exceptions.empty? return if caught_exceptions.empty?
raise MultipleCaskErrors, caught_exceptions if caught_exceptions.count > 1 raise MultipleCaskErrors, caught_exceptions if caught_exceptions.count > 1

View File

@ -137,12 +137,10 @@ module Cask
locales = MacOS.languages locales = MacOS.languages
.map do |language| .map do |language|
begin
Locale.parse(language) Locale.parse(language)
rescue Locale::ParserError rescue Locale::ParserError
nil nil
end end
end
.compact .compact
locales.each do |locale| locales.each do |locale|
@ -255,7 +253,6 @@ module Cask
ORDINARY_ARTIFACT_CLASSES.each do |klass| ORDINARY_ARTIFACT_CLASSES.each do |klass|
define_method(klass.dsl_key) do |*args| define_method(klass.dsl_key) do |*args|
begin
if [*artifacts.map(&:class), klass].include?(Artifact::StageOnly) && if [*artifacts.map(&:class), klass].include?(Artifact::StageOnly) &&
(artifacts.map(&:class) & ACTIVATABLE_ARTIFACT_CLASSES).any? (artifacts.map(&:class) & ACTIVATABLE_ARTIFACT_CLASSES).any?
raise CaskInvalidError.new(cask, "'stage_only' must be the only activatable artifact.") raise CaskInvalidError.new(cask, "'stage_only' must be the only activatable artifact.")
@ -268,7 +265,6 @@ module Cask
raise CaskInvalidError.new(cask, "invalid '#{klass.dsl_key}' stanza: #{e}") raise CaskInvalidError.new(cask, "invalid '#{klass.dsl_key}' stanza: #{e}")
end end
end end
end
ARTIFACT_BLOCK_CLASSES.each do |klass| ARTIFACT_BLOCK_CLASSES.each do |klass|
[klass.dsl_key, klass.uninstall_dsl_key].each do |dsl_key| [klass.dsl_key, klass.uninstall_dsl_key].each do |dsl_key|

View File

@ -111,14 +111,12 @@ module Cask
return unless @cask.conflicts_with return unless @cask.conflicts_with
@cask.conflicts_with[:cask].each do |conflicting_cask| @cask.conflicts_with[:cask].each do |conflicting_cask|
begin
conflicting_cask = CaskLoader.load(conflicting_cask) conflicting_cask = CaskLoader.load(conflicting_cask)
raise CaskConflictError.new(@cask, conflicting_cask) if conflicting_cask.installed? raise CaskConflictError.new(@cask, conflicting_cask) if conflicting_cask.installed?
rescue CaskUnavailableError rescue CaskUnavailableError
next # Ignore conflicting Casks that do not exist. next # Ignore conflicting Casks that do not exist.
end end
end end
end
def reinstall def reinstall
odebug "Cask::Installer#reinstall" odebug "Cask::Installer#reinstall"

View File

@ -86,11 +86,9 @@ class Caveats
def keg def keg
@keg ||= [f.prefix, f.opt_prefix, f.linked_keg].map do |d| @keg ||= [f.prefix, f.opt_prefix, f.linked_keg].map do |d|
begin
Keg.new(d.resolved_path) Keg.new(d.resolved_path)
rescue rescue
nil nil
end
end.compact.first end.compact.first
end end

View File

@ -25,13 +25,11 @@ module Homebrew
deps_of_installed = installed.flat_map do |f| deps_of_installed = installed.flat_map do |f|
f.runtime_dependencies.map do |dep| f.runtime_dependencies.map do |dep|
begin
dep.to_formula.full_name dep.to_formula.full_name
rescue FormulaUnavailableError rescue FormulaUnavailableError
dep.name dep.name
end end
end end
end
leaves = installed.map(&:full_name) - deps_of_installed leaves = installed.map(&:full_name) - deps_of_installed
leaves.each(&method(:puts)) leaves.each(&method(:puts))

View File

@ -382,7 +382,6 @@ module Homebrew
end end
reinstallable.each do |f| reinstallable.each do |f|
begin
reinstall_formula(f, build_from_source: true) reinstall_formula(f, build_from_source: true)
rescue FormulaInstallationAlreadyAttemptedError rescue FormulaInstallationAlreadyAttemptedError
# We already attempted to reinstall f as part of the dependency tree of # We already attempted to reinstall f as part of the dependency tree of
@ -399,4 +398,3 @@ module Homebrew
end end
end end
end end
end

View File

@ -68,7 +68,6 @@ module Homebrew
uses = formulae.select do |f| uses = formulae.select do |f|
used_formulae.all? do |ff| used_formulae.all? do |ff|
begin
deps = f.runtime_dependencies if only_installed_arg deps = f.runtime_dependencies if only_installed_arg
deps ||= if recursive deps ||= if recursive
recursive_includes(Dependency, f, includes, ignores) recursive_includes(Dependency, f, includes, ignores)
@ -77,19 +76,16 @@ module Homebrew
end end
deps.any? do |dep| deps.any? do |dep|
begin
dep.to_formula.full_name == ff.full_name dep.to_formula.full_name == ff.full_name
rescue rescue
dep.name == ff.name dep.name == ff.name
end end
end
rescue FormulaUnavailableError rescue FormulaUnavailableError
# Silently ignore this case as we don't care about things used in # Silently ignore this case as we don't care about things used in
# taps that aren't currently tapped. # taps that aren't currently tapped.
next next
end end
end end
end
return if uses.empty? return if uses.empty?

View File

@ -63,13 +63,11 @@ class DescriptionCacheStore < CacheStore
return populate_if_empty! if database.empty? return populate_if_empty! if database.empty?
formula_names.each do |name| formula_names.each do |name|
begin
update!(name, Formula[name].desc) update!(name, Formula[name].desc)
rescue FormulaUnavailableError, *FormulaVersions::IGNORED_EXCEPTIONS rescue FormulaUnavailableError, *FormulaVersions::IGNORED_EXCEPTIONS
delete!(name) delete!(name)
end end
end end
end
# Use an array of formulae names to delete them from the `DescriptionCacheStore`. # Use an array of formulae names to delete them from the `DescriptionCacheStore`.
# #

View File

@ -434,7 +434,6 @@ module Homebrew
def audit_conflicts def audit_conflicts
formula.conflicts.each do |c| formula.conflicts.each do |c|
begin
Formulary.factory(c.name) Formulary.factory(c.name)
rescue TapFormulaUnavailableError rescue TapFormulaUnavailableError
# Don't complain about missing cross-tap conflicts. # Don't complain about missing cross-tap conflicts.
@ -445,7 +444,6 @@ module Homebrew
problem "Ambiguous conflicting formula #{c.name.inspect}." problem "Ambiguous conflicting formula #{c.name.inspect}."
end end
end end
end
def audit_keg_only_style def audit_keg_only_style
return unless formula.keg_only? return unless formula.keg_only?

View File

@ -718,7 +718,6 @@ module Homebrew
def check_for_unreadable_installed_formula def check_for_unreadable_installed_formula
formula_unavailable_exceptions = [] formula_unavailable_exceptions = []
Formula.racks.each do |rack| Formula.racks.each do |rack|
begin
Formulary.from_rack(rack) Formulary.from_rack(rack)
rescue FormulaUnreadableError, FormulaClassUnavailableError, rescue FormulaUnreadableError, FormulaClassUnavailableError,
TapFormulaUnreadableError, TapFormulaClassUnavailableError => e TapFormulaUnreadableError, TapFormulaClassUnavailableError => e
@ -727,7 +726,6 @@ module Homebrew
TapFormulaAmbiguityError, TapFormulaWithOldnameAmbiguityError TapFormulaAmbiguityError, TapFormulaWithOldnameAmbiguityError
nil nil
end end
end
return if formula_unavailable_exceptions.empty? return if formula_unavailable_exceptions.empty?
<<~EOS <<~EOS

View File

@ -213,11 +213,9 @@ module SharedEnvExtension
path.append( path.append(
# user paths # user paths
ORIGINAL_PATHS.map do |p| ORIGINAL_PATHS.map do |p|
begin
p.realpath.to_s p.realpath.to_s
rescue rescue
nil nil
end
end - %w[/usr/X11/bin /opt/X11/bin], end - %w[/usr/X11/bin /opt/X11/bin],
) )
self["PATH"] = path self["PATH"] = path

View File

@ -17,12 +17,10 @@ module Superenv
def homebrew_extra_paths def homebrew_extra_paths
paths = [] paths = []
paths += %w[binutils make].map do |f| paths += %w[binutils make].map do |f|
begin
bin = Formula[f].opt_bin bin = Formula[f].opt_bin
bin if bin.directory? bin if bin.directory?
rescue FormulaUnavailableError rescue FormulaUnavailableError
nil nil
end
end.compact end.compact
paths paths
end end

View File

@ -387,11 +387,9 @@ class Formula
return [] if versioned_formula? return [] if versioned_formula?
Pathname.glob(path.to_s.gsub(/\.rb$/, "@*.rb")).map do |path| Pathname.glob(path.to_s.gsub(/\.rb$/, "@*.rb")).map do |path|
begin
Formula[path.basename(".rb").to_s] Formula[path.basename(".rb").to_s]
rescue FormulaUnavailableError rescue FormulaUnavailableError
nil nil
end
end.compact.sort end.compact.sort
end end
@ -1387,7 +1385,6 @@ class Formula
# @private # @private
def self.each def self.each
files.each do |file| files.each do |file|
begin
yield Formulary.factory(file) yield Formulary.factory(file)
rescue => e rescue => e
# Don't let one broken formula break commands. But do complain. # Don't let one broken formula break commands. But do complain.
@ -1396,7 +1393,6 @@ class Formula
next next
end end
end end
end
# Clear cache of .racks # Clear cache of .racks
def self.clear_racks_cache def self.clear_racks_cache
@ -1425,11 +1421,9 @@ class Formula
# @private # @private
def self.installed def self.installed
@installed ||= racks.flat_map do |rack| @installed ||= racks.flat_map do |rack|
begin
Formulary.from_rack(rack) Formulary.from_rack(rack)
rescue rescue
[] []
end
end.uniq(&:name) end.uniq(&:name)
end end
@ -1568,11 +1562,9 @@ class Formula
read_from_tab: read_from_tab, read_from_tab: read_from_tab,
undeclared: undeclared, undeclared: undeclared,
).map do |d| ).map do |d|
begin
d.to_formula d.to_formula
rescue FormulaUnavailableError rescue FormulaUnavailableError
nil nil
end
end.compact end.compact
end end

View File

@ -351,7 +351,6 @@ class FormulaInstaller
return if ARGV.force? return if ARGV.force?
conflicts = formula.conflicts.select do |c| conflicts = formula.conflicts.select do |c|
begin
f = Formulary.factory(c.name) f = Formulary.factory(c.name)
rescue TapFormulaUnavailableError rescue TapFormulaUnavailableError
# If the formula name is a fully-qualified name let's silently # If the formula name is a fully-qualified name let's silently
@ -373,7 +372,6 @@ class FormulaInstaller
else else
f.linked_keg.exist? && f.opt_prefix.exist? f.linked_keg.exist? && f.opt_prefix.exist?
end end
end
raise FormulaConflictError.new(formula, conflicts) unless conflicts.empty? raise FormulaConflictError.new(formula, conflicts) unless conflicts.empty?
end end

View File

@ -106,11 +106,9 @@ require "PATH"
ENV["HOMEBREW_PATH"] ||= ENV["PATH"] ENV["HOMEBREW_PATH"] ||= ENV["PATH"]
ORIGINAL_PATHS = PATH.new(ENV["HOMEBREW_PATH"]).map do |p| ORIGINAL_PATHS = PATH.new(ENV["HOMEBREW_PATH"]).map do |p|
begin
Pathname.new(p).expand_path Pathname.new(p).expand_path
rescue rescue
nil nil
end
end.compact.freeze end.compact.freeze
HOMEBREW_INTERNAL_COMMAND_ALIASES = { HOMEBREW_INTERNAL_COMMAND_ALIASES = {

View File

@ -22,7 +22,6 @@ module Homebrew
def attempt_directory_creation def attempt_directory_creation
Keg::MUST_EXIST_DIRECTORIES.each do |dir| Keg::MUST_EXIST_DIRECTORIES.each do |dir|
begin
FileUtils.mkdir_p(dir) unless dir.exist? FileUtils.mkdir_p(dir) unless dir.exist?
# Create these files to ensure that these directories aren't removed # Create these files to ensure that these directories aren't removed
@ -34,7 +33,6 @@ module Homebrew
nil nil
end end
end end
end
def check_cc_argv def check_cc_argv
return unless ARGV.cc return unless ARGV.cc

View File

@ -128,7 +128,6 @@ class Keg
keg_names = kegs.select(&:optlinked?).map(&:name) keg_names = kegs.select(&:optlinked?).map(&:name)
keg_formulae = [] keg_formulae = []
kegs_by_source = kegs.group_by do |keg| kegs_by_source = kegs.group_by do |keg|
begin
# First, attempt to resolve the keg to a formula # First, attempt to resolve the keg to a formula
# to get up-to-date name and tap information. # to get up-to-date name and tap information.
f = keg.to_formula f = keg.to_formula
@ -139,7 +138,6 @@ class Keg
# fall back to the information in the tab. # fall back to the information in the tab.
[keg.name, keg.tab.tap] [keg.name, keg.tab.tap]
end end
end
all_required_kegs = Set.new all_required_kegs = Set.new
all_dependents = [] all_dependents = []

View File

@ -37,7 +37,6 @@ module Readall
def valid_formulae?(formulae) def valid_formulae?(formulae)
failed = false failed = false
formulae.each do |file| formulae.each do |file|
begin
Formulary.factory(file) Formulary.factory(file)
rescue Interrupt rescue Interrupt
raise raise
@ -46,7 +45,6 @@ module Readall
puts e puts e
failed = true failed = true
end end
end
!failed !failed
end end

View File

@ -184,13 +184,11 @@ class SoftwareSpec
def recursive_dependencies def recursive_dependencies
deps_f = [] deps_f = []
recursive_dependencies = deps.map do |dep| recursive_dependencies = deps.map do |dep|
begin
deps_f << dep.to_formula deps_f << dep.to_formula
dep dep
rescue TapFormulaUnavailableError rescue TapFormulaUnavailableError
# Don't complain about missing cross-tap dependencies # Don't complain about missing cross-tap dependencies
next next
end
end.compact.uniq end.compact.uniq
deps_f.compact.each do |f| deps_f.compact.each do |f|
f.recursive_dependencies.each do |dep| f.recursive_dependencies.each do |dep|
@ -386,12 +384,11 @@ class BottleSpecification
def checksums def checksums
tags = collector.keys.sort_by do |tag| tags = collector.keys.sort_by do |tag|
# Sort non-MacOS tags below MacOS tags. # Sort non-MacOS tags below MacOS tags.
begin
OS::Mac::Version.from_symbol tag OS::Mac::Version.from_symbol tag
rescue ArgumentError rescue ArgumentError
"0.#{tag}" "0.#{tag}"
end end
end
checksums = {} checksums = {}
tags.reverse_each do |tag| tags.reverse_each do |tag|
checksum = collector[tag] checksum = collector[tag]

View File

@ -148,7 +148,6 @@ class SystemCommand
break if readable_sources.empty? break if readable_sources.empty?
readable_sources.each do |source| readable_sources.each do |source|
begin
line = source.readline_nonblock || "" line = source.readline_nonblock || ""
type = (source == sources[0]) ? :stdout : :stderr type = (source == sources[0]) ? :stdout : :stderr
yield(type, line) yield(type, line)
@ -156,7 +155,6 @@ class SystemCommand
next next
end end
end end
end
sources.each(&:close_read) sources.each(&:close_read)
end end

View File

@ -199,7 +199,6 @@ shared_examples "#uninstall_phase or #zap_phase" do
let(:cask) { Cask::CaskLoader.load(cask_path("with-#{artifact_dsl_key}-#{directive}")) } let(:cask) { Cask::CaskLoader.load(cask_path("with-#{artifact_dsl_key}-#{directive}")) }
around do |example| around do |example|
begin
ENV["HOME"] = dir ENV["HOME"] = dir
FileUtils.touch paths FileUtils.touch paths
@ -208,7 +207,6 @@ shared_examples "#uninstall_phase or #zap_phase" do
ensure ensure
FileUtils.rm_f paths FileUtils.rm_f paths
end end
end
before do before do
allow_any_instance_of(Cask::Artifact::AbstractUninstall).to receive(:trash_paths) allow_any_instance_of(Cask::Artifact::AbstractUninstall).to receive(:trash_paths)

View File

@ -5,14 +5,12 @@ require_relative "shared_examples/invalid_option"
describe Cask::Cmd::Create, :cask do describe Cask::Cmd::Create, :cask do
around do |example| around do |example|
begin
example.run example.run
ensure ensure
%w[new-cask additional-cask another-cask yet-another-cask local-caff].each do |cask| %w[new-cask additional-cask another-cask yet-another-cask local-caff].each do |cask|
FileUtils.rm_f Cask::CaskLoader.path(cask) FileUtils.rm_f Cask::CaskLoader.path(cask)
end end
end end
end
before do before do
allow_any_instance_of(described_class).to receive(:exec_editor) allow_any_instance_of(described_class).to receive(:exec_editor)

View File

@ -473,7 +473,6 @@ describe Cask::DSL, :cask do
end end
it "does not include a trailing slash" do it "does not include a trailing slash" do
begin
original_appdir = Cask::Config.global.appdir original_appdir = Cask::Config.global.appdir
Cask::Config.global.appdir = "#{original_appdir}/" Cask::Config.global.appdir = "#{original_appdir}/"
@ -486,7 +485,6 @@ describe Cask::DSL, :cask do
Cask::Config.global.appdir = original_appdir Cask::Config.global.appdir = original_appdir
end end
end end
end
describe "#artifacts" do describe "#artifacts" do
it "sorts artifacts according to the preferable installation order" do it "sorts artifacts according to the preferable installation order" do

View File

@ -34,7 +34,6 @@ describe Homebrew::Cleanup do
let(:lock_file) { Pathname.new("#{HOMEBREW_LOCKS}/foo") } let(:lock_file) { Pathname.new("#{HOMEBREW_LOCKS}/foo") }
around do |example| around do |example|
begin
FileUtils.touch ds_store FileUtils.touch ds_store
FileUtils.touch lock_file FileUtils.touch lock_file
@ -43,7 +42,6 @@ describe Homebrew::Cleanup do
FileUtils.rm_f ds_store FileUtils.rm_f ds_store
FileUtils.rm_f lock_file FileUtils.rm_f lock_file
end end
end
describe "::cleanup" do describe "::cleanup" do
it "removes .DS_Store and lock files" do it "removes .DS_Store and lock files" do

View File

@ -33,7 +33,6 @@ RSpec.shared_context "custom internal commands" do
end end
around do |example| around do |example|
begin
cmds.each do |f| cmds.each do |f|
FileUtils.touch f FileUtils.touch f
end end
@ -43,7 +42,6 @@ RSpec.shared_context "custom internal commands" do
FileUtils.rm_f cmds FileUtils.rm_f cmds
end end
end end
end
describe Homebrew do describe Homebrew do
include_context "custom internal commands" include_context "custom internal commands"

View File

@ -9,7 +9,6 @@ end
describe "brew style" do describe "brew style" do
around do |example| around do |example|
begin
FileUtils.ln_s HOMEBREW_LIBRARY_PATH, HOMEBREW_LIBRARY/"Homebrew" FileUtils.ln_s HOMEBREW_LIBRARY_PATH, HOMEBREW_LIBRARY/"Homebrew"
FileUtils.ln_s HOMEBREW_LIBRARY_PATH.parent/".rubocop.yml", HOMEBREW_LIBRARY/".rubocop_audit.yml" FileUtils.ln_s HOMEBREW_LIBRARY_PATH.parent/".rubocop.yml", HOMEBREW_LIBRARY/".rubocop_audit.yml"
FileUtils.ln_s HOMEBREW_LIBRARY_PATH.parent/".rubocop_shared.yml", HOMEBREW_LIBRARY/".rubocop_shared.yml" FileUtils.ln_s HOMEBREW_LIBRARY_PATH.parent/".rubocop_shared.yml", HOMEBREW_LIBRARY/".rubocop_shared.yml"
@ -20,7 +19,6 @@ describe "brew style" do
FileUtils.rm_f HOMEBREW_LIBRARY/".rubocop_audit.yml" FileUtils.rm_f HOMEBREW_LIBRARY/".rubocop_audit.yml"
FileUtils.rm_f HOMEBREW_LIBRARY/".rubocop_shared.yml" FileUtils.rm_f HOMEBREW_LIBRARY/".rubocop_shared.yml"
end end
end
before do before do
allow(Homebrew).to receive(:install_bundler_gems!) allow(Homebrew).to receive(:install_bundler_gems!)

View File

@ -73,7 +73,6 @@ describe Homebrew::Diagnostic::Checks do
end end
specify "#check_user_path_3" do specify "#check_user_path_3" do
begin
sbin = HOMEBREW_PREFIX/"sbin" sbin = HOMEBREW_PREFIX/"sbin"
ENV["HOMEBREW_PATH"] = ENV["HOMEBREW_PATH"] =
"#{HOMEBREW_PREFIX}/bin#{File::PATH_SEPARATOR}" + "#{HOMEBREW_PREFIX}/bin#{File::PATH_SEPARATOR}" +
@ -87,7 +86,6 @@ describe Homebrew::Diagnostic::Checks do
ensure ensure
sbin.rmtree sbin.rmtree
end end
end
specify "#check_for_config_scripts" do specify "#check_for_config_scripts" do
mktmpdir do |path| mktmpdir do |path|
@ -103,7 +101,6 @@ describe Homebrew::Diagnostic::Checks do
end end
specify "#check_for_symlinked_cellar" do specify "#check_for_symlinked_cellar" do
begin
HOMEBREW_CELLAR.rmtree HOMEBREW_CELLAR.rmtree
mktmpdir do |path| mktmpdir do |path|
@ -115,7 +112,6 @@ describe Homebrew::Diagnostic::Checks do
HOMEBREW_CELLAR.unlink HOMEBREW_CELLAR.unlink
HOMEBREW_CELLAR.mkpath HOMEBREW_CELLAR.mkpath
end end
end
specify "#check_ld_vars catches LD vars" do specify "#check_ld_vars catches LD vars" do
ENV["LD_LIBRARY_PATH"] = "foo" ENV["LD_LIBRARY_PATH"] = "foo"

View File

@ -1266,7 +1266,6 @@ describe Formula do
let(:testball_repo) { HOMEBREW_PREFIX/"testball_repo" } let(:testball_repo) { HOMEBREW_PREFIX/"testball_repo" }
example do example do
begin
outdated_stable_prefix = HOMEBREW_CELLAR/"testball/1.0" outdated_stable_prefix = HOMEBREW_CELLAR/"testball/1.0"
head_prefix_a = HOMEBREW_CELLAR/"testball/HEAD" head_prefix_a = HOMEBREW_CELLAR/"testball/HEAD"
head_prefix_b = HOMEBREW_CELLAR/"testball/HEAD-aaaaaaa_1" head_prefix_b = HOMEBREW_CELLAR/"testball/HEAD-aaaaaaa_1"
@ -1303,7 +1302,6 @@ describe Formula do
testball_repo.rmtree if testball_repo.exist? testball_repo.rmtree if testball_repo.exist?
end end
end end
end
describe "#mkdir" do describe "#mkdir" do
let(:dst) { mktmpdir } let(:dst) { mktmpdir }

View File

@ -217,11 +217,9 @@ RSpec::Matchers.alias_matcher :a_string_containing, :include
RSpec::Matchers.define :a_json_string do RSpec::Matchers.define :a_json_string do
match do |actual| match do |actual|
begin
JSON.parse(actual) JSON.parse(actual)
true true
rescue JSON::ParserError rescue JSON::ParserError
false false
end end
end end
end

View File

@ -66,10 +66,8 @@ end
RSpec.configure do |config| RSpec.configure do |config|
config.after do config.after do
begin
FakeSystemCommand.verify_expectations! FakeSystemCommand.verify_expectations!
ensure ensure
FakeSystemCommand.clear FakeSystemCommand.clear
end end
end end
end

View File

@ -41,7 +41,6 @@ RSpec.shared_context "integration test" do
end end
around do |example| around do |example|
begin
(HOMEBREW_PREFIX/"bin").mkpath (HOMEBREW_PREFIX/"bin").mkpath
FileUtils.touch HOMEBREW_PREFIX/"bin/brew" FileUtils.touch HOMEBREW_PREFIX/"bin/brew"
@ -49,7 +48,6 @@ RSpec.shared_context "integration test" do
ensure ensure
FileUtils.rm_r HOMEBREW_PREFIX/"bin" FileUtils.rm_r HOMEBREW_PREFIX/"bin"
end end
end
# Generate unique ID to be able to # Generate unique ID to be able to
# properly merge coverage results. # properly merge coverage results.
@ -94,12 +92,10 @@ RSpec.shared_context "integration test" do
simplecov_spec = Gem.loaded_specs["simplecov"] simplecov_spec = Gem.loaded_specs["simplecov"]
specs = [simplecov_spec] specs = [simplecov_spec]
simplecov_spec.runtime_dependencies.each do |dep| simplecov_spec.runtime_dependencies.each do |dep|
begin
specs += dep.to_specs specs += dep.to_specs
rescue Gem::LoadError => e rescue Gem::LoadError => e
onoe e onoe e
end end
end
libs = specs.flat_map do |spec| libs = specs.flat_map do |spec|
full_gem_path = spec.full_gem_path full_gem_path = spec.full_gem_path
# full_require_paths isn't available in RubyGems < 2.2. # full_require_paths isn't available in RubyGems < 2.2.

View File

@ -267,14 +267,12 @@ describe SystemCommand do
it "does not leak the secrets set by environment" do it "does not leak the secrets set by environment" do
redacted_msg = /#{Regexp.escape("username:******")}/ redacted_msg = /#{Regexp.escape("username:******")}/
expect do expect do
begin
ENV["PASSWORD"] = "hunter2" ENV["PASSWORD"] = "hunter2"
described_class.run! "curl", described_class.run! "curl",
args: %w[--user username:hunter2], args: %w[--user username:hunter2],
verbose: true verbose: true
ensure ensure
ENV.delete "PASSWORD" ENV.delete "PASSWORD"
end
end.to raise_error.with_message(redacted_msg).and output(redacted_msg).to_stdout end.to raise_error.with_message(redacted_msg).and output(redacted_msg).to_stdout
end end
end end

View File

@ -61,7 +61,6 @@ describe Tap do
end end
specify "::fetch" do specify "::fetch" do
begin
expect(described_class.fetch("Homebrew", "core")).to be_kind_of(CoreTap) expect(described_class.fetch("Homebrew", "core")).to be_kind_of(CoreTap)
expect(described_class.fetch("Homebrew", "homebrew")).to be_kind_of(CoreTap) expect(described_class.fetch("Homebrew", "homebrew")).to be_kind_of(CoreTap)
tap = described_class.fetch("Homebrew", "foo") tap = described_class.fetch("Homebrew", "foo")
@ -82,7 +81,6 @@ describe Tap do
ensure ensure
described_class.clear_cache described_class.clear_cache
end end
end
describe "::from_path" do describe "::from_path" do
let(:tap) { described_class.fetch("Homebrew", "core") } let(:tap) { described_class.fetch("Homebrew", "core") }
@ -113,7 +111,6 @@ describe Tap do
end end
specify "#issues_url" do specify "#issues_url" do
begin
t = described_class.new("someone", "foo") t = described_class.new("someone", "foo")
path = Tap::TAP_DIRECTORY/"someone/homebrew-foo" path = Tap::TAP_DIRECTORY/"someone/homebrew-foo"
path.mkpath path.mkpath
@ -130,7 +127,6 @@ describe Tap do
ensure ensure
path.parent.rmtree path.parent.rmtree
end end
end
specify "files" do specify "files" do
setup_tap_files setup_tap_files
@ -272,7 +268,6 @@ describe Tap do
end end
specify "#install and #uninstall" do specify "#install and #uninstall" do
begin
setup_tap_files setup_tap_files
setup_git_repo setup_git_repo
@ -297,10 +292,8 @@ describe Tap do
(HOMEBREW_PREFIX/"etc").rmtree if (HOMEBREW_PREFIX/"etc").exist? (HOMEBREW_PREFIX/"etc").rmtree if (HOMEBREW_PREFIX/"etc").exist?
(HOMEBREW_PREFIX/"share").rmtree if (HOMEBREW_PREFIX/"share").exist? (HOMEBREW_PREFIX/"share").rmtree if (HOMEBREW_PREFIX/"share").exist?
end end
end
specify "#link_completions_and_manpages" do specify "#link_completions_and_manpages" do
begin
setup_tap_files setup_tap_files
setup_git_repo setup_git_repo
tap = described_class.new("Homebrew", "baz") tap = described_class.new("Homebrew", "baz")
@ -319,7 +312,6 @@ describe Tap do
(HOMEBREW_PREFIX/"etc").rmtree if (HOMEBREW_PREFIX/"etc").exist? (HOMEBREW_PREFIX/"etc").rmtree if (HOMEBREW_PREFIX/"etc").exist?
(HOMEBREW_PREFIX/"share").rmtree if (HOMEBREW_PREFIX/"share").exist? (HOMEBREW_PREFIX/"share").rmtree if (HOMEBREW_PREFIX/"share").exist?
end end
end
specify "#pin and #unpin" do specify "#pin and #unpin" do
expect(subject).not_to be_pinned expect(subject).not_to be_pinned

View File

@ -50,7 +50,6 @@ module Homebrew
method = instance_method(name) method = instance_method(name)
define_method(name) do |*args, &block| define_method(name) do |*args, &block|
begin
time = Time.now time = Time.now
method.bind(self).call(*args, &block) method.bind(self).call(*args, &block)
ensure ensure
@ -59,7 +58,6 @@ module Homebrew
end end
end end
end end
end
return unless $times.nil? return unless $times.nil?
@ -388,11 +386,9 @@ module Kernel
def paths def paths
@paths ||= PATH.new(ENV["HOMEBREW_PATH"]).map do |p| @paths ||= PATH.new(ENV["HOMEBREW_PATH"]).map do |p|
begin
File.expand_path(p).chomp("/") File.expand_path(p).chomp("/")
rescue ArgumentError rescue ArgumentError
onoe "The following PATH component is invalid: #{p}" onoe "The following PATH component is invalid: #{p}"
end
end.uniq.compact end.uniq.compact
end end

View File

@ -32,7 +32,6 @@ module Utils
read, write = IO.pipe read, write = IO.pipe
pid = fork do pid = fork do
begin
ENV["HOMEBREW_ERROR_PIPE"] = server.path ENV["HOMEBREW_ERROR_PIPE"] = server.path
server.close server.close
read.close read.close
@ -57,7 +56,6 @@ module Utils
else else
exit!(true) exit!(true)
end end
end
ignore_interrupts(:quietly) do # the child will receive the interrupt and marshal it back ignore_interrupts(:quietly) do # the child will receive the interrupt and marshal it back
begin begin