diff options
| author | Mike McQuaid | 2016-09-18 13:28:15 +0100 |
|---|---|---|
| committer | GitHub | 2016-09-18 13:28:15 +0100 |
| commit | 59b7f16bfd9c1968aae0a2f1cd9a43d3d160d99f (patch) | |
| tree | 17d2adec882cdeef36a8fd40d891fe7fe4021572 /Library | |
| parent | 56541001a45ea58c54096bc42584c17d72b1415a (diff) | |
| parent | 1bdbb0f462e4c3557bbcba0b203696bdcf025bb4 (diff) | |
| download | brew-59b7f16bfd9c1968aae0a2f1cd9a43d3d160d99f.tar.bz2 | |
Merge pull request #989 from MikeMcQuaid/rubocop-final
Rubocop: apply auto-corrections and don't use hash-rockets
Diffstat (limited to 'Library')
109 files changed, 827 insertions, 536 deletions
diff --git a/Library/.rubocop.yml b/Library/.rubocop.yml index 343362d62..33277ac7c 100644 --- a/Library/.rubocop.yml +++ b/Library/.rubocop.yml @@ -1,14 +1,12 @@ +inherit_from: .rubocop_todo.yml + AllCops: + TargetRubyVersion: 2.0 Exclude: + - 'Homebrew/cask/**/*' - 'Homebrew/vendor/**/*' - 'Homebrew/test/vendor/**/*' -# Whilst we now can handle the newer hash syntax of 1.9+ the -# hash rockets are everywhere & it'd be good to change this more -# consistently than piecemeal. -Style/HashSyntax: - EnforcedStyle: hash_rockets - # ruby style guide favorite Style/StringLiterals: EnforcedStyle: double_quotes diff --git a/Library/.rubocop_todo.yml b/Library/.rubocop_todo.yml new file mode 100644 index 000000000..18b69e207 --- /dev/null +++ b/Library/.rubocop_todo.yml @@ -0,0 +1,259 @@ +# This configuration was generated by +# `rubocop --auto-gen-config` +# on 2016-09-17 15:44:31 +0100 using RuboCop version 0.42.0. +# The point is for the user to remove these configuration records +# one by one as the offenses are removed from the code base. +# Note that changes in the inspected code, or installation of new +# versions of RuboCop, may require this file to be generated again. + +# Offense count: 4 +# Cop supports --auto-correct. +# Configuration parameters: AlignWith, SupportedStyles, AutoCorrect. +# SupportedStyles: keyword, variable, start_of_line +Lint/EndAlignment: + Exclude: + - 'Homebrew/download_strategy.rb' + - 'Homebrew/keg.rb' + - 'Homebrew/os/mac/cctools_mach.rb' + +# Offense count: 18 +Lint/HandleExceptions: + Exclude: + - 'Homebrew/cmd/install.rb' + - 'Homebrew/cmd/reinstall.rb' + - 'Homebrew/cmd/tap.rb' + - 'Homebrew/cmd/update-report.rb' + - 'Homebrew/cmd/upgrade.rb' + - 'Homebrew/cmd/uses.rb' + - 'Homebrew/descriptions.rb' + - 'Homebrew/dev-cmd/test-bot.rb' + - 'Homebrew/diagnostic.rb' + - 'Homebrew/extend/ENV/super.rb' + - 'Homebrew/extend/pathname.rb' + - 'Homebrew/formula.rb' + - 'Homebrew/formula_versions.rb' + - 'Homebrew/test/test_ENV.rb' + +# Offense count: 3 +Lint/IneffectiveAccessModifier: + Exclude: + - 'Homebrew/formula.rb' + - 'Homebrew/version.rb' + +# Offense count: 1 +Lint/Loop: + Exclude: + - 'Homebrew/patch.rb' + +# Offense count: 6 +Lint/NestedMethodDefinition: + Exclude: + - 'Homebrew/dev-cmd/bottle.rb' + - 'Homebrew/dev-cmd/test-bot.rb' + +# Offense count: 2 +Lint/NonLocalExitFromIterator: + Exclude: + - 'Homebrew/extend/pathname.rb' + +# Offense count: 28 +Lint/RescueException: + Enabled: false + +# Offense count: 1 +Lint/ShadowedException: + Exclude: + - 'Homebrew/brew.rb' + +# Offense count: 2 +Lint/UselessAssignment: + Exclude: + - 'Homebrew/requirements.rb' + +# Offense count: 18 +Metrics/BlockNesting: + Max: 5 + +# Offense count: 20 +# Configuration parameters: CountComments. +Metrics/ModuleLength: + Max: 369 + +# Offense count: 1 +# Configuration parameters: CountKeywordArgs. +Metrics/ParameterLists: + Max: 6 + +# Offense count: 2 +Performance/FixedSize: + Exclude: + - 'Homebrew/dev-cmd/audit.rb' + - 'Homebrew/dev-cmd/bottle.rb' + +# Offense count: 8 +Style/AccessorMethodName: + Exclude: + - 'Homebrew/download_strategy.rb' + - 'Homebrew/extend/ENV/std.rb' + - 'Homebrew/formula.rb' + - 'Homebrew/formula_lock.rb' + - 'Homebrew/formulary.rb' + - 'Homebrew/migrator.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, SupportedStyles. +# SupportedStyles: prefer_alias, prefer_alias_method +Style/Alias: + Exclude: + - 'Homebrew/blacklist.rb' + +# Offense count: 26 +Style/CaseEquality: + Enabled: false + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: IndentWhenRelativeTo, SupportedStyles, IndentOneStep, IndentationWidth. +# SupportedStyles: case, end +Style/CaseIndentation: + Exclude: + - 'Homebrew/keg.rb' + +# Offense count: 11 +Style/ClassVars: + Exclude: + - 'Homebrew/cleanup.rb' + - 'Homebrew/dev-cmd/audit.rb' + - 'Homebrew/dev-cmd/test-bot.rb' + - 'Homebrew/formula_installer.rb' + - 'Homebrew/test/testing_env.rb' + - 'Homebrew/utils.rb' + +# Offense count: 1 +Style/ConstantName: + Exclude: + - 'Homebrew/os/mac.rb' + +# Offense count: 10 +Style/DoubleNegation: + Exclude: + - 'Homebrew/extend/ARGV.rb' + - 'Homebrew/formula_installer.rb' + - 'Homebrew/os/mac/cctools_keg.rb' + - 'Homebrew/os/mac/ruby_keg.rb' + - 'Homebrew/os/mac/xcode.rb' + - 'Homebrew/requirement.rb' + - 'Homebrew/software_spec.rb' + +# Offense count: 1 +# Configuration parameters: EnforcedStyle, SupportedStyles. +# SupportedStyles: format, sprintf, percent +Style/FormatString: + Exclude: + - 'Homebrew/formula.rb' + +# Offense count: 13 +# Configuration parameters: AllowedVariables. +Style/GlobalVars: + Exclude: + - 'Homebrew/diagnostic.rb' + - 'Homebrew/utils.rb' + +# Offense count: 2 +Style/IdenticalConditionalBranches: + Exclude: + - 'Homebrew/formula_lock.rb' + +# Offense count: 5 +# Configuration parameters: EnforcedStyle, SupportedStyles. +# SupportedStyles: snake_case, camelCase +Style/MethodName: + Exclude: + - 'Homebrew/cleanup.rb' + - 'Homebrew/diagnostic.rb' + - 'Homebrew/formula_cellar_checks.rb' + - 'Homebrew/formula_installer.rb' + - 'Homebrew/os/mac/cctools_mach.rb' + +# Offense count: 7 +# Configuration parameters: EnforcedStyle, SupportedStyles. +# SupportedStyles: module_function, extend_self +Style/ModuleFunction: + Exclude: + - 'Homebrew/global.rb' + - 'Homebrew/os/mac.rb' + - 'Homebrew/os/mac/xcode.rb' + - 'Homebrew/os/mac/xquartz.rb' + - 'Homebrew/utils/github.rb' + - 'Homebrew/utils/json.rb' + +# Offense count: 8 +Style/MultilineBlockChain: + Exclude: + - 'Homebrew/cmd/search.rb' + - 'Homebrew/dev-cmd/aspell-dictionaries.rb' + - 'Homebrew/dev-cmd/audit.rb' + - 'Homebrew/dev-cmd/man.rb' + - 'Homebrew/diagnostic.rb' + - 'Homebrew/test/test_patching.rb' + +# Offense count: 4 +# Cop supports --auto-correct. +Style/MutableConstant: + Exclude: + - 'Homebrew/dependency_collector.rb' + - 'Homebrew/formulary.rb' + - 'Homebrew/tab.rb' + - 'Homebrew/tap.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, MinBodyLength, SupportedStyles. +# SupportedStyles: skip_modifier_ifs, always +Style/Next: + Exclude: + - 'Homebrew/dev-cmd/test-bot.rb' + +# Offense count: 9 +Style/OpMethod: + Exclude: + - 'Homebrew/compilers.rb' + - 'Homebrew/dependencies.rb' + - 'Homebrew/install_renamed.rb' + - 'Homebrew/options.rb' + +# Offense count: 4 +# Configuration parameters: NamePrefix, NamePrefixBlacklist, NameWhitelist. +# NamePrefix: is_, has_, have_ +# NamePrefixBlacklist: is_, has_, have_ +# NameWhitelist: is_a? +Style/PredicateName: + Exclude: + - 'spec/**/*' + - 'Homebrew/download_strategy.rb' + - 'Homebrew/hardware.rb' + +# Offense count: 7 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, SupportedStyles, AllowInnerSlashes. +# SupportedStyles: slashes, percent_r, mixed +Style/RegexpLiteral: + Exclude: + - 'Homebrew/diagnostic.rb' + - 'Homebrew/keg.rb' + - 'Homebrew/version.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: AllowAsExpressionSeparator. +Style/Semicolon: + Exclude: + - 'Homebrew/descriptions.rb' + +# Offense count: 1 +# Configuration parameters: Methods. +# Methods: {"reduce"=>["a", "e"]}, {"inject"=>["a", "e"]} +Style/SingleLineBlockParams: + Exclude: + - 'Homebrew/diagnostic.rb' diff --git a/Library/Homebrew/brew.rb b/Library/Homebrew/brew.rb index b177569d1..eeadc70e1 100644 --- a/Library/Homebrew/brew.rb +++ b/Library/Homebrew/brew.rb @@ -83,7 +83,7 @@ begin # arguments themselves. if empty_argv || help_flag require "cmd/help" - Homebrew.help cmd, :empty_argv => empty_argv + Homebrew.help cmd, empty_argv: empty_argv # `Homebrew.help` never returns, except for external/unknown commands. end @@ -125,7 +125,7 @@ begin rescue UsageError => e require "cmd/help" - Homebrew.help cmd, :usage_error => e.message + Homebrew.help cmd, usage_error: e.message rescue SystemExit => e onoe "Kernel.exit" if ARGV.verbose? && !e.success? $stderr.puts e.backtrace if ARGV.debug? diff --git a/Library/Homebrew/build.rb b/Library/Homebrew/build.rb index a015f158c..f4dde895a 100644 --- a/Library/Homebrew/build.rb +++ b/Library/Homebrew/build.rb @@ -157,7 +157,7 @@ class Build # The stdlib recorded in the install receipt is used during dependency # compatibility checks, so we only care about the stdlib that libraries # link against. - keg.detect_cxx_stdlibs(:skip_executables => true) + keg.detect_cxx_stdlibs(skip_executables: true) end def fixopt(f) diff --git a/Library/Homebrew/build_environment.rb b/Library/Homebrew/build_environment.rb index 05ac9a43e..b66aafcdf 100644 --- a/Library/Homebrew/build_environment.rb +++ b/Library/Homebrew/build_environment.rb @@ -43,7 +43,8 @@ module Homebrew HOMEBREW_SVN HOMEBREW_GIT HOMEBREW_SDKROOT HOMEBREW_BUILD_FROM_SOURCE MAKE GIT CPP - ACLOCAL_PATH PATH CPATH].select { |key| env.key?(key) } + ACLOCAL_PATH PATH CPATH + ].select { |key| env.key?(key) } end def dump_build_env(env, f = $stdout) diff --git a/Library/Homebrew/caveats.rb b/Library/Homebrew/caveats.rb index b71596b2b..9c1787f87 100644 --- a/Library/Homebrew/caveats.rb +++ b/Library/Homebrew/caveats.rb @@ -8,9 +8,10 @@ class Caveats def caveats caveats = [] begin - build, f.build = f.build, Tab.for_formula(f) + build = f.build + f.build = Tab.for_formula(f) s = f.caveats.to_s - caveats << s.chomp + "\n" if s.length > 0 + caveats << s.chomp + "\n" unless s.empty? ensure f.build = build end @@ -33,7 +34,11 @@ class Caveats def keg @keg ||= [f.prefix, f.opt_prefix, f.linked_keg].map do |d| - Keg.new(d.resolved_path) rescue nil + begin + Keg.new(d.resolved_path) + rescue + nil + end end.compact.first end diff --git a/Library/Homebrew/checksum.rb b/Library/Homebrew/checksum.rb index 1197609b1..6be454efb 100644 --- a/Library/Homebrew/checksum.rb +++ b/Library/Homebrew/checksum.rb @@ -2,7 +2,7 @@ class Checksum attr_reader :hash_type, :hexdigest alias_method :to_s, :hexdigest - TYPES = [:sha256] + TYPES = [:sha256].freeze def initialize(hash_type, hexdigest) @hash_type = hash_type diff --git a/Library/Homebrew/cleanup.rb b/Library/Homebrew/cleanup.rb index 41c4bbf34..265f06d26 100644 --- a/Library/Homebrew/cleanup.rb +++ b/Library/Homebrew/cleanup.rb @@ -33,7 +33,7 @@ module Homebrew def self.cleanup_logs return unless HOMEBREW_LOGS.directory? HOMEBREW_LOGS.subdirs.each do |dir| - cleanup_path(dir) { dir.rmtree } if prune?(dir, :days_default => 14) + cleanup_path(dir) { dir.rmtree } if prune?(dir, days_default: 14) end end @@ -43,7 +43,7 @@ module Homebrew end end - def self.cleanup_cache(cache=HOMEBREW_CACHE) + def self.cleanup_cache(cache = HOMEBREW_CACHE) return unless cache.directory? cache.children.each do |path| if path.to_s.end_with? ".incomplete" @@ -67,7 +67,11 @@ module Homebrew file = path if Pathname::BOTTLE_EXTNAME_RX === file.to_s - version = Utils::Bottles.resolve_version(file) rescue file.version + version = begin + Utils::Bottles.resolve_version(file) + rescue + file.version + end else version = file.version end @@ -88,7 +92,7 @@ module Homebrew f.version > version end - if file_is_stale || ARGV.switch?("s") && !f.installed? || Utils::Bottles::file_outdated?(f, file) + if file_is_stale || ARGV.switch?("s") && !f.installed? || Utils::Bottles.file_outdated?(f, file) cleanup_path(file) { file.unlink } end end @@ -117,8 +121,8 @@ module Homebrew def self.rm_DS_Store paths = Queue.new - %w[Cellar Frameworks Library bin etc include lib opt sbin share var]. - map { |p| HOMEBREW_PREFIX/p }.each { |p| paths << p if p.exist? } + %w[Cellar Frameworks Library bin etc include lib opt sbin share var] + .map { |p| HOMEBREW_PREFIX/p }.each { |p| paths << p if p.exist? } workers = (0...Hardware::CPU.cores).map do Thread.new do Kernel.loop do diff --git a/Library/Homebrew/cmd/deps.rb b/Library/Homebrew/cmd/deps.rb index 8db70461e..acaf922d7 100644 --- a/Library/Homebrew/cmd/deps.rb +++ b/Library/Homebrew/cmd/deps.rb @@ -44,11 +44,11 @@ require "ostruct" module Homebrew def deps mode = OpenStruct.new( - :installed? => ARGV.include?("--installed"), - :tree? => ARGV.include?("--tree"), - :all? => ARGV.include?("--all"), - :topo_order? => ARGV.include?("-n"), - :union? => ARGV.include?("--union") + installed?: ARGV.include?("--installed"), + tree?: ARGV.include?("--tree"), + all?: ARGV.include?("--all"), + topo_order?: ARGV.include?("-n"), + union?: ARGV.include?("--union") ) if mode.installed? && mode.tree? diff --git a/Library/Homebrew/cmd/fetch.rb b/Library/Homebrew/cmd/fetch.rb index fd8b0780c..93141ca5b 100644 --- a/Library/Homebrew/cmd/fetch.rb +++ b/Library/Homebrew/cmd/fetch.rb @@ -40,7 +40,7 @@ module Homebrew puts "Fetching: #{bucket * ", "}" if bucket.size > 1 bucket.each do |f| - f.print_tap_action :verb => "Fetching" + f.print_tap_action verb: "Fetching" fetched_bottle = false if fetch_bottle?(f) diff --git a/Library/Homebrew/cmd/gist-logs.rb b/Library/Homebrew/cmd/gist-logs.rb index 2c60129d1..200ad9fb5 100644 --- a/Library/Homebrew/cmd/gist-logs.rb +++ b/Library/Homebrew/cmd/gist-logs.rb @@ -23,16 +23,16 @@ module Homebrew s = StringIO.new SystemConfig.dump_verbose_config s # Dummy summary file, asciibetically first, to control display title of gist - files["# #{f.name} - #{timestamp}.txt"] = { :content => brief_build_info(f) } - files["00.config.out"] = { :content => s.string } - files["00.doctor.out"] = { :content => `brew doctor 2>&1` } + files["# #{f.name} - #{timestamp}.txt"] = { content: brief_build_info(f) } + files["00.config.out"] = { content: s.string } + files["00.doctor.out"] = { content: `brew doctor 2>&1` } unless f.core_formula? tap = <<-EOS.undent Formula: #{f.name} Tap: #{f.tap} Path: #{f.path} EOS - files["00.tap.out"] = { :content => tap } + files["00.tap.out"] = { content: tap } end # Description formatted to work well as page title when viewing gist @@ -93,8 +93,8 @@ module Homebrew contents = file.size? ? file.read : "empty log" # small enough to avoid GitHub "unicorn" page-load-timeout errors max_file_size = 1_000_000 - contents = truncate_text_to_approximate_size(contents, max_file_size, :front_weight => 0.2) - logs[file.basename.to_s] = { :content => contents } + contents = truncate_text_to_approximate_size(contents, max_file_size, front_weight: 0.2) + logs[file.basename.to_s] = { content: contents } end if dir.exist? raise "No logs." if logs.empty? logs diff --git a/Library/Homebrew/cmd/linkapps.rb b/Library/Homebrew/cmd/linkapps.rb index 6659ce256..a4e4326f2 100644 --- a/Library/Homebrew/cmd/linkapps.rb +++ b/Library/Homebrew/cmd/linkapps.rb @@ -12,7 +12,7 @@ require "formula" module Homebrew def linkapps - target_dir = linkapps_target(:local => ARGV.include?("--local")) + target_dir = linkapps_target(local: ARGV.include?("--local")) unless target_dir.directory? opoo "#{target_dir} does not exist, stopping." diff --git a/Library/Homebrew/cmd/outdated.rb b/Library/Homebrew/cmd/outdated.rb index e421b2481..7afa41df4 100644 --- a/Library/Homebrew/cmd/outdated.rb +++ b/Library/Homebrew/cmd/outdated.rb @@ -39,11 +39,11 @@ module Homebrew verbose = ($stdout.tty? || ARGV.verbose?) && !ARGV.flag?("--quiet") fetch_head = ARGV.fetch_head? - outdated_formulae = formulae.select { |f| f.outdated?(:fetch_head => fetch_head) } + outdated_formulae = formulae.select { |f| f.outdated?(fetch_head: fetch_head) } outdated_formulae.each do |f| if verbose - outdated_versions = f.outdated_versions(:fetch_head => fetch_head) + outdated_versions = f.outdated_versions(fetch_head: fetch_head) current_version = if f.head? && outdated_versions.any? { |v| v.to_s == f.pkg_version.to_s } "latest HEAD" else @@ -59,19 +59,19 @@ module Homebrew def print_outdated_json(formulae) json = [] fetch_head = ARGV.fetch_head? - outdated_formulae = formulae.select { |f| f.outdated?(:fetch_head => fetch_head) } + outdated_formulae = formulae.select { |f| f.outdated?(fetch_head: fetch_head) } outdated = outdated_formulae.each do |f| - outdated_versions = f.outdated_versions(:fetch_head => fetch_head) + outdated_versions = f.outdated_versions(fetch_head: fetch_head) current_version = if f.head? && outdated_versions.any? { |v| v.to_s == f.pkg_version.to_s } "HEAD" else f.pkg_version.to_s end - json << { :name => f.full_name, - :installed_versions => outdated_versions.collect(&:to_s), - :current_version => current_version } + json << { name: f.full_name, + installed_versions: outdated_versions.collect(&:to_s), + current_version: current_version } end puts Utils::JSON.dump(json) diff --git a/Library/Homebrew/cmd/prune.rb b/Library/Homebrew/cmd/prune.rb index 20c2a3454..83979064a 100644 --- a/Library/Homebrew/cmd/prune.rb +++ b/Library/Homebrew/cmd/prune.rb @@ -58,6 +58,6 @@ module Homebrew end end - unlinkapps_prune(:dry_run => ARGV.dry_run?, :quiet => true) + unlinkapps_prune(dry_run: ARGV.dry_run?, quiet: true) end end diff --git a/Library/Homebrew/cmd/readall.rb b/Library/Homebrew/cmd/readall.rb index 132472b70..e77e68865 100644 --- a/Library/Homebrew/cmd/readall.rb +++ b/Library/Homebrew/cmd/readall.rb @@ -25,7 +25,7 @@ module Homebrew Homebrew.failed = true unless Readall.valid_ruby_syntax?(ruby_files) end - options = { :aliases => ARGV.include?("--aliases") } + options = { aliases: ARGV.include?("--aliases") } taps = if ARGV.named.empty? Tap else diff --git a/Library/Homebrew/cmd/style.rb b/Library/Homebrew/cmd/style.rb index 61e2b7908..9540e853d 100644 --- a/Library/Homebrew/cmd/style.rb +++ b/Library/Homebrew/cmd/style.rb @@ -30,7 +30,7 @@ module Homebrew ARGV.formulae.map(&:path) end - Homebrew.failed = check_style_and_print(target, :fix => ARGV.flag?("--fix")) + Homebrew.failed = check_style_and_print(target, fix: ARGV.flag?("--fix")) end # Checks style for a list of files, printing simple RuboCop output. diff --git a/Library/Homebrew/cmd/tap.rb b/Library/Homebrew/cmd/tap.rb index 49d278b7a..8ad63e4ba 100644 --- a/Library/Homebrew/cmd/tap.rb +++ b/Library/Homebrew/cmd/tap.rb @@ -47,9 +47,9 @@ module Homebrew else tap = Tap.fetch(ARGV.named[0]) begin - tap.install :clone_target => ARGV.named[1], - :full_clone => full_clone?, - :quiet => ARGV.quieter? + tap.install clone_target: ARGV.named[1], + full_clone: full_clone?, + quiet: ARGV.quieter? rescue TapRemoteMismatchError => e odie e rescue TapAlreadyTappedError, TapAlreadyUnshallowError @@ -67,7 +67,7 @@ module Homebrew opoo "Homebrew.install_tap is deprecated, use Tap#install." tap = Tap.fetch(user, repo) begin - tap.install(:clone_target => clone_target, :full_clone => full_clone?) + tap.install(clone_target: clone_target, full_clone: full_clone?) rescue TapAlreadyTappedError false else diff --git a/Library/Homebrew/cmd/unlinkapps.rb b/Library/Homebrew/cmd/unlinkapps.rb index 44b8aa06c..fc53470ec 100644 --- a/Library/Homebrew/cmd/unlinkapps.rb +++ b/Library/Homebrew/cmd/unlinkapps.rb @@ -13,17 +13,17 @@ require "cmd/linkapps" module Homebrew def unlinkapps - target_dir = linkapps_target(:local => ARGV.include?("--local")) + target_dir = linkapps_target(local: ARGV.include?("--local")) - unlinkapps_from_dir(target_dir, :dry_run => ARGV.dry_run?) + unlinkapps_from_dir(target_dir, dry_run: ARGV.dry_run?) end private def unlinkapps_prune(opts = {}) - opts = opts.merge(:prune => true) - unlinkapps_from_dir(linkapps_target(:local => false), opts) - unlinkapps_from_dir(linkapps_target(:local => true), opts) + opts = opts.merge(prune: true) + unlinkapps_from_dir(linkapps_target(local: false), opts) + unlinkapps_from_dir(linkapps_target(local: true), opts) end def unlinkapps_from_dir(target_dir, opts = {}) diff --git a/Library/Homebrew/cmd/unpack.rb b/Library/Homebrew/cmd/unpack.rb index a8c7c36a6..1a3044c2e 100644 --- a/Library/Homebrew/cmd/unpack.rb +++ b/Library/Homebrew/cmd/unpack.rb @@ -39,7 +39,7 @@ module Homebrew ENV["VERBOSE"] = "1" # show messages about tar f.brew do f.patch if ARGV.flag?("--patch") - cp_r getwd, stage_dir, :preserve => true + cp_r getwd, stage_dir, preserve: true end ENV["VERBOSE"] = nil diff --git a/Library/Homebrew/cmd/update-report.rb b/Library/Homebrew/cmd/update-report.rb index d97a0275e..ddbb9bd90 100644 --- a/Library/Homebrew/cmd/update-report.rb +++ b/Library/Homebrew/cmd/update-report.rb @@ -109,7 +109,7 @@ module Homebrew def install_core_tap_if_necessary core_tap = CoreTap.instance return if core_tap.installed? - CoreTap.ensure_installed! :quiet => false + CoreTap.ensure_installed! quiet: false revision = core_tap.git_head ENV["HOMEBREW_UPDATE_BEFORE_HOMEBREW_HOMEBREW_CORE"] = revision ENV["HOMEBREW_UPDATE_AFTER_HOMEBREW_HOMEBREW_CORE"] = revision @@ -175,7 +175,7 @@ module Homebrew link_src_dst_dirs(HOMEBREW_REPOSITORY/"etc/bash_completion.d", HOMEBREW_PREFIX/"etc/bash_completion.d", command) link_src_dst_dirs(HOMEBREW_REPOSITORY/"share/doc/homebrew", - HOMEBREW_PREFIX/"share/doc/homebrew", command, :link_dir => true) + HOMEBREW_PREFIX/"share/doc/homebrew", command, link_dir: true) link_src_dst_dirs(HOMEBREW_REPOSITORY/"share/zsh/site-functions", HOMEBREW_PREFIX/"share/zsh/site-functions", command) link_path_manpages(HOMEBREW_REPOSITORY/"share", command) diff --git a/Library/Homebrew/cmd/upgrade.rb b/Library/Homebrew/cmd/upgrade.rb index 1053319bf..6968fbda8 100644 --- a/Library/Homebrew/cmd/upgrade.rb +++ b/Library/Homebrew/cmd/upgrade.rb @@ -25,13 +25,13 @@ module Homebrew if ARGV.named.empty? outdated = Formula.installed.select do |f| - f.outdated?(:fetch_head => ARGV.fetch_head?) + f.outdated?(fetch_head: ARGV.fetch_head?) end exit 0 if outdated.empty? else outdated = ARGV.resolved_formulae.select do |f| - f.outdated?(:fetch_head => ARGV.fetch_head?) + f.outdated?(fetch_head: ARGV.fetch_head?) end (ARGV.resolved_formulae - outdated).each do |f| diff --git a/Library/Homebrew/compilers.rb b/Library/Homebrew/compilers.rb index b8bc708fa..940566643 100644 --- a/Library/Homebrew/compilers.rb +++ b/Library/Homebrew/compilers.rb @@ -1,12 +1,12 @@ # @private module CompilerConstants - GNU_GCC_VERSIONS = %w[4.3 4.4 4.5 4.6 4.7 4.8 4.9 5 6 7] + GNU_GCC_VERSIONS = %w[4.3 4.4 4.5 4.6 4.7 4.8 4.9 5 6 7].freeze GNU_GCC_REGEXP = /^gcc-(4\.[3-9]|[5-7])$/ COMPILER_SYMBOL_MAP = { "gcc-4.0" => :gcc_4_0, "gcc-4.2" => :gcc, "clang" => :clang, - } + }.freeze COMPILERS = COMPILER_SYMBOL_MAP.values + GNU_GCC_VERSIONS.map { |n| "gcc-#{n}" } @@ -58,19 +58,19 @@ class CompilerFailure end COLLECTIONS = { - :cxx11 => [ + cxx11: [ create(:gcc_4_0), create(:gcc), create(:clang) { build 425 }, - create(:gcc => "4.3"), - create(:gcc => "4.4"), - create(:gcc => "4.5"), - create(:gcc => "4.6"), + create(gcc: "4.3"), + create(gcc: "4.4"), + create(gcc: "4.5"), + create(gcc: "4.6"), ], - :openmp => [ + openmp: [ create(:clang), ], - } + }.freeze end class CompilerSelector @@ -79,10 +79,10 @@ class CompilerSelector Compiler = Struct.new(:name, :version) COMPILER_PRIORITY = { - :clang => [:clang, :gcc, :gnu, :gcc_4_0], - :gcc => [:gcc, :gnu, :clang, :gcc_4_0], - :gcc_4_0 => [:gcc_4_0, :gcc, :gnu, :clang], - } + clang: [:clang, :gcc, :gnu, :gcc_4_0], + gcc: [:gcc, :gnu, :clang, :gcc_4_0], + gcc_4_0: [:gcc_4_0, :gcc, :gnu, :clang], + }.freeze def self.select_for(formula, compilers = self.compilers) new(formula, DevelopmentTools, compilers).compiler @@ -103,7 +103,7 @@ class CompilerSelector def compiler find_compiler { |c| return c.name unless fails_with?(c) } - raise CompilerSelectionError.new(formula) + raise CompilerSelectionError, formula end private diff --git a/Library/Homebrew/debrew.rb b/Library/Homebrew/debrew.rb index 7b1b50735..48d449f4a 100644 --- a/Library/Homebrew/debrew.rb +++ b/Library/Homebrew/debrew.rb @@ -110,7 +110,7 @@ module Debrew try_lock begin - puts "#{e.backtrace.first}" + puts e.backtrace.first.to_s puts "#{Tty.red}#{e.class.name}#{Tty.reset}: #{e}" loop do diff --git a/Library/Homebrew/dependable.rb b/Library/Homebrew/dependable.rb index 0620ffe32..0834b08ec 100644 --- a/Library/Homebrew/dependable.rb +++ b/Library/Homebrew/dependable.rb @@ -1,7 +1,7 @@ require "options" module Dependable - RESERVED_TAGS = [:build, :optional, :recommended, :run, :linked] + RESERVED_TAGS = [:build, :optional, :recommended, :run, :linked].freeze def build? tags.include? :build diff --git a/Library/Homebrew/dependency_collector.rb b/Library/Homebrew/dependency_collector.rb index 122828191..08b5fc12b 100644 --- a/Library/Homebrew/dependency_collector.rb +++ b/Library/Homebrew/dependency_collector.rb @@ -145,20 +145,19 @@ class DependencyCollector tags << :build strategy = spec.download_strategy - case - when strategy <= CurlDownloadStrategy + if strategy <= CurlDownloadStrategy parse_url_spec(spec.url, tags) - when strategy <= GitDownloadStrategy + elsif strategy <= GitDownloadStrategy GitRequirement.new(tags) - when strategy <= MercurialDownloadStrategy + elsif strategy <= MercurialDownloadStrategy MercurialRequirement.new(tags) - when strategy <= FossilDownloadStrategy + elsif strategy <= FossilDownloadStrategy Dependency.new("fossil", tags) - when strategy <= BazaarDownloadStrategy + elsif strategy <= BazaarDownloadStrategy Dependency.new("bazaar", tags) - when strategy <= CVSDownloadStrategy + elsif strategy <= CVSDownloadStrategy Dependency.new("cvs", tags) if MacOS.version >= :mavericks || !MacOS::Xcode.provides_cvs? - when strategy < AbstractDownloadStrategy + elsif strategy < AbstractDownloadStrategy # allow unknown strategies to pass through else raise TypeError, diff --git a/Library/Homebrew/descriptions.rb b/Library/Homebrew/descriptions.rb index 9c5341461..5e7a5b06c 100644 --- a/Library/Homebrew/descriptions.rb +++ b/Library/Homebrew/descriptions.rb @@ -6,7 +6,7 @@ class Descriptions CACHE_FILE = HOMEBREW_CACHE + "desc_cache.json" def self.cache - @cache || self.load_cache + @cache || load_cache end # If the cache file exists, load it into, and return, a hash; otherwise, @@ -31,7 +31,7 @@ class Descriptions Formula.each do |f| @cache[f.full_name] = f.desc end - self.save_cache + save_cache end # Return true if the cache exists, and none of the Taps @@ -51,7 +51,7 @@ class Descriptions # Create the cache if it doesn't already exist. def self.ensure_cache - self.generate_cache unless self.cache_fresh? && self.cache + generate_cache unless cache_fresh? && cache end # Take a {Report}, as generated by cmd/update.rb. @@ -66,8 +66,8 @@ class Descriptions renamings = report.select_formula(:R) alterations = report.select_formula(:A) + report.select_formula(:M) + renamings.map(&:last) - self.cache_formulae(alterations, :save => false) - self.uncache_formulae(report.select_formula(:D) + + cache_formulae(alterations, save: false) + uncache_formulae(report.select_formula(:D) + renamings.map(&:first)) end end @@ -75,8 +75,8 @@ class Descriptions # Given an array of formula names, add them and their descriptions to the # cache. Save the updated cache to disk, unless explicitly told not to. - def self.cache_formulae(formula_names, options = { :save => true }) - if self.cache + def self.cache_formulae(formula_names, options = { save: true }) + if cache formula_names.each do |name| begin desc = Formulary.factory(name).desc @@ -84,22 +84,22 @@ class Descriptions end @cache[name] = desc end - self.save_cache if options[:save] + save_cache if options[:save] end end # Given an array of formula names, remove them and their descriptions from # the cache. Save the updated cache to disk, unless explicitly told not to. - def self.uncache_formulae(formula_names, options = { :save => true }) - if self.cache + def self.uncache_formulae(formula_names, options = { save: true }) + if cache formula_names.each { |name| @cache.delete(name) } - self.save_cache if options[:save] + save_cache if options[:save] end end # Given a regex, find all formulae whose specified fields contain a match. def self.search(regex, field = :either) - self.ensure_cache + ensure_cache results = case field when :name @@ -138,6 +138,6 @@ class Descriptions def short_name_counts @short_name_counts ||= - short_names.values.reduce(Hash.new(0)) { |counts, name| counts[name] += 1; counts } + short_names.values.each_with_object(Hash.new(0)) { |name, counts| counts[name] += 1; counts } end end diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb index 511610a9a..20e9a8aff 100644 --- a/Library/Homebrew/dev-cmd/audit.rb +++ b/Library/Homebrew/dev-cmd/audit.rb @@ -62,11 +62,11 @@ module Homebrew if strict # Check style in a single batch run up front for performance - style_results = check_style_json(files, :realpath => true) + style_results = check_style_json(files, realpath: true) end ff.each do |f| - options = { :new_formula => new_formula, :strict => strict, :online => online } + options = { new_formula: new_formula, strict: strict, online: online } options[:style_offenses] = style_results.file_offenses(f.path) if strict fa = FormulaAuditor.new(f, options) fa.audit @@ -172,7 +172,7 @@ class FormulaAuditor return unless @style_offenses display_cop_names = ARGV.include?("--display-cop-names") @style_offenses.each do |offense| - problem offense.to_s(:display_cop_name => display_cop_names) + problem offense.to_s(display_cop_name: display_cop_names) end end @@ -655,7 +655,7 @@ class FormulaAuditor return unless formula.tap # skip formula not from core or any taps return unless formula.tap.git? # git log is required - fv = FormulaVersions.new(formula, :max_depth => 10) + fv = FormulaVersions.new(formula, max_depth: 10) attributes = [:revision, :version_scheme] attributes_map = fv.version_attributes_map(attributes, "origin/master") diff --git a/Library/Homebrew/dev-cmd/pull.rb b/Library/Homebrew/dev-cmd/pull.rb index a59792281..7f027e159 100644 --- a/Library/Homebrew/dev-cmd/pull.rb +++ b/Library/Homebrew/dev-cmd/pull.rb @@ -243,7 +243,7 @@ module Homebrew end published = [] - bintray_creds = { :user => ENV["BINTRAY_USER"], :key => ENV["BINTRAY_KEY"] } + bintray_creds = { user: ENV["BINTRAY_USER"], key: ENV["BINTRAY_KEY"] } if bintray_creds[:user] && bintray_creds[:key] changed_formulae_names.each do |name| f = Formula[name] @@ -338,7 +338,7 @@ module Homebrew others << file end end - { :files => files, :formulae => formulae, :others => others } + { files: files, formulae: formulae, others: others } end # Get current formula versions without loading formula definition in this process diff --git a/Library/Homebrew/dev-cmd/test-bot.rb b/Library/Homebrew/dev-cmd/test-bot.rb index c8f34c24f..43feb318c 100644 --- a/Library/Homebrew/dev-cmd/test-bot.rb +++ b/Library/Homebrew/dev-cmd/test-bot.rb @@ -102,7 +102,7 @@ module Homebrew # Assume we are starting from a "mostly" UTF-8 string str.force_encoding(Encoding::UTF_8) return str if str.valid_encoding? - str.encode!(Encoding::UTF_16, :invalid => :replace) + str.encode!(Encoding::UTF_16, invalid: :replace) str.encode!(Encoding::UTF_8) end @@ -652,7 +652,7 @@ module Homebrew bottle_merge_args << "--keep-old" if ARGV.include? "--keep-old" test "brew", "bottle", *bottle_merge_args test "brew", "uninstall", "--force", formula_name - FileUtils.ln bottle_filename, HOMEBREW_CACHE/bottle_filename, :force => true + FileUtils.ln bottle_filename, HOMEBREW_CACHE/bottle_filename, force: true @formulae.delete(formula_name) unless unchanged_build_dependencies.empty? test "brew", "uninstall", "--force", *unchanged_build_dependencies @@ -908,7 +908,7 @@ module Homebrew bottles = Dir["#{jenkins}/jobs/#{job}/configurations/axis-version/*/builds/#{id}/archive/*.bottle*.*"] return if bottles.empty? - FileUtils.cp bottles, Dir.pwd, :verbose => true + FileUtils.cp bottles, Dir.pwd, verbose: true end json_files = Dir.glob("*.bottle.json") @@ -1077,14 +1077,14 @@ module Homebrew skip_homebrew = ARGV.include?("--skip-homebrew") if ARGV.named.empty? # With no arguments just build the most recent commit. - current_test = Test.new("HEAD", :tap => tap, :skip_homebrew => skip_homebrew) + current_test = Test.new("HEAD", tap: tap, skip_homebrew: skip_homebrew) any_errors = !current_test.run tests << current_test else ARGV.named.each do |argument| test_error = false begin - current_test = Test.new(argument, :tap => tap, :skip_homebrew => skip_homebrew) + current_test = Test.new(argument, tap: tap, skip_homebrew: skip_homebrew) skip_homebrew = true rescue ArgumentError => e test_error = true @@ -1153,7 +1153,7 @@ module Homebrew # Truncate to 1MB to avoid hitting CI limits if output.bytesize > MAX_STEP_OUTPUT_SIZE - output = truncate_text_to_approximate_size(output, MAX_STEP_OUTPUT_SIZE, :front_weight => 0.0) + output = truncate_text_to_approximate_size(output, MAX_STEP_OUTPUT_SIZE, front_weight: 0.0) output = "truncated output to 1MB:\n" + output end end diff --git a/Library/Homebrew/development_tools.rb b/Library/Homebrew/development_tools.rb index 93372bbc5..14e1a07f7 100644 --- a/Library/Homebrew/development_tools.rb +++ b/Library/Homebrew/development_tools.rb @@ -27,7 +27,11 @@ class DevelopmentTools def default_cc cc = DevelopmentTools.locate "cc" - cc.realpath.basename.to_s rescue nil + begin + cc.realpath.basename.to_s + rescue + nil + end end def default_compiler diff --git a/Library/Homebrew/diagnostic.rb b/Library/Homebrew/diagnostic.rb index e2e2d50c4..bcdde6656 100644 --- a/Library/Homebrew/diagnostic.rb +++ b/Library/Homebrew/diagnostic.rb @@ -412,11 +412,11 @@ module Homebrew unless $seen_prefix_bin # only show the doctor message if there are any conflicts # rationale: a default install should not trigger any brew doctor messages - conflicts = Dir["#{HOMEBREW_PREFIX}/bin/*"]. - map { |fn| File.basename fn }. - select { |bn| File.exist? "/usr/bin/#{bn}" } + conflicts = Dir["#{HOMEBREW_PREFIX}/bin/*"] + .map { |fn| File.basename fn } + .select { |bn| File.exist? "/usr/bin/#{bn}" } - if conflicts.size > 0 + unless conflicts.empty? message = inject_file_list conflicts, <<-EOS.undent /usr/bin occurs before #{HOMEBREW_PREFIX}/bin This means that system-provided programs will be used instead of those @@ -456,7 +456,7 @@ module Homebrew # Don't complain about sbin not being in the path if it doesn't exist sbin = (HOMEBREW_PREFIX+"sbin") - return unless sbin.directory? && sbin.children.length > 0 + return unless sbin.directory? && !sbin.children.empty? <<-EOS.undent Homebrew's sbin was not found in your PATH but you have installed @@ -515,7 +515,11 @@ module Homebrew return if @found.empty? # Our gettext formula will be caught by check_linked_keg_only_brews - gettext = Formulary.factory("gettext") rescue nil + gettext = begin + Formulary.factory("gettext") + rescue + nil + end homebrew_owned = @found.all? do |path| Pathname.new(path).realpath.to_s.start_with? "#{HOMEBREW_CELLAR}/gettext" end @@ -532,7 +536,11 @@ module Homebrew find_relative_paths("lib/libiconv.dylib", "include/iconv.h") return if @found.empty? - libiconv = Formulary.factory("libiconv") rescue nil + libiconv = begin + Formulary.factory("libiconv") + rescue + nil + end if libiconv && libiconv.linked_keg.directory? unless libiconv.keg_only? <<-EOS.undent @@ -806,9 +814,9 @@ module Homebrew libexpat.framework libcurl.framework ] - frameworks_found = frameworks_to_check. - map { |framework| "/Library/Frameworks/#{framework}" }. - select { |framework| File.exist? framework } + frameworks_found = frameworks_to_check + .map { |framework| "/Library/Frameworks/#{framework}" } + .select { |framework| File.exist? framework } return if frameworks_found.empty? inject_file_list frameworks_found, <<-EOS.undent @@ -885,11 +893,10 @@ module Homebrew def check_for_old_homebrew_share_python_in_path message = "" ["", "3"].map do |suffix| - if paths.include?((HOMEBREW_PREFIX/"share/python#{suffix}").to_s) - message += <<-EOS.undent + next unless paths.include?((HOMEBREW_PREFIX/"share/python#{suffix}").to_s) + message += <<-EOS.undent #{HOMEBREW_PREFIX}/share/python#{suffix} is not needed in PATH. - EOS - end + EOS end unless message.empty? message += <<-EOS.undent diff --git a/Library/Homebrew/download_strategy.rb b/Library/Homebrew/download_strategy.rb index cd09fc1e2..cabb22c22 100644 --- a/Library/Homebrew/download_strategy.rb +++ b/Library/Homebrew/download_strategy.rb @@ -59,14 +59,13 @@ class AbstractDownloadStrategy def expand_safe_system_args(args) args = args.dup args.each_with_index do |arg, ii| - if arg.is_a? Hash - unless ARGV.verbose? - args[ii] = arg[:quiet_flag] - else - args.delete_at ii - end - return args + next unless arg.is_a? Hash + if ARGV.verbose? + args.delete_at ii + else + args[ii] = arg[:quiet_flag] end + return args end # 2 as default because commands are eg. svn up, git pull args.insert(2, "-q") unless ARGV.verbose? @@ -226,7 +225,7 @@ class AbstractFileDownloadStrategy < AbstractDownloadStrategy def stage case cached_location.compression_type when :zip - with_system_path { quiet_safe_system "unzip", { :quiet_flag => "-qq" }, cached_location } + with_system_path { quiet_safe_system "unzip", { quiet_flag: "-qq" }, cached_location } chdir when :gzip_only with_system_path { buffered_write("gunzip") } @@ -234,7 +233,7 @@ class AbstractFileDownloadStrategy < AbstractDownloadStrategy with_system_path { buffered_write("bunzip2") } when :gzip, :bzip2, :compress, :tar # Assume these are also tarred - tar_flags = (ARGV.verbose? && ENV["TRAVIS"].nil?) ? "xv" : "x" + tar_flags = ARGV.verbose? && ENV["TRAVIS"].nil? ? "xv" : "x" # Older versions of tar require an explicit format flag if cached_location.compression_type == :gzip tar_flags << "z" @@ -255,11 +254,11 @@ class AbstractFileDownloadStrategy < AbstractDownloadStrategy when :xar safe_system "/usr/bin/xar", "-xf", cached_location when :rar - quiet_safe_system "unrar", "x", { :quiet_flag => "-inul" }, cached_location + quiet_safe_system "unrar", "x", { quiet_flag: "-inul" }, cached_location when :p7zip safe_system "7zr", "x", cached_location else - cp cached_location, basename_without_params, :preserve => true + cp cached_location, basename_without_params, preserve: true end end @@ -269,7 +268,11 @@ class AbstractFileDownloadStrategy < AbstractDownloadStrategy entries = Dir["*"] case entries.length when 0 then raise "Empty archive" - when 1 then Dir.chdir entries.first rescue nil + when 1 then begin + Dir.chdir entries.first + rescue + nil + end end end @@ -324,7 +327,9 @@ class CurlDownloadStrategy < AbstractFileDownloadStrategy def fetch ohai "Downloading #{@url}" - unless cached_location.exist? + if cached_location.exist? + puts "Already downloaded: #{cached_location}" + else had_incomplete_download = temporary_path.exist? begin _fetch @@ -337,12 +342,10 @@ class CurlDownloadStrategy < AbstractFileDownloadStrategy had_incomplete_download = false retry else - raise CurlDownloadStrategyError.new(@url) + raise CurlDownloadStrategyError, @url end end ignore_interrupts { temporary_path.rename(cached_location) } - else - puts "Already downloaded: #{cached_location}" end rescue CurlDownloadStrategyError raise if mirrors.empty? @@ -377,7 +380,7 @@ class CurlDownloadStrategy < AbstractFileDownloadStrategy if !ENV["HOMEBREW_NO_INSECURE_REDIRECT"].nil? && url.start_with?("https://") && urls.any? { |u| !u.start_with? "https://" } puts "HTTPS to HTTP redirect detected & HOMEBREW_NO_INSECURE_REDIRECT is set." - raise CurlDownloadStrategyError.new(url) + raise CurlDownloadStrategyError, url end url = urls.last end @@ -464,7 +467,7 @@ end # Useful for installing jars. class NoUnzipCurlDownloadStrategy < CurlDownloadStrategy def stage - cp cached_location, basename_without_params, :preserve => true + cp cached_location, basename_without_params, preserve: true end end @@ -613,8 +616,8 @@ class GitDownloadStrategy < VCSDownloadStrategy %r{git://}, %r{https://github\.com}, %r{http://git\.sv\.gnu\.org}, - %r{http://llvm\.org} - ] + %r{http://llvm\.org}, + ].freeze def initialize(name, resource) super @@ -625,7 +628,7 @@ class GitDownloadStrategy < VCSDownloadStrategy def stage super - cp_r File.join(cached_location, "."), Dir.pwd, :preserve => true + cp_r File.join(cached_location, "."), Dir.pwd, preserve: true end def source_modified_time @@ -764,7 +767,8 @@ class GitDownloadStrategy < VCSDownloadStrategy # in 2.8.3. Clones created with affected version remain broken.) # See https://github.com/Homebrew/homebrew-core/pull/1520 for an example. submodule_dirs = Utils.popen_read( - "git", "submodule", "--quiet", "foreach", "--recursive", "pwd") + "git", "submodule", "--quiet", "foreach", "--recursive", "pwd" + ) submodule_dirs.lines.map(&:chomp).each do |submodule_dir| work_dir = Pathname.new(submodule_dir) @@ -856,7 +860,7 @@ class CVSDownloadStrategy < VCSDownloadStrategy end def stage - cp_r File.join(cached_location, "."), Dir.pwd, :preserve => true + cp_r File.join(cached_location, "."), Dir.pwd, preserve: true end private @@ -872,13 +876,13 @@ class CVSDownloadStrategy < VCSDownloadStrategy def clone_repo HOMEBREW_CACHE.cd do # Login is only needed (and allowed) with pserver; skip for anoncvs. - quiet_safe_system cvspath, { :quiet_flag => "-Q" }, "-d", @url, "login" if @url.include? "pserver" - quiet_safe_system cvspath, { :quiet_flag => "-Q" }, "-d", @url, "checkout", "-d", cache_filename, @module + quiet_safe_system cvspath, { quiet_flag: "-Q" }, "-d", @url, "login" if @url.include? "pserver" + quiet_safe_system cvspath, { quiet_flag: "-Q" }, "-d", @url, "checkout", "-d", cache_filename, @module end end def update - cached_location.cd { quiet_safe_system cvspath, { :quiet_flag => "-Q" }, "up" } + cached_location.cd { quiet_safe_system cvspath, { quiet_flag: "-Q" }, "up" } end def split_url(in_url) @@ -945,7 +949,7 @@ class BazaarDownloadStrategy < VCSDownloadStrategy def stage # The export command doesn't work on checkouts # See https://bugs.launchpad.net/bzr/+bug/897511 - cp_r File.join(cached_location, "."), Dir.pwd, :preserve => true + cp_r File.join(cached_location, "."), Dir.pwd, preserve: true rm_r ".bzr" end diff --git a/Library/Homebrew/emoji.rb b/Library/Homebrew/emoji.rb index 8c58ca895..ade330947 100644 --- a/Library/Homebrew/emoji.rb +++ b/Library/Homebrew/emoji.rb @@ -17,7 +17,7 @@ module Emoji def enabled? !ENV["HOMEBREW_NO_EMOJI"] end - alias generic_enabled? enabled? + alias_method :generic_enabled?, :enabled? end end diff --git a/Library/Homebrew/exceptions.rb b/Library/Homebrew/exceptions.rb index 4d1559c28..70045333a 100644 --- a/Library/Homebrew/exceptions.rb +++ b/Library/Homebrew/exceptions.rb @@ -309,7 +309,7 @@ class BuildError < RuntimeError end def fetch_issues - GitHub.issues_for_formula(formula.name, :tap => formula.tap) + GitHub.issues_for_formula(formula.name, tap: formula.tap) rescue GitHub::RateLimitExceededError => e opoo e.message [] @@ -482,7 +482,7 @@ class DuplicateResourceError < ArgumentError end # raised when a single patch file is not found and apply hasn't been specified -class MissingApplyError < RuntimeError ; end +class MissingApplyError < RuntimeError; end class BottleVersionMismatchError < RuntimeError def initialize(bottle_file, bottle_version, formula, formula_version) diff --git a/Library/Homebrew/extend/ENV/std.rb b/Library/Homebrew/extend/ENV/std.rb index fec0044a1..a9b2358b1 100644 --- a/Library/Homebrew/extend/ENV/std.rb +++ b/Library/Homebrew/extend/ENV/std.rb @@ -132,7 +132,7 @@ module Stdenv replace_in_cflags(/-Xarch_#{Hardware::CPU.arch_32_bit} (-march=\S*)/, '\1') # Clang mistakenly enables AES-NI on plain Nehalem map = Hardware::CPU.optimization_flags - map = map.merge(:nehalem => "-march=native -Xclang -target-feature -Xclang -aes") + map = map.merge(nehalem: "-march=native -Xclang -target-feature -Xclang -aes") set_cpu_cflags "-march=native", map end diff --git a/Library/Homebrew/extend/os/mac/hardware/cpu.rb b/Library/Homebrew/extend/os/mac/hardware/cpu.rb index 8733c4933..0695d4a5b 100644 --- a/Library/Homebrew/extend/os/mac/hardware/cpu.rb +++ b/Library/Homebrew/extend/os/mac/hardware/cpu.rb @@ -4,11 +4,11 @@ module Hardware class CPU class << self PPC_OPTIMIZATION_FLAGS = { - :g3 => "-mcpu=750", - :g4 => "-mcpu=7400", - :g4e => "-mcpu=7450", - :g5 => "-mcpu=970", - :g5_64 => "-mcpu=970 -arch ppc64", + g3: "-mcpu=750", + g4: "-mcpu=7400", + g4e: "-mcpu=7450", + g5: "-mcpu=970", + g5_64: "-mcpu=970 -arch ppc64", }.freeze def optimization_flags OPTIMIZATION_FLAGS.merge(PPC_OPTIMIZATION_FLAGS) diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb index 88f53a6d1..599b49392 100644 --- a/Library/Homebrew/formula.rb +++ b/Library/Homebrew/formula.rb @@ -418,7 +418,7 @@ class Formula # exists and is not empty. # @private def installed? - (dir = installed_prefix).directory? && dir.children.length > 0 + (dir = installed_prefix).directory? && !dir.children.empty? end # If at least one version of {Formula} is installed. @@ -451,7 +451,7 @@ class Formula prefix(head_version) if head_version end - def head_version_outdated?(version, options={}) + def head_version_outdated?(version, options = {}) tab = Tab.for_keg(prefix(version)) return true if tab.version_scheme < version_scheme @@ -802,7 +802,7 @@ class Formula # <string>/dev/null</string> # </plist> # EOS - #end</pre> + # end</pre> def plist nil end @@ -1061,7 +1061,7 @@ class Formula # @private def outdated_versions(options = {}) @outdated_versions ||= Hash.new do |cache, key| - raise Migrator::MigrationNeededError.new(self) if migration_needed? + raise Migrator::MigrationNeededError, self if migration_needed? cache[key] = _outdated_versions(key) end @outdated_versions[options] @@ -1348,7 +1348,7 @@ class Formula "stable" => (stable.version.to_s if stable), "bottle" => bottle ? true : false, "devel" => (devel.version.to_s if devel), - "head" => (head.version.to_s if head) + "head" => (head.version.to_s if head), }, "revision" => revision, "version_scheme" => version_scheme, @@ -1362,7 +1362,7 @@ class Formula "optional_dependencies" => deps.select(&:optional?).map(&:name).uniq, "build_dependencies" => deps.select(&:build?).map(&:name).uniq, "conflicts_with" => conflicts.map(&:name), - "caveats" => caveats + "caveats" => caveats, } hsh["requirements"] = requirements.map do |req| @@ -1370,7 +1370,7 @@ class Formula "name" => req.name, "default_formula" => req.default_formula, "cask" => req.cask, - "download" => req.download + "download" => req.download, } end @@ -1385,8 +1385,7 @@ class Formula bottle_spec = spec.bottle_specification bottle_info = { "rebuild" => bottle_spec.rebuild, - "cellar" => (cellar = bottle_spec.cellar).is_a?(Symbol) ? \ - cellar.inspect : cellar, + "cellar" => (cellar = bottle_spec.cellar).is_a?(Symbol) ? cellar.inspect : cellar, "prefix" => bottle_spec.prefix, "root_url" => bottle_spec.root_url, } @@ -1408,7 +1407,7 @@ class Formula "version" => keg.version.to_s, "used_options" => tab.used_options.as_flags, "built_as_bottle" => tab.built_as_bottle, - "poured_from_bottle" => tab.poured_from_bottle + "poured_from_bottle" => tab.poured_from_bottle, } end @@ -1564,11 +1563,10 @@ class Formula while buf = rd.gets log.puts buf # make sure dots printed with interval of at least 1 min. - if (Time.now - last_dot) > 60 - print "." - $stdout.flush - last_dot = Time.now - end + next unless (Time.now - last_dot) > 60 + print "." + $stdout.flush + last_dot = Time.now end puts else @@ -1668,7 +1666,11 @@ class Formula $stderr.reopen(out) out.close args.collect!(&:to_s) - exec(cmd, *args) rescue nil + begin + exec(cmd, *args) + rescue + nil + end puts "Failed to execute: #{cmd}" exit! 1 # never gets here unless exec threw or failed end @@ -1680,7 +1682,8 @@ class Formula env_home = buildpath/".brew_home" mkdir_p env_home - old_home, ENV["HOME"] = ENV["HOME"], env_home + old_home = ENV["HOME"] + ENV["HOME"] = env_home old_curl_home = ENV["CURL_HOME"] ENV["CURL_HOME"] = old_curl_home || old_home setup_home env_home diff --git a/Library/Homebrew/formula_cellar_checks.rb b/Library/Homebrew/formula_cellar_checks.rb index f527c453b..3805d0f45 100644 --- a/Library/Homebrew/formula_cellar_checks.rb +++ b/Library/Homebrew/formula_cellar_checks.rb @@ -166,7 +166,7 @@ module FormulaCellarChecks audit_check_output(check_elisp_dirname(formula.share, formula.name)) audit_check_output(check_elisp_root(formula.share, formula.name)) end - alias generic_audit_installed audit_installed + alias_method :generic_audit_installed, :audit_installed private diff --git a/Library/Homebrew/formula_installer.rb b/Library/Homebrew/formula_installer.rb index cb62e6206..18267ee78 100644 --- a/Library/Homebrew/formula_installer.rb +++ b/Library/Homebrew/formula_installer.rb @@ -67,14 +67,14 @@ class FormulaInstaller def self.prevent_build_flags build_flags = ARGV.collect_build_flags - raise BuildFlagsError.new(build_flags) unless build_flags.empty? + raise BuildFlagsError, build_flags unless build_flags.empty? end def build_bottle? !!@build_bottle && !formula.bottle_disabled? end - def pour_bottle?(install_bottle_options = { :warn=>false }) + def pour_bottle?(install_bottle_options = { warn: false }) return true if Homebrew::Hooks::Bottles.formula_has_bottle?(formula) return false if @pour_failed @@ -191,7 +191,7 @@ class FormulaInstaller check_conflicts if !pour_bottle? && !formula.bottle_unneeded? && !DevelopmentTools.installed? - raise BuildToolsError.new([formula]) + raise BuildToolsError, [formula] end unless skip_deps_check? @@ -229,7 +229,7 @@ class FormulaInstaller @@attempted << formula - pour_bottle = pour_bottle?(:warn => true) + pour_bottle = pour_bottle?(warn: true) if pour_bottle begin install_relocation_tools unless formula.bottle_specification.skip_relocation? @@ -244,7 +244,7 @@ class FormulaInstaller @pour_failed = true onoe e.message opoo "Bottle installation failed: building from source." - raise BuildToolsError.new([formula]) unless DevelopmentTools.installed? + raise BuildToolsError, [formula] unless DevelopmentTools.installed? else @poured_bottle = true end @@ -317,7 +317,7 @@ class FormulaInstaller dep_f.pour_bottle? || dep_f.bottle_unneeded? end - raise BuildToolsError.new(unbottled) unless unbottled.empty? + raise BuildToolsError, unbottled unless unbottled.empty? end def compute_and_install_dependencies @@ -336,7 +336,7 @@ class FormulaInstaller end end - raise UnsatisfiedRequirements.new(fatals) unless fatals.empty? + raise UnsatisfiedRequirements, fatals unless fatals.empty? end def install_requirement_default_formula?(req, dependent, build) @@ -422,7 +422,7 @@ class FormulaInstaller puts "All dependencies for #{formula.full_name} are satisfied." elsif !deps.empty? oh1 "Installing dependencies for #{formula.full_name}: #{Tty.green}#{deps.map(&:first)*", "}#{Tty.reset}", - :truncate => false + truncate: false deps.each { |dep, options| install_dependency(dep, options) } end @@ -675,7 +675,7 @@ class FormulaInstaller puts e puts puts "Possible conflicting files are:" - mode = OpenStruct.new(:dry_run => true, :overwrite => true) + mode = OpenStruct.new(dry_run: true, overwrite: true) keg.link(mode) @show_summary_heading = true Homebrew.failed = true diff --git a/Library/Homebrew/formula_pin.rb b/Library/Homebrew/formula_pin.rb index 18352c93b..0558c714c 100644 --- a/Library/Homebrew/formula_pin.rb +++ b/Library/Homebrew/formula_pin.rb @@ -16,7 +16,7 @@ class FormulaPin end def pin - pin_at(@f.installed_kegs.map { |keg| keg.version }.max) + pin_at(@f.installed_kegs.map(&:version).max) end def unpin diff --git a/Library/Homebrew/formula_support.rb b/Library/Homebrew/formula_support.rb index c649bf502..83855d131 100644 --- a/Library/Homebrew/formula_support.rb +++ b/Library/Homebrew/formula_support.rb @@ -58,7 +58,7 @@ end # Used to annotate formulae that don't require compiling or cannot build bottle. class BottleDisableReason - SUPPORTED_TYPES = [:unneeded, :disable] + SUPPORTED_TYPES = [:unneeded, :disable].freeze def initialize(type, reason) @type = type diff --git a/Library/Homebrew/formula_versions.rb b/Library/Homebrew/formula_versions.rb index e5a0c0aea..ec2e2a459 100644 --- a/Library/Homebrew/formula_versions.rb +++ b/Library/Homebrew/formula_versions.rb @@ -5,7 +5,7 @@ class FormulaVersions ArgumentError, NameError, SyntaxError, TypeError, FormulaSpecificationError, FormulaValidationError, ErrorDuringExecution, LoadError, FormulaMethodDeprecatedError - ] + ].freeze attr_reader :name, :path, :repository, :entry_name diff --git a/Library/Homebrew/formulary.rb b/Library/Homebrew/formulary.rb index cbad28fc7..1cd9dce2a 100644 --- a/Library/Homebrew/formulary.rb +++ b/Library/Homebrew/formulary.rb @@ -28,9 +28,9 @@ class Formulary begin mod.const_get(class_name) rescue NameError => original_exception - class_list = mod.constants. - map { |const_name| mod.const_get(const_name) }. - select { |const| const.is_a?(Class) } + class_list = mod.constants + .map { |const_name| mod.const_get(const_name) } + .select { |const| const.is_a?(Class) } e = FormulaClassUnavailableError.new(name, path, class_name, class_list) raise e, "", original_exception.backtrace end @@ -78,7 +78,7 @@ class Formulary # Gets the formula instance. def get_formula(spec) - klass.new(name, path, spec, :alias_path => alias_path) + klass.new(name, path, spec, alias_path: alias_path) end def klass @@ -90,7 +90,7 @@ class Formulary def load_file $stderr.puts "#{$0} (#{self.class.name}): loading #{path}" if ARGV.debug? - raise FormulaUnavailableError.new(name) unless path.file? + raise FormulaUnavailableError, name unless path.file? Formulary.load_formula_from_path(name, path) end end @@ -188,7 +188,7 @@ class Formulary end def get_formula(_spec) - raise FormulaUnavailableError.new(name) + raise FormulaUnavailableError, name end end @@ -353,11 +353,11 @@ class Formulary name = name.downcase taps.map do |tap| Pathname.glob([ - "#{tap}Formula/#{name}.rb", - "#{tap}HomebrewFormula/#{name}.rb", - "#{tap}#{name}.rb", - "#{tap}Aliases/#{name}", - ]).detect(&:file?) + "#{tap}Formula/#{name}.rb", + "#{tap}HomebrewFormula/#{name}.rb", + "#{tap}#{name}.rb", + "#{tap}Aliases/#{name}", + ]).detect(&:file?) end.compact end diff --git a/Library/Homebrew/global.rb b/Library/Homebrew/global.rb index 8472eba5c..91692c146 100644 --- a/Library/Homebrew/global.rb +++ b/Library/Homebrew/global.rb @@ -16,7 +16,7 @@ ARGV.extend(HomebrewArgvExtension) HOMEBREW_PRODUCT = ENV["HOMEBREW_PRODUCT"] HOMEBREW_VERSION = ENV["HOMEBREW_VERSION"] -HOMEBREW_WWW = "http://brew.sh" +HOMEBREW_WWW = "http://brew.sh".freeze require "config" @@ -26,7 +26,7 @@ RUBY_PATH = Pathname.new(RbConfig.ruby) RUBY_BIN = RUBY_PATH.dirname HOMEBREW_USER_AGENT_CURL = ENV["HOMEBREW_USER_AGENT_CURL"] -HOMEBREW_USER_AGENT_RUBY = "#{ENV["HOMEBREW_USER_AGENT"]} ruby/#{RUBY_VERSION}-p#{RUBY_PATCHLEVEL}" +HOMEBREW_USER_AGENT_RUBY = "#{ENV["HOMEBREW_USER_AGENT"]} ruby/#{RUBY_VERSION}-p#{RUBY_PATCHLEVEL}".freeze HOMEBREW_CURL_ARGS = [ "--fail", @@ -54,7 +54,13 @@ HOMEBREW_PULL_OR_COMMIT_URL_REGEX = %r[https://github\.com/([\w-]+)/([\w-]+)?/(? require "compat" unless ARGV.include?("--no-compat") || ENV["HOMEBREW_NO_COMPAT"] -ORIGINAL_PATHS = ENV["PATH"].split(File::PATH_SEPARATOR).map { |p| Pathname.new(p).expand_path rescue nil }.compact.freeze +ORIGINAL_PATHS = ENV["PATH"].split(File::PATH_SEPARATOR).map do |p| + begin + Pathname.new(p).expand_path + rescue + nil + end +end.compact.freeze # TODO: remove this as soon as it's removed from commands.rb. HOMEBREW_INTERNAL_COMMAND_ALIASES = { @@ -71,5 +77,5 @@ HOMEBREW_INTERNAL_COMMAND_ALIASES = { "dr" => "doctor", "--repo" => "--repository", "environment" => "--env", - "--config" => "config" -} + "--config" => "config", +}.freeze diff --git a/Library/Homebrew/hardware.rb b/Library/Homebrew/hardware.rb index a7c6d353c..fd5251bf6 100644 --- a/Library/Homebrew/hardware.rb +++ b/Library/Homebrew/hardware.rb @@ -9,10 +9,10 @@ module Hardware class << self OPTIMIZATION_FLAGS = { - :penryn => "-march=core2 -msse4.1", - :core2 => "-march=core2", - :core => "-march=prescott", - :dunno => "", + penryn: "-march=core2 -msse4.1", + core2: "-march=core2", + core: "-march=prescott", + dunno: "", }.freeze def optimization_flags diff --git a/Library/Homebrew/keg.rb b/Library/Homebrew/keg.rb index febb60971..640ecbc72 100644 --- a/Library/Homebrew/keg.rb +++ b/Library/Homebrew/keg.rb @@ -64,7 +64,7 @@ class Keg # locale-specific directories have the form language[_territory][.codeset][@modifier] LOCALEDIR_RX = /(locale|man)\/([a-z]{2}|C|POSIX)(_[A-Z]{2})?(\.[a-zA-Z\-0-9]+(@.+)?)?/ INFOFILE_RX = %r{info/([^.].*?\.info|dir)$} - TOP_LEVEL_DIRECTORIES = %w[bin etc include lib sbin share var Frameworks] + TOP_LEVEL_DIRECTORIES = %w[bin etc include lib sbin share var Frameworks].freeze ALL_TOP_LEVEL_DIRECTORIES = (TOP_LEVEL_DIRECTORIES + %w[lib/pkgconfig share/locale share/man opt]).freeze PRUNEABLE_DIRECTORIES = %w[bin etc include lib sbin share Frameworks LinkedKegs var/homebrew].map do |d| case d when "LinkedKegs" then HOMEBREW_LIBRARY/d else HOMEBREW_PREFIX/d end @@ -80,7 +80,7 @@ class Keg man/cat5 man/cat6 man/cat7 man/cat8 applications gnome gnome/help icons mime-info pixmaps sounds postgresql - ] + ].freeze # if path is a file in a keg then this will return the containing Keg object def self.for(path) @@ -216,17 +216,16 @@ class Keg dirs << dst if dst.directory? && !dst.symlink? # check whether the file to be unlinked is from the current keg first - if dst.symlink? && src == dst.resolved_path - if mode.dry_run - puts dst - Find.prune if src.directory? - next - end - - dst.uninstall_info if dst.to_s =~ INFOFILE_RX - dst.unlink + next unless dst.symlink? && src == dst.resolved_path + if mode.dry_run + puts dst Find.prune if src.directory? + next end + + dst.uninstall_info if dst.to_s =~ INFOFILE_RX + dst.unlink + Find.prune if src.directory? end end @@ -301,7 +300,7 @@ class Keg end def link(mode = OpenStruct.new) - raise AlreadyLinkedError.new(self) if linked_keg_record.directory? + raise AlreadyLinkedError, self if linked_keg_record.directory? ObserverPathnameExtension.reset_counts! @@ -319,7 +318,6 @@ class Keg when "locale/locale.alias" then :skip_file when INFOFILE_RX then :info when LOCALEDIR_RX then :mkpath - when *SHARE_PATHS then :mkpath when /^icons\/.*\/icon-theme\.cache$/ then :skip_file # all icons subfolders should also mkpath when /^icons\// then :mkpath @@ -328,6 +326,7 @@ class Keg # Lua, Lua51, Lua53 all need the same handling. when /^lua\// then :mkpath when %r{^guile/} then :mkpath + when *SHARE_PATHS then :mkpath else :link end end diff --git a/Library/Homebrew/keg_relocate.rb b/Library/Homebrew/keg_relocate.rb index 864e2f97b..053c8b9de 100644 --- a/Library/Homebrew/keg_relocate.rb +++ b/Library/Homebrew/keg_relocate.rb @@ -12,9 +12,9 @@ class Keg end end end - alias generic_fix_dynamic_linkage fix_dynamic_linkage + alias_method :generic_fix_dynamic_linkage, :fix_dynamic_linkage - def relocate_dynamic_linkage(old_prefix, new_prefix, old_cellar, new_cellar) + def relocate_dynamic_linkage(_old_prefix, _new_prefix, _old_cellar, _new_cellar) [] end @@ -35,12 +35,12 @@ class Keg first.open("wb") { |f| f.write(s) } end else - rest.each { |file| FileUtils.ln(first, file, :force => true) } + rest.each { |file| FileUtils.ln(first, file, force: true) } end end end - def detect_cxx_stdlibs(options = {}) + def detect_cxx_stdlibs(_options = {}) [] end @@ -101,7 +101,7 @@ class Keg symlink_files end - def self.file_linked_libraries(file, string) + def self.file_linked_libraries(_file, _string) [] end end diff --git a/Library/Homebrew/language/java.rb b/Library/Homebrew/language/java.rb index 5bdc3e7cf..330b5208b 100644 --- a/Library/Homebrew/language/java.rb +++ b/Library/Homebrew/language/java.rb @@ -6,11 +6,11 @@ module Language end def self.java_home_env(version = nil) - { :JAVA_HOME => "$(#{java_home_cmd(version)})" } + { JAVA_HOME: "$(#{java_home_cmd(version)})" } end def self.overridable_java_home_env(version = nil) - { :JAVA_HOME => "${JAVA_HOME:-$(#{java_home_cmd(version)})}" } + { JAVA_HOME: "${JAVA_HOME:-$(#{java_home_cmd(version)})}" } end end end diff --git a/Library/Homebrew/metafiles.rb b/Library/Homebrew/metafiles.rb index 6d8f71f2a..bef48f3cf 100644 --- a/Library/Homebrew/metafiles.rb +++ b/Library/Homebrew/metafiles.rb @@ -3,11 +3,11 @@ class Metafiles EXTENSIONS = %w[ .adoc .asc .asciidoc .creole .html .markdown .md .mdown .mediawiki .mkdn .org .pod .rdoc .rst .rtf .textile .txt .wiki - ] + ].freeze BASENAMES = %w[ about authors changelog changes copying copyright history license licence news notes notice readme todo - ] + ].freeze def self.list?(file) return false if %w[.DS_Store INSTALL_RECEIPT.json].include?(file) diff --git a/Library/Homebrew/migrator.rb b/Library/Homebrew/migrator.rb index 550f8e51a..d31025119 100644 --- a/Library/Homebrew/migrator.rb +++ b/Library/Homebrew/migrator.rb @@ -86,11 +86,11 @@ class Migrator def initialize(formula) @oldname = formula.oldname @newname = formula.name - raise MigratorNoOldnameError.new(formula) unless oldname + raise MigratorNoOldnameError, formula unless oldname @formula = formula @old_cellar = HOMEBREW_CELLAR/formula.oldname - raise MigratorNoOldpathError.new(formula) unless old_cellar.exist? + raise MigratorNoOldpathError, formula unless old_cellar.exist? @old_tabs = old_cellar.subdirs.map { |d| Tab.for_keg(Keg.new(d)) } @old_tap = old_tabs.first.tap @@ -234,7 +234,7 @@ class Migrator puts e puts puts "Possible conflicting files are:" - mode = OpenStruct.new(:dry_run => true, :overwrite => true) + mode = OpenStruct.new(dry_run: true, overwrite: true) new_keg.link(mode) raise rescue Keg::LinkError => e diff --git a/Library/Homebrew/os/mac.rb b/Library/Homebrew/os/mac.rb index ad8d474b8..803d8cce3 100644 --- a/Library/Homebrew/os/mac.rb +++ b/Library/Homebrew/os/mac.rb @@ -156,50 +156,50 @@ module OS end STANDARD_COMPILERS = { - "2.0" => { :gcc_40_build => 4061 }, - "2.5" => { :gcc_40_build => 5370 }, - "3.1.4" => { :gcc_40_build => 5493, :gcc_42_build => 5577 }, - "3.2.6" => { :gcc_40_build => 5494, :gcc_42_build => 5666, :clang => "1.7", :clang_build => 77 }, - "4.0" => { :gcc_40_build => 5494, :gcc_42_build => 5666, :clang => "2.0", :clang_build => 137 }, - "4.0.1" => { :gcc_40_build => 5494, :gcc_42_build => 5666, :clang => "2.0", :clang_build => 137 }, - "4.0.2" => { :gcc_40_build => 5494, :gcc_42_build => 5666, :clang => "2.0", :clang_build => 137 }, - "4.2" => { :clang => "3.0", :clang_build => 211 }, - "4.3" => { :clang => "3.1", :clang_build => 318 }, - "4.3.1" => { :clang => "3.1", :clang_build => 318 }, - "4.3.2" => { :clang => "3.1", :clang_build => 318 }, - "4.3.3" => { :clang => "3.1", :clang_build => 318 }, - "4.4" => { :clang => "4.0", :clang_build => 421 }, - "4.4.1" => { :clang => "4.0", :clang_build => 421 }, - "4.5" => { :clang => "4.1", :clang_build => 421 }, - "4.5.1" => { :clang => "4.1", :clang_build => 421 }, - "4.5.2" => { :clang => "4.1", :clang_build => 421 }, - "4.6" => { :clang => "4.2", :clang_build => 425 }, - "4.6.1" => { :clang => "4.2", :clang_build => 425 }, - "4.6.2" => { :clang => "4.2", :clang_build => 425 }, - "4.6.3" => { :clang => "4.2", :clang_build => 425 }, - "5.0" => { :clang => "5.0", :clang_build => 500 }, - "5.0.1" => { :clang => "5.0", :clang_build => 500 }, - "5.0.2" => { :clang => "5.0", :clang_build => 500 }, - "5.1" => { :clang => "5.1", :clang_build => 503 }, - "5.1.1" => { :clang => "5.1", :clang_build => 503 }, - "6.0" => { :clang => "6.0", :clang_build => 600 }, - "6.0.1" => { :clang => "6.0", :clang_build => 600 }, - "6.1" => { :clang => "6.0", :clang_build => 600 }, - "6.1.1" => { :clang => "6.0", :clang_build => 600 }, - "6.2" => { :clang => "6.0", :clang_build => 600 }, - "6.3" => { :clang => "6.1", :clang_build => 602 }, - "6.3.1" => { :clang => "6.1", :clang_build => 602 }, - "6.3.2" => { :clang => "6.1", :clang_build => 602 }, - "6.4" => { :clang => "6.1", :clang_build => 602 }, - "7.0" => { :clang => "7.0", :clang_build => 700 }, - "7.0.1" => { :clang => "7.0", :clang_build => 700 }, - "7.1" => { :clang => "7.0", :clang_build => 700 }, - "7.1.1" => { :clang => "7.0", :clang_build => 700 }, - "7.2" => { :clang => "7.0", :clang_build => 700 }, - "7.2.1" => { :clang => "7.0", :clang_build => 700 }, - "7.3" => { :clang => "7.3", :clang_build => 703 }, - "7.3.1" => { :clang => "7.3", :clang_build => 703 }, - "8.0" => { :clang => "8.0", :clang_build => 800 }, + "2.0" => { gcc_40_build: 4061 }, + "2.5" => { gcc_40_build: 5370 }, + "3.1.4" => { gcc_40_build: 5493, gcc_42_build: 5577 }, + "3.2.6" => { gcc_40_build: 5494, gcc_42_build: 5666, clang: "1.7", clang_build: 77 }, + "4.0" => { gcc_40_build: 5494, gcc_42_build: 5666, clang: "2.0", clang_build: 137 }, + "4.0.1" => { gcc_40_build: 5494, gcc_42_build: 5666, clang: "2.0", clang_build: 137 }, + "4.0.2" => { gcc_40_build: 5494, gcc_42_build: 5666, clang: "2.0", clang_build: 137 }, + "4.2" => { clang: "3.0", clang_build: 211 }, + "4.3" => { clang: "3.1", clang_build: 318 }, + "4.3.1" => { clang: "3.1", clang_build: 318 }, + "4.3.2" => { clang: "3.1", clang_build: 318 }, + "4.3.3" => { clang: "3.1", clang_build: 318 }, + "4.4" => { clang: "4.0", clang_build: 421 }, + "4.4.1" => { clang: "4.0", clang_build: 421 }, + "4.5" => { clang: "4.1", clang_build: 421 }, + "4.5.1" => { clang: "4.1", clang_build: 421 }, + "4.5.2" => { clang: "4.1", clang_build: 421 }, + "4.6" => { clang: "4.2", clang_build: 425 }, + "4.6.1" => { clang: "4.2", clang_build: 425 }, + "4.6.2" => { clang: "4.2", clang_build: 425 }, + "4.6.3" => { clang: "4.2", clang_build: 425 }, + "5.0" => { clang: "5.0", clang_build: 500 }, + "5.0.1" => { clang: "5.0", clang_build: 500 }, + "5.0.2" => { clang: "5.0", clang_build: 500 }, + "5.1" => { clang: "5.1", clang_build: 503 }, + "5.1.1" => { clang: "5.1", clang_build: 503 }, + "6.0" => { clang: "6.0", clang_build: 600 }, + "6.0.1" => { clang: "6.0", clang_build: 600 }, + "6.1" => { clang: "6.0", clang_build: 600 }, + "6.1.1" => { clang: "6.0", clang_build: 600 }, + "6.2" => { clang: "6.0", clang_build: 600 }, + "6.3" => { clang: "6.1", clang_build: 602 }, + "6.3.1" => { clang: "6.1", clang_build: 602 }, + "6.3.2" => { clang: "6.1", clang_build: 602 }, + "6.4" => { clang: "6.1", clang_build: 602 }, + "7.0" => { clang: "7.0", clang_build: 700 }, + "7.0.1" => { clang: "7.0", clang_build: 700 }, + "7.1" => { clang: "7.0", clang_build: 700 }, + "7.1.1" => { clang: "7.0", clang_build: 700 }, + "7.2" => { clang: "7.0", clang_build: 700 }, + "7.2.1" => { clang: "7.0", clang_build: 700 }, + "7.3" => { clang: "7.3", clang_build: 703 }, + "7.3.1" => { clang: "7.3", clang_build: 703 }, + "8.0" => { clang: "8.0", clang_build: 800 }, }.freeze def compilers_standard? diff --git a/Library/Homebrew/os/mac/cctools_mach.rb b/Library/Homebrew/os/mac/cctools_mach.rb index 7e8f9a4d3..7e8b96b83 100644 --- a/Library/Homebrew/os/mac/cctools_mach.rb +++ b/Library/Homebrew/os/mac/cctools_mach.rb @@ -44,7 +44,7 @@ module CctoolsMachO else :dunno end - mach_data << { :arch => arch, :type => type } + mach_data << { arch: arch, type: type } end mach_data rescue diff --git a/Library/Homebrew/os/mac/ruby_keg.rb b/Library/Homebrew/os/mac/ruby_keg.rb index 8f7b37419..e476b174f 100644 --- a/Library/Homebrew/os/mac/ruby_keg.rb +++ b/Library/Homebrew/os/mac/ruby_keg.rb @@ -4,7 +4,7 @@ module RubyKeg def change_dylib_id(id, file) @require_install_name_tool = true puts "Changing dylib ID of #{file}\n from #{file.dylib_id}\n to #{id}" if ARGV.debug? - MachO::Tools.change_dylib_id(file, id, :strict => false) + MachO::Tools.change_dylib_id(file, id, strict: false) rescue MachO::MachOError onoe <<-EOS.undent Failed changing dylib ID of #{file} @@ -17,7 +17,7 @@ module RubyKeg def change_install_name(old, new, file) @require_install_name_tool = true puts "Changing install name in #{file}\n from #{old}\n to #{new}" if ARGV.debug? - MachO::Tools.change_install_name(file, old, new, :strict => false) + MachO::Tools.change_install_name(file, old, new, strict: false) rescue MachO::MachOError onoe <<-EOS.undent Failed changing install name in #{file} diff --git a/Library/Homebrew/os/mac/ruby_mach.rb b/Library/Homebrew/os/mac/ruby_mach.rb index 0a1565f4f..5d0e75c31 100644 --- a/Library/Homebrew/os/mac/ruby_mach.rb +++ b/Library/Homebrew/os/mac/ruby_mach.rb @@ -33,7 +33,7 @@ module RubyMachO else :dunno end - mach_data << { :arch => arch, :type => type } + mach_data << { arch: arch, type: type } end mach_data diff --git a/Library/Homebrew/os/mac/version.rb b/Library/Homebrew/os/mac/version.rb index 8d96bd3b9..802ec3035 100644 --- a/Library/Homebrew/os/mac/version.rb +++ b/Library/Homebrew/os/mac/version.rb @@ -4,15 +4,15 @@ module OS module Mac class Version < ::Version SYMBOLS = { - :sierra => "10.12", - :el_capitan => "10.11", - :yosemite => "10.10", - :mavericks => "10.9", - :mountain_lion => "10.8", - :lion => "10.7", - :snow_leopard => "10.6", - :leopard => "10.5", - :tiger => "10.4", + sierra: "10.12", + el_capitan: "10.11", + yosemite: "10.10", + mavericks: "10.9", + mountain_lion: "10.8", + lion: "10.7", + snow_leopard: "10.6", + leopard: "10.5", + tiger: "10.4", }.freeze def self.from_symbol(sym) diff --git a/Library/Homebrew/patch.rb b/Library/Homebrew/patch.rb index 9adb1ffee..1148389cf 100644 --- a/Library/Homebrew/patch.rb +++ b/Library/Homebrew/patch.rb @@ -29,7 +29,7 @@ module Patch when Hash list when Array, String, :DATA - { :p1 => list } + { p1: list } else {} end.each_pair do |strip, urls| @@ -130,7 +130,7 @@ class ExternalPatch patch_dir = Pathname.pwd if patch_files.empty? children = patch_dir.children - if (children.length == 1 && children.first.file?) + if children.length == 1 && children.first.file? patch_files << children.first.basename else raise MissingApplyError, <<-EOS.undent diff --git a/Library/Homebrew/requirement.rb b/Library/Homebrew/requirement.rb index 7a40d419e..4ea15774d 100644 --- a/Library/Homebrew/requirement.rb +++ b/Library/Homebrew/requirement.rb @@ -165,7 +165,7 @@ class Requirement def initialize(options, &block) case options when Hash - @options = { :build_env => true } + @options = { build_env: true } @options.merge!(options) else @satisfied = options diff --git a/Library/Homebrew/requirements.rb b/Library/Homebrew/requirements.rb index e709ff9cc..68d21a2b7 100644 --- a/Library/Homebrew/requirements.rb +++ b/Library/Homebrew/requirements.rb @@ -19,7 +19,7 @@ require "requirements/emacs_requirement" class XcodeRequirement < Requirement fatal true - satisfy(:build_env => false) { xcode_installed_version } + satisfy(build_env: false) { xcode_installed_version } def initialize(tags) @version = tags.find { |t| tags.delete(t) if /(\d\.)+\d/ === t } @@ -102,7 +102,7 @@ class ArchRequirement < Requirement super end - satisfy(:build_env => false) do + satisfy(build_env: false) do case @arch when :x86_64 then MacOS.prefer_64_bit? when :intel, :ppc then Hardware::CPU.type == @arch diff --git a/Library/Homebrew/requirements/apr_requirement.rb b/Library/Homebrew/requirements/apr_requirement.rb index 3b0a910e4..9c07eeaeb 100644 --- a/Library/Homebrew/requirements/apr_requirement.rb +++ b/Library/Homebrew/requirements/apr_requirement.rb @@ -5,7 +5,7 @@ class AprRequirement < Requirement default_formula "apr-util" # APR shipped in Tiger is too old, but Leopard+ is usable - satisfy(:build_env => false) { MacOS.version > :leopard && MacOS::CLT.installed? } + satisfy(build_env: false) { MacOS.version > :leopard && MacOS::CLT.installed? } env do unless MacOS::CLT.installed? diff --git a/Library/Homebrew/requirements/cctools_requirement.rb b/Library/Homebrew/requirements/cctools_requirement.rb index 65a10b4b6..ef0cd680c 100644 --- a/Library/Homebrew/requirements/cctools_requirement.rb +++ b/Library/Homebrew/requirements/cctools_requirement.rb @@ -7,7 +7,7 @@ class CctoolsRequirement < Requirement fatal true default_formula "cctools" - satisfy(:build_env => false) do + satisfy(build_env: false) do MacOS::Xcode.installed? || MacOS::CLT.installed? || Formula["cctools"].installed? end end diff --git a/Library/Homebrew/requirements/emacs_requirement.rb b/Library/Homebrew/requirements/emacs_requirement.rb index 737f57264..c8e2ec274 100644 --- a/Library/Homebrew/requirements/emacs_requirement.rb +++ b/Library/Homebrew/requirements/emacs_requirement.rb @@ -7,7 +7,7 @@ class EmacsRequirement < Requirement super end - satisfy :build_env => false do + satisfy build_env: false do next false unless which "emacs" next true unless @version emacs_version = Utils.popen_read("emacs", "--batch", "--eval", "(princ emacs-version)") diff --git a/Library/Homebrew/requirements/fortran_requirement.rb b/Library/Homebrew/requirements/fortran_requirement.rb index 9d58950fc..ba3fead6f 100644 --- a/Library/Homebrew/requirements/fortran_requirement.rb +++ b/Library/Homebrew/requirements/fortran_requirement.rb @@ -7,7 +7,7 @@ class FortranRequirement < Requirement env { ENV.fortran } - satisfy :build_env => false do + satisfy build_env: false do which(ENV["FC"] || "gfortran") end end diff --git a/Library/Homebrew/requirements/gpg2_requirement.rb b/Library/Homebrew/requirements/gpg2_requirement.rb index 9eea59e78..00bf4183a 100644 --- a/Library/Homebrew/requirements/gpg2_requirement.rb +++ b/Library/Homebrew/requirements/gpg2_requirement.rb @@ -8,5 +8,5 @@ class GPG2Requirement < Requirement # MacGPG2/GPGTools installs GnuPG 2.0.x as a vanilla `gpg` symlink # pointing to `gpg2`, as do we. Ensure we're actually using a 2.0 `gpg`. # Temporarily, only support 2.0.x rather than the 2.1.x "modern" series. - satisfy(:build_env => false) { Gpg.gpg2 || Gpg.gpg } + satisfy(build_env: false) { Gpg.gpg2 || Gpg.gpg } end diff --git a/Library/Homebrew/requirements/java_requirement.rb b/Library/Homebrew/requirements/java_requirement.rb index ff451c688..c868e0f3f 100644 --- a/Library/Homebrew/requirements/java_requirement.rb +++ b/Library/Homebrew/requirements/java_requirement.rb @@ -5,7 +5,7 @@ class JavaRequirement < Requirement cask "java" download "http://www.oracle.com/technetwork/java/javase/downloads/index.html" - satisfy :build_env => false do + satisfy build_env: false do next false unless File.executable? "/usr/libexec/java_home" args = %w[--failfast] diff --git a/Library/Homebrew/requirements/language_module_requirement.rb b/Library/Homebrew/requirements/language_module_requirement.rb index 185777013..7091a690a 100644 --- a/Library/Homebrew/requirements/language_module_requirement.rb +++ b/Library/Homebrew/requirements/language_module_requirement.rb @@ -10,7 +10,7 @@ class LanguageModuleRequirement < Requirement super([language, module_name, import_name]) end - satisfy(:build_env => false) { quiet_system(*the_test) } + satisfy(build_env: false) { quiet_system(*the_test) } def message s = <<-EOS.undent diff --git a/Library/Homebrew/requirements/maximum_macos_requirement.rb b/Library/Homebrew/requirements/maximum_macos_requirement.rb index 9f5b42d54..ad60af063 100644 --- a/Library/Homebrew/requirements/maximum_macos_requirement.rb +++ b/Library/Homebrew/requirements/maximum_macos_requirement.rb @@ -8,7 +8,7 @@ class MaximumMacOSRequirement < Requirement super end - satisfy(:build_env => false) { MacOS.version <= @version } + satisfy(build_env: false) { MacOS.version <= @version } def message <<-EOS.undent diff --git a/Library/Homebrew/requirements/minimum_macos_requirement.rb b/Library/Homebrew/requirements/minimum_macos_requirement.rb index 0ff393a79..f128a6615 100644 --- a/Library/Homebrew/requirements/minimum_macos_requirement.rb +++ b/Library/Homebrew/requirements/minimum_macos_requirement.rb @@ -8,7 +8,7 @@ class MinimumMacOSRequirement < Requirement super end - satisfy(:build_env => false) { MacOS.version >= @version } + satisfy(build_env: false) { MacOS.version >= @version } def message "OS X #{@version.pretty_name} or newer is required." diff --git a/Library/Homebrew/requirements/osxfuse_requirement.rb b/Library/Homebrew/requirements/osxfuse_requirement.rb index 520f7037e..63ccf934f 100644 --- a/Library/Homebrew/requirements/osxfuse_requirement.rb +++ b/Library/Homebrew/requirements/osxfuse_requirement.rb @@ -5,7 +5,7 @@ class OsxfuseRequirement < Requirement cask "osxfuse" download "https://osxfuse.github.io/" - satisfy(:build_env => false) { self.class.binary_osxfuse_installed? } + satisfy(build_env: false) { self.class.binary_osxfuse_installed? } def self.binary_osxfuse_installed? File.exist?("/usr/local/include/osxfuse/fuse.h") && @@ -19,7 +19,7 @@ end class NonBinaryOsxfuseRequirement < Requirement fatal true - satisfy(:build_env => false) { HOMEBREW_PREFIX.to_s != "/usr/local" || !OsxfuseRequirement.binary_osxfuse_installed? } + satisfy(build_env: false) { HOMEBREW_PREFIX.to_s != "/usr/local" || !OsxfuseRequirement.binary_osxfuse_installed? } def message <<-EOS.undent diff --git a/Library/Homebrew/requirements/perl_requirement.rb b/Library/Homebrew/requirements/perl_requirement.rb index 6d7484175..007134191 100644 --- a/Library/Homebrew/requirements/perl_requirement.rb +++ b/Library/Homebrew/requirements/perl_requirement.rb @@ -8,7 +8,7 @@ class PerlRequirement < Requirement super end - satisfy(:build_env => false) do + satisfy(build_env: false) do which_all("perl").detect do |perl| perl_version = Utils.popen_read(perl, "--version")[/\(v(\d+\.\d+)(?:\.\d+)?\)/, 1] next unless perl_version diff --git a/Library/Homebrew/requirements/python_requirement.rb b/Library/Homebrew/requirements/python_requirement.rb index 2800f52b0..478f6286e 100644 --- a/Library/Homebrew/requirements/python_requirement.rb +++ b/Library/Homebrew/requirements/python_requirement.rb @@ -5,7 +5,7 @@ class PythonRequirement < Requirement default_formula "python" cask "python" - satisfy :build_env => false do + satisfy build_env: false do python = which_python next unless python version = python_short_version @@ -58,7 +58,7 @@ class Python3Requirement < PythonRequirement default_formula "python3" cask "python3" - satisfy(:build_env => false) { which_python } + satisfy(build_env: false) { which_python } def python_binary "python3" diff --git a/Library/Homebrew/requirements/ruby_requirement.rb b/Library/Homebrew/requirements/ruby_requirement.rb index dd0039638..873f285bf 100644 --- a/Library/Homebrew/requirements/ruby_requirement.rb +++ b/Library/Homebrew/requirements/ruby_requirement.rb @@ -8,7 +8,7 @@ class RubyRequirement < Requirement super end - satisfy :build_env => false do + satisfy build_env: false do which_all("ruby").detect do |ruby| version = /\d\.\d/.match Utils.popen_read(ruby, "--version") next unless version diff --git a/Library/Homebrew/requirements/tuntap_requirement.rb b/Library/Homebrew/requirements/tuntap_requirement.rb index 76f1744a2..3ae142080 100644 --- a/Library/Homebrew/requirements/tuntap_requirement.rb +++ b/Library/Homebrew/requirements/tuntap_requirement.rb @@ -3,7 +3,7 @@ require "requirement" class TuntapRequirement < Requirement fatal true cask "tuntap" - satisfy(:build_env => false) { self.class.binary_tuntap_installed? } + satisfy(build_env: false) { self.class.binary_tuntap_installed? } def self.binary_tuntap_installed? %w[ diff --git a/Library/Homebrew/requirements/unsigned_kext_requirement.rb b/Library/Homebrew/requirements/unsigned_kext_requirement.rb index 390004687..f57be6577 100644 --- a/Library/Homebrew/requirements/unsigned_kext_requirement.rb +++ b/Library/Homebrew/requirements/unsigned_kext_requirement.rb @@ -3,7 +3,7 @@ require "requirement" class UnsignedKextRequirement < Requirement fatal true - satisfy(:build_env => false) { MacOS.version < :yosemite } + satisfy(build_env: false) { MacOS.version < :yosemite } def message s = <<-EOS.undent diff --git a/Library/Homebrew/requirements/x11_requirement.rb b/Library/Homebrew/requirements/x11_requirement.rb index 6a320401a..03d0382c5 100644 --- a/Library/Homebrew/requirements/x11_requirement.rb +++ b/Library/Homebrew/requirements/x11_requirement.rb @@ -22,7 +22,7 @@ class X11Requirement < Requirement super(tags) end - satisfy :build_env => false do + satisfy build_env: false do MacOS::XQuartz.installed? && min_version <= Version.create(MacOS::XQuartz.version) end diff --git a/Library/Homebrew/sandbox.rb b/Library/Homebrew/sandbox.rb index dece2e4a5..9392b7122 100644 --- a/Library/Homebrew/sandbox.rb +++ b/Library/Homebrew/sandbox.rb @@ -42,25 +42,25 @@ class Sandbox end def allow_write(path, options = {}) - add_rule :allow => true, :operation => "file-write*", :filter => path_filter(path, options[:type]) + add_rule allow: true, operation: "file-write*", filter: path_filter(path, options[:type]) end def deny_write(path, options = {}) - add_rule :allow => false, :operation => "file-write*", :filter => path_filter(path, options[:type]) + add_rule allow: false, operation: "file-write*", filter: path_filter(path, options[:type]) end def allow_write_path(path) - allow_write path, :type => :subpath + allow_write path, type: :subpath end def deny_write_path(path) - deny_write path, :type => :subpath + deny_write path, type: :subpath end def allow_write_temp_and_cache allow_write_path "/private/tmp" allow_write_path "/private/var/tmp" - allow_write "^/private/var/folders/[^/]+/[^/]+/[C,T]/", :type => :regex + allow_write "^/private/var/folders/[^/]+/[^/]+/[C,T]/", type: :regex allow_write_path HOMEBREW_TEMP allow_write_path HOMEBREW_CACHE end @@ -111,7 +111,7 @@ class Sandbox logs = Utils.popen_read("syslog", *syslog_args) # These messages are confusing and non-fatal, so don't report them. - logs = logs.lines.reject{ |l| l.match(/^.*Python\(\d+\) deny file-write.*pyc$/) }.join + logs = logs.lines.reject { |l| l.match(/^.*Python\(\d+\) deny file-write.*pyc$/) }.join unless logs.empty? if @logfile diff --git a/Library/Homebrew/software_spec.rb b/Library/Homebrew/software_spec.rb index 84b94ce48..f935d9a13 100644 --- a/Library/Homebrew/software_spec.rb +++ b/Library/Homebrew/software_spec.rb @@ -15,8 +15,8 @@ class SoftwareSpec PREDEFINED_OPTIONS = { :universal => Option.new("universal", "Build a universal binary"), :cxx11 => Option.new("c++11", "Build using C++11 mode"), - "32-bit" => Option.new("32-bit", "Build 32-bit only") - } + "32-bit" => Option.new("32-bit", "Build 32-bit only"), + }.freeze attr_reader :name, :full_name, :owner attr_reader :build, :resources, :patches, :options @@ -72,9 +72,7 @@ class SoftwareSpec !!@bottle_disable_reason end - def bottle_disable_reason - @bottle_disable_reason - end + attr_reader :bottle_disable_reason def bottle_defined? !bottle_specification.collector.keys.empty? @@ -85,7 +83,7 @@ class SoftwareSpec (bottle_specification.compatible_cellar? || ARGV.force_bottle?) end - def bottle(disable_type = nil, disable_reason = nil, &block) + def bottle(disable_type = nil, disable_reason = nil, &block) if disable_type @bottle_disable_reason = BottleDisableReason.new(disable_type, disable_reason) else @@ -99,7 +97,7 @@ class SoftwareSpec def resource(name, klass = Resource, &block) if block_given? - raise DuplicateResourceError.new(name) if resource_defined?(name) + raise DuplicateResourceError, name if resource_defined?(name) res = klass.new(name, &block) resources[name] = res dependency_collector.add(res) @@ -144,11 +142,10 @@ class SoftwareSpec old_flag = deprecated_option.old_flag new_flag = deprecated_option.current_flag - if @flags.include? old_flag - @flags -= [old_flag] - @flags |= [new_flag] - @deprecated_flags << deprecated_option - end + next unless @flags.include? old_flag + @flags -= [old_flag] + @flags |= [new_flag] + @deprecated_flags << deprecated_option end end end @@ -340,7 +337,13 @@ class BottleSpecification def checksums checksums = {} os_versions = collector.keys - os_versions.map! { |osx| MacOS::Version.from_symbol osx rescue nil }.compact! + os_versions.map! do |osx| + begin + MacOS::Version.from_symbol osx + rescue + nil + end + end.compact! os_versions.sort.reverse_each do |os_version| osx = os_version.to_sym checksum = collector[osx] diff --git a/Library/Homebrew/system_config.rb b/Library/Homebrew/system_config.rb index 516c9c20a..830c9ec33 100644 --- a/Library/Homebrew/system_config.rb +++ b/Library/Homebrew/system_config.rb @@ -57,7 +57,7 @@ class SystemConfig end def describe_perl - describe_path(which "perl") + describe_path(which("perl")) end def describe_python diff --git a/Library/Homebrew/tab.rb b/Library/Homebrew/tab.rb index 69e44d9dd..53338a035 100644 --- a/Library/Homebrew/tab.rb +++ b/Library/Homebrew/tab.rb @@ -9,7 +9,7 @@ require "development_tools" # should not be called directly, instead use one of the class methods like # `Tab.create`. class Tab < OpenStruct - FILENAME = "INSTALL_RECEIPT.json" + FILENAME = "INSTALL_RECEIPT.json".freeze CACHE = {} def self.clear_cache @@ -39,8 +39,8 @@ class Tab < OpenStruct "devel" => formula.devel ? formula.devel.version.to_s : nil, "head" => formula.head ? formula.head.version.to_s : nil, "version_scheme" => formula.version_scheme, - } - } + }, + }, } new(attributes) @@ -65,7 +65,7 @@ class Tab < OpenStruct end if attributes["source"]["tap"] == "mxcl/master" || - attributes["source"]["tap"] == "Homebrew/homebrew" + attributes["source"]["tap"] == "Homebrew/homebrew" attributes["source"]["tap"] = "homebrew/core" end @@ -154,7 +154,7 @@ class Tab < OpenStruct "devel" => f.devel ? f.devel.version.to_s : nil, "head" => f.head ? f.head.version.to_s : nil, "version_scheme" => f.version_scheme, - } + }, } end @@ -181,8 +181,8 @@ class Tab < OpenStruct "devel" => nil, "head" => nil, "version_scheme" => 0, - } - } + }, + }, } new(attributes) @@ -303,7 +303,7 @@ class Tab < OpenStruct "HEAD" => self.HEAD, "stdlib" => (stdlib.to_s if stdlib), "compiler" => (compiler.to_s if compiler), - "source" => source + "source" => source, } Utils::JSON.dump(attributes) diff --git a/Library/Homebrew/tap.rb b/Library/Homebrew/tap.rb index 340f6eca3..ecf81ca37 100644 --- a/Library/Homebrew/tap.rb +++ b/Library/Homebrew/tap.rb @@ -215,7 +215,7 @@ class Tap begin safe_system "git", *args - unless Readall.valid_tap?(self, :aliases => true) + unless Readall.valid_tap?(self, aliases: true) unless ARGV.homebrew_developer? raise "Cannot tap #{name}: invalid syntax in tap!" end @@ -280,7 +280,7 @@ class Tap # True if the {#remote} of {Tap} is customized. def custom_remote? return true unless remote - remote.casecmp(default_remote) != 0 + remote.casecmp(default_remote).nonzero? end # path to the directory of all {Formula} files for this {Tap}. @@ -356,7 +356,7 @@ class Tap # @private def alias_table return @alias_table if @alias_table - @alias_table = Hash.new + @alias_table = {} alias_files.each do |alias_file| @alias_table[alias_file_to_name(alias_file)] = formula_file_to_name(alias_file.resolved_path) end @@ -367,7 +367,7 @@ class Tap # @private def alias_reverse_table return @alias_reverse_table if @alias_reverse_table - @alias_reverse_table = Hash.new + @alias_reverse_table = {} alias_table.each do |alias_name, formula_name| @alias_reverse_table[formula_name] ||= [] @alias_reverse_table[formula_name] << alias_name @@ -421,7 +421,7 @@ class Tap "formula_names" => formula_names, "formula_files" => formula_files.map(&:to_s), "command_files" => command_files.map(&:to_s), - "pinned" => pinned? + "pinned" => pinned?, } if installed? @@ -457,7 +457,7 @@ class Tap def ==(other) other = Tap.fetch(other) if other.is_a?(String) - self.class == other.class && self.name == other.name + self.class == other.class && name == other.name end def self.each @@ -505,7 +505,6 @@ class Tap end end end - end # A specialized {Tap} class for the core formulae diff --git a/Library/Homebrew/test/Gemfile b/Library/Homebrew/test/Gemfile index c7c146233..b7666e551 100644 --- a/Library/Homebrew/test/Gemfile +++ b/Library/Homebrew/test/Gemfile @@ -10,8 +10,8 @@ group :coverage do # back to stable as soon as v0.12.1 or v0.13.0 is released. See pull request # <https://github.com/Homebrew/legacy-homebrew/pull/48250> for full details. gem "simplecov", "0.12.0", - :git => "https://github.com/colszowka/simplecov.git", - :branch => "master", # commit 257e26394c464c4ab388631b4eff1aa98c37d3f1 - :require => false + git: "https://github.com/colszowka/simplecov.git", + branch: "master", # commit 257e26394c464c4ab388631b4eff1aa98c37d3f1 + require: false gem "codecov", require: false end diff --git a/Library/Homebrew/test/Rakefile b/Library/Homebrew/test/Rakefile index 3841badab..a2db861f2 100644 --- a/Library/Homebrew/test/Rakefile +++ b/Library/Homebrew/test/Rakefile @@ -11,7 +11,7 @@ TEST_FILES = Dir["#{TEST_DIRECTORY}/test_*.rb"].reject do |f| f.include?("/test_os_mac_") && !mac? end -task :default => :test +task default: :test Rake::TestTask.new(:test) do |t| t.libs << TEST_DIRECTORY diff --git a/Library/Homebrew/test/test_cmd_audit.rb b/Library/Homebrew/test/test_cmd_audit.rb index 9c672f634..98ab780b4 100644 --- a/Library/Homebrew/test/test_cmd_audit.rb +++ b/Library/Homebrew/test/test_cmd_audit.rb @@ -50,7 +50,7 @@ class FormulaTextTests < Homebrew::TestCase end def test_has_end - ft = formula_text "end", "", :patch => "__END__\na patch here" + ft = formula_text "end", "", patch: "__END__\na patch here" assert ft.end?, "The formula must have __END__" assert_equal "class End < Formula\n \nend", ft.without_patch end @@ -138,7 +138,7 @@ class FormulaAuditorTests < Homebrew::TestCase end def test_audit_file_strict_ordering_issue - fa = formula_auditor "foo", <<-EOS.undent, :strict => true + fa = formula_auditor "foo", <<-EOS.undent, strict: true class Foo < Formula url "http://example.com/foo-1.0.tgz" homepage "http://example.com" @@ -150,7 +150,7 @@ class FormulaAuditorTests < Homebrew::TestCase end def test_audit_file_strict_resource_placement - fa = formula_auditor "foo", <<-EOS.undent, :strict => true + fa = formula_auditor "foo", <<-EOS.undent, strict: true class Foo < Formula url "https://example.com/foo-1.0.tgz" @@ -167,7 +167,7 @@ class FormulaAuditorTests < Homebrew::TestCase end def test_audit_file_strict_plist_placement - fa = formula_auditor "foo", <<-EOS.undent, :strict => true + fa = formula_auditor "foo", <<-EOS.undent, strict: true class Foo < Formula url "https://example.com/foo-1.0.tgz" @@ -185,7 +185,7 @@ class FormulaAuditorTests < Homebrew::TestCase end def test_audit_file_strict_url_outside_of_stable_block - fa = formula_auditor "foo", <<-EOS.undent, :strict => true + fa = formula_auditor "foo", <<-EOS.undent, strict: true class Foo < Formula url "http://example.com/foo-1.0.tgz" stable do @@ -198,7 +198,7 @@ class FormulaAuditorTests < Homebrew::TestCase end def test_audit_file_strict_head_and_head_do - fa = formula_auditor "foo", <<-EOS.undent, :strict => true + fa = formula_auditor "foo", <<-EOS.undent, strict: true class Foo < Formula head "http://example.com/foo.git" head do @@ -211,7 +211,7 @@ class FormulaAuditorTests < Homebrew::TestCase end def test_audit_file_strict_bottle_and_bottle_do - fa = formula_auditor "foo", <<-EOS.undent, :strict => true + fa = formula_auditor "foo", <<-EOS.undent, strict: true class Foo < Formula url "http://example.com/foo-1.0.tgz" bottle do @@ -234,7 +234,7 @@ class FormulaAuditorTests < Homebrew::TestCase fa.audit_class assert_equal [], fa.problems - fa = formula_auditor "foo", <<-EOS.undent, :strict => true + fa = formula_auditor "foo", <<-EOS.undent, strict: true class Foo < Formula url "http://example.com/foo-1.0.tgz" end @@ -291,7 +291,7 @@ class FormulaAuditorTests < Homebrew::TestCase end def test_audit_line_pkgshare - fa = formula_auditor "foo", <<-EOS.undent, :strict => true + fa = formula_auditor "foo", <<-EOS.undent, strict: true class Foo < Formula url "http://example.com/foo-1.0.tgz" end @@ -320,7 +320,7 @@ class FormulaAuditorTests < Homebrew::TestCase # Formulae with "++" in their name would break various audit regexps: # Error: nested *?+ in regexp: /^libxml++3\s/ def test_audit_plus_plus_name - fa = formula_auditor "foolibc++", <<-EOS.undent, :strict => true + fa = formula_auditor "foolibc++", <<-EOS.undent, strict: true class Foolibcxx < Formula desc "foolibc++ is a test" url "http://example.com/foo-1.0.tgz" @@ -358,7 +358,7 @@ class FormulaAuditorTests < Homebrew::TestCase end def test_audit_github_repository_no_api - fa = formula_auditor "foo", <<-EOS.undent, :strict => true, :online => true + fa = formula_auditor "foo", <<-EOS.undent, strict: true, online: true class Foo < Formula homepage "https://github.com/example/example" url "http://example.com/foo-1.0.tgz" @@ -393,14 +393,14 @@ class FormulaAuditorTests < Homebrew::TestCase def test_audit_desc formula_descriptions = [ - { :name => "foo", :desc => nil, - :problem => "Formula should have a desc" }, - { :name => "bar", :desc => "bar" * 30, - :problem => "Description is too long" }, - { :name => "baz", :desc => "Baz commandline tool", - :problem => "Description should use \"command-line\"" }, - { :name => "qux", :desc => "A tool called Qux", - :problem => "Description shouldn't start with an indefinite article" }, + { name: "foo", desc: nil, + problem: "Formula should have a desc" }, + { name: "bar", desc: "bar" * 30, + problem: "Description is too long" }, + { name: "baz", desc: "Baz commandline tool", + problem: "Description should use \"command-line\"" }, + { name: "qux", desc: "A tool called Qux", + problem: "Description shouldn't start with an indefinite article" }, ] formula_descriptions.each do |formula| @@ -411,14 +411,14 @@ class FormulaAuditorTests < Homebrew::TestCase end EOS - fa = formula_auditor formula[:name], content, :strict => true + fa = formula_auditor formula[:name], content, strict: true fa.audit_desc assert_match formula[:problem], fa.problems.first end end def test_audit_homepage - fa = formula_auditor "foo", <<-EOS.undent, :online => true + fa = formula_auditor "foo", <<-EOS.undent, online: true class Foo < Formula homepage "ftp://example.com/foo" url "http://example.com/foo-1.0.tgz" diff --git a/Library/Homebrew/test/test_cmd_testbot.rb b/Library/Homebrew/test/test_cmd_testbot.rb index a696b9e95..d762448d1 100644 --- a/Library/Homebrew/test/test_cmd_testbot.rb +++ b/Library/Homebrew/test/test_cmd_testbot.rb @@ -52,8 +52,8 @@ class TestbotStepTests < Homebrew::TestCase def stub_test_instance stub( - :category => "stub", - :log_root => Pathname.pwd + category: "stub", + log_root: Pathname.pwd ) end diff --git a/Library/Homebrew/test/test_compiler_failure.rb b/Library/Homebrew/test/test_compiler_failure.rb index d907c93a3..db2ba6371 100644 --- a/Library/Homebrew/test/test_compiler_failure.rb +++ b/Library/Homebrew/test/test_compiler_failure.rb @@ -37,14 +37,14 @@ class CompilerFailureTests < Homebrew::TestCase end def test_create_with_hash - failure = create(:gcc => "4.8") + failure = create(gcc: "4.8") assert_fails_with compiler("gcc-4.8", "4.8"), failure assert_fails_with compiler("gcc-4.8", "4.8.1"), failure refute_fails_with compiler("gcc-4.7", "4.7"), failure end def test_create_with_hash_and_version - failure = create(:gcc => "4.8") { version "4.8.1" } + failure = create(gcc: "4.8") { version "4.8.1" } assert_fails_with compiler("gcc-4.8", "4.8"), failure assert_fails_with compiler("gcc-4.8", "4.8.1"), failure refute_fails_with compiler("gcc-4.8", "4.8.2"), failure diff --git a/Library/Homebrew/test/test_compiler_selector.rb b/Library/Homebrew/test/test_compiler_selector.rb index d030d48ce..0363cacd2 100644 --- a/Library/Homebrew/test/test_compiler_selector.rb +++ b/Library/Homebrew/test/test_compiler_selector.rb @@ -42,7 +42,7 @@ class CompilerSelectorTests < Homebrew::TestCase end def test_all_compiler_failures - @f << :clang << :llvm << :gcc << { :gcc => "4.8" } << { :gcc => "4.7" } + @f << :clang << :llvm << :gcc << { gcc: "4.8" } << { gcc: "4.7" } assert_raises(CompilerSelectionError) { actual_cc } end @@ -66,7 +66,7 @@ class CompilerSelectorTests < Homebrew::TestCase end def test_fails_with_non_apple_gcc - @f << { :gcc => "4.8" } + @f << { gcc: "4.8" } assert_equal :clang, actual_cc end @@ -86,12 +86,12 @@ class CompilerSelectorTests < Homebrew::TestCase end def test_mixed_failures_4 - @f << :clang << { :gcc => "4.8" } + @f << :clang << { gcc: "4.8" } assert_equal :gcc, actual_cc end def test_mixed_failures_5 - @f << :clang << :gcc << :llvm << { :gcc => "4.8" } + @f << :clang << :gcc << :llvm << { gcc: "4.8" } assert_equal "gcc-4.7", actual_cc end @@ -102,13 +102,13 @@ class CompilerSelectorTests < Homebrew::TestCase def test_missing_gcc @versions.gcc_build_version = nil - @f << :clang << :llvm << { :gcc => "4.8" } << { :gcc => "4.7" } + @f << :clang << :llvm << { gcc: "4.8" } << { gcc: "4.7" } assert_raises(CompilerSelectionError) { actual_cc } end def test_missing_llvm_and_gcc @versions.gcc_build_version = nil - @f << :clang << { :gcc => "4.8" } << { :gcc => "4.7" } + @f << :clang << { gcc: "4.8" } << { gcc: "4.7" } assert_raises(CompilerSelectionError) { actual_cc } end end diff --git a/Library/Homebrew/test/test_dependency_collector.rb b/Library/Homebrew/test/test_dependency_collector.rb index 9ef2a8cc7..a94b4959e 100644 --- a/Library/Homebrew/test/test_dependency_collector.rb +++ b/Library/Homebrew/test/test_dependency_collector.rb @@ -48,8 +48,8 @@ class DependencyCollectorTests < Homebrew::TestCase end def test_requirement_tags - @d.add :x11 => "2.5.1" - @d.add :xcode => :build + @d.add x11: "2.5.1" + @d.add xcode: :build assert_empty find_requirement(X11Requirement).tags assert_predicate find_requirement(XcodeRequirement), :build? end @@ -60,17 +60,17 @@ class DependencyCollectorTests < Homebrew::TestCase end def test_x11_min_version - @d.add :x11 => "2.5.1" + @d.add x11: "2.5.1" assert_equal "2.5.1", find_requirement(X11Requirement).min_version.to_s end def test_x11_tag - @d.add :x11 => :optional + @d.add x11: :optional assert_predicate find_requirement(X11Requirement), :optional? end def test_x11_min_version_and_tag - @d.add :x11 => ["2.5.1", :optional] + @d.add x11: ["2.5.1", :optional] dep = find_requirement(X11Requirement) assert_equal "2.5.1", dep.min_version.to_s assert_predicate dep, :optional? diff --git a/Library/Homebrew/test/test_dependency_expansion.rb b/Library/Homebrew/test/test_dependency_expansion.rb index 97bf70eab..9d6de35e2 100644 --- a/Library/Homebrew/test/test_dependency_expansion.rb +++ b/Library/Homebrew/test/test_dependency_expansion.rb @@ -4,7 +4,7 @@ require "dependency" class DependencyExpansionTests < Homebrew::TestCase def build_dep(name, tags = [], deps = []) dep = Dependency.new(name.to_s, tags) - dep.stubs(:to_formula).returns(stub(:deps => deps, :name => name)) + dep.stubs(:to_formula).returns(stub(deps: deps, name: name)) dep end @@ -14,7 +14,7 @@ class DependencyExpansionTests < Homebrew::TestCase @baz = build_dep(:baz) @qux = build_dep(:qux) @deps = [@foo, @bar, @baz, @qux] - @f = stub(:deps => @deps, :name => "f") + @f = stub(deps: @deps, name: "f") end def test_expand_yields_dependent_and_dep_pairs @@ -43,19 +43,19 @@ class DependencyExpansionTests < Homebrew::TestCase end def test_expand_preserves_dependency_order - @foo.stubs(:to_formula).returns(stub(:name => "f", :deps => [@qux, @baz])) + @foo.stubs(:to_formula).returns(stub(name: "f", deps: [@qux, @baz])) assert_equal [@qux, @baz, @foo, @bar], Dependency.expand(@f) end def test_expand_skips_optionals_by_default deps = [build_dep(:foo, [:optional]), @bar, @baz, @qux] - f = stub(:deps => deps, :build => stub(:with? => false), :name => "f") + f = stub(deps: deps, build: stub(with?: false), name: "f") assert_equal [@bar, @baz, @qux], Dependency.expand(f) end def test_expand_keeps_recommendeds_by_default deps = [build_dep(:foo, [:recommended]), @bar, @baz, @qux] - f = stub(:deps => deps, :build => stub(:with? => true), :name => "f") + f = stub(deps: deps, build: stub(with?: true), name: "f") assert_equal deps, Dependency.expand(f) end @@ -73,7 +73,7 @@ class DependencyExpansionTests < Homebrew::TestCase def test_merger_preserves_env_proc env_proc = stub dep = Dependency.new("foo", [], env_proc) - dep.stubs(:to_formula).returns(stub(:deps => [], :name => "foo")) + dep.stubs(:to_formula).returns(stub(deps: [], name: "foo")) @deps.replace [dep] assert_equal env_proc, Dependency.expand(@f).first.env_proc end @@ -88,8 +88,8 @@ class DependencyExpansionTests < Homebrew::TestCase def test_skip_skips_parent_but_yields_children f = stub( - :name => "f", - :deps => [ + name: "f", + deps: [ build_dep(:foo, [], [@bar, @baz]), build_dep(:foo, [], [@baz]), ] @@ -105,7 +105,7 @@ class DependencyExpansionTests < Homebrew::TestCase def test_keep_dep_but_prune_recursive_deps foo = build_dep(:foo, [:build], @bar) baz = build_dep(:baz, [:build]) - f = stub(:name => "f", :deps => [foo, baz]) + f = stub(name: "f", deps: [foo, baz]) deps = Dependency.expand(f) do |_dependent, dep| Dependency.keep_but_prune_recursive_deps if dep.build? @@ -122,15 +122,15 @@ class DependencyExpansionTests < Homebrew::TestCase def test_cyclic_dependency foo = build_dep(:foo) bar = build_dep(:bar, [], [foo]) - foo.stubs(:to_formula).returns(stub(:deps => [bar], :name => "foo")) - f = stub(:name => "f", :deps => [foo, bar]) + foo.stubs(:to_formula).returns(stub(deps: [bar], name: "foo")) + f = stub(name: "f", deps: [foo, bar]) assert_nothing_raised { Dependency.expand(f) } end def test_clean_expand_stack foo = build_dep(:foo) foo.stubs(:to_formula).raises(FormulaUnavailableError, "foo") - f = stub(:name => "f", :deps => [foo]) + f = stub(name: "f", deps: [foo]) assert_raises(FormulaUnavailableError) { Dependency.expand(f) } assert_empty Dependency.instance_variable_get(:@expand_stack) end diff --git a/Library/Homebrew/test/test_download_strategies.rb b/Library/Homebrew/test/test_download_strategies.rb index 3f371d461..d107d14e8 100644 --- a/Library/Homebrew/test/test_download_strategies.rb +++ b/Library/Homebrew/test/test_download_strategies.rb @@ -21,7 +21,7 @@ class AbstractDownloadStrategyTests < Homebrew::TestCase end def test_expand_safe_system_args_with_explicit_quiet_flag - @args << { :quiet_flag => "--flag" } + @args << { quiet_flag: "--flag" } expanded_args = @strategy.expand_safe_system_args(@args) assert_equal %w[foo bar baz --flag], expanded_args end @@ -39,8 +39,8 @@ class AbstractDownloadStrategyTests < Homebrew::TestCase def test_source_modified_time mktemp "mtime" do - touch "foo", :mtime => Time.now - 10 - touch "bar", :mtime => Time.now - 100 + touch "foo", mtime: Time.now - 10 + touch "bar", mtime: Time.now - 100 ln_s "not-exist", "baz" assert_equal File.mtime("foo"), @strategy.source_modified_time end diff --git a/Library/Homebrew/test/test_exceptions.rb b/Library/Homebrew/test/test_exceptions.rb index 4926b0c40..671b433e4 100644 --- a/Library/Homebrew/test/test_exceptions.rb +++ b/Library/Homebrew/test/test_exceptions.rb @@ -32,7 +32,7 @@ class ExceptionsTest < Homebrew::TestCase end def test_tap_formula_unavailable_error - t = stub(:user => "u", :repo => "r", :to_s => "u/r", :installed? => false) + t = stub(user: "u", repo: "r", to_s: "u/r", installed?: false) assert_match "Please tap it and then try again: brew tap u/r", TapFormulaUnavailableError.new(t, "foo").to_s end @@ -73,7 +73,7 @@ class ExceptionsTest < Homebrew::TestCase end def test_build_error - f = stub(:name => "foo") + f = stub(name: "foo") assert_equal "Failed executing: badprg arg1 arg2", BuildError.new(f, "badprg", %w[arg1 arg2], {}).to_s end @@ -84,20 +84,20 @@ class ExceptionsTest < Homebrew::TestCase end def test_formula_installation_already_attempted_error - f = stub(:full_name => "foo/bar") + f = stub(full_name: "foo/bar") assert_equal "Formula installation already attempted: foo/bar", FormulaInstallationAlreadyAttemptedError.new(f).to_s end def test_formula_conflict_error - f = stub(:full_name => "foo/qux") - c = stub(:name => "bar", :reason => "I decided to") + f = stub(full_name: "foo/qux") + c = stub(name: "bar", reason: "I decided to") assert_match "Please `brew unlink bar` before continuing.", FormulaConflictError.new(f, [c]).to_s end def test_compiler_selection_error - f = stub(:full_name => "foo") + f = stub(full_name: "foo") assert_match "foo cannot be built with any available compilers.", CompilerSelectionError.new(f).to_s end @@ -115,27 +115,27 @@ class ExceptionsTest < Homebrew::TestCase end def test_checksum_mismatch_error - h1 = stub(:hash_type => "sha256", :to_s => "deadbeef") - h2 = stub(:hash_type => "sha256", :to_s => "deadcafe") + h1 = stub(hash_type: "sha256", to_s: "deadbeef") + h2 = stub(hash_type: "sha256", to_s: "deadcafe") assert_match "SHA256 mismatch", ChecksumMismatchError.new("/file.tar.gz", h1, h2).to_s end def test_resource_missing_error - f = stub(:full_name => "bar") - r = stub(:inspect => "<resource foo>") + f = stub(full_name: "bar") + r = stub(inspect: "<resource foo>") assert_match "bar does not define resource <resource foo>", ResourceMissingError.new(f, r).to_s end def test_duplicate_resource_error - r = stub(:inspect => "<resource foo>") + r = stub(inspect: "<resource foo>") assert_equal "Resource <resource foo> is defined more than once", DuplicateResourceError.new(r).to_s end def test_bottle_version_mismatch_error - f = stub(:full_name => "foo") + f = stub(full_name: "foo") assert_match "Bottle version mismatch", BottleVersionMismatchError.new("/foo.bottle.tar.gz", "1.0", f, "1.1").to_s end diff --git a/Library/Homebrew/test/test_formula.rb b/Library/Homebrew/test/test_formula.rb index 07244a151..7c09e765f 100644 --- a/Library/Homebrew/test/test_formula.rb +++ b/Library/Homebrew/test/test_formula.rb @@ -10,7 +10,7 @@ class FormulaTests < Homebrew::TestCase spec = :stable alias_path = CoreTap.instance.alias_dir/"formula_alias" - f = klass.new(name, path, spec, :alias_path => alias_path) + f = klass.new(name, path, spec, alias_path: alias_path) assert_equal name, f.name assert_equal path, f.path assert_equal alias_path, f.alias_path @@ -72,16 +72,16 @@ class FormulaTests < Homebrew::TestCase def test_installed? f = Testball.new - f.stubs(:installed_prefix).returns(stub(:directory? => false)) + f.stubs(:installed_prefix).returns(stub(directory?: false)) refute_predicate f, :installed? f.stubs(:installed_prefix).returns( - stub(:directory? => true, :children => []) + stub(directory?: true, children: []) ) refute_predicate f, :installed? f.stubs(:installed_prefix).returns( - stub(:directory? => true, :children => [stub]) + stub(directory?: true, children: [stub]) ) assert_predicate f, :installed? end @@ -255,7 +255,7 @@ class FormulaTests < Homebrew::TestCase mirror "http://example.org/test-0.1.tbz" sha256 TEST_SHA256 - head "http://example.com/test.git", :tag => "foo" + head "http://example.com/test.git", tag: "foo" devel do url "http://example.com/test-0.2.tbz" @@ -352,7 +352,7 @@ class FormulaTests < Homebrew::TestCase initial_env = ENV.to_hash f = formula do - head "foo", :using => :git + head "foo", using: :git end cached_location = f.head.downloader.cached_location @@ -616,47 +616,47 @@ class OutdatedVersionsTests < Homebrew::TestCase end def test_greater_different_tap_installed - setup_tab_for_prefix(greater_prefix, :tap => "user/repo") + setup_tab_for_prefix(greater_prefix, tap: "user/repo") assert_predicate f.outdated_versions, :empty? end def test_greater_same_tap_installed f.instance_variable_set(:@tap, CoreTap.instance) - setup_tab_for_prefix(greater_prefix, :tap => "homebrew/core") + setup_tab_for_prefix(greater_prefix, tap: "homebrew/core") assert_predicate f.outdated_versions, :empty? end def test_outdated_different_tap_installed - setup_tab_for_prefix(outdated_prefix, :tap => "user/repo") + setup_tab_for_prefix(outdated_prefix, tap: "user/repo") refute_predicate f.outdated_versions, :empty? end def test_outdated_same_tap_installed f.instance_variable_set(:@tap, CoreTap.instance) - setup_tab_for_prefix(outdated_prefix, :tap => "homebrew/core") + setup_tab_for_prefix(outdated_prefix, tap: "homebrew/core") refute_predicate f.outdated_versions, :empty? end def test_same_head_installed f.instance_variable_set(:@tap, CoreTap.instance) - setup_tab_for_prefix(head_prefix, :tap => "homebrew/core") + setup_tab_for_prefix(head_prefix, tap: "homebrew/core") assert_predicate f.outdated_versions, :empty? end def test_different_head_installed f.instance_variable_set(:@tap, CoreTap.instance) - setup_tab_for_prefix(head_prefix, :tap => "user/repo") + setup_tab_for_prefix(head_prefix, tap: "user/repo") assert_predicate f.outdated_versions, :empty? end def test_mixed_taps_greater_version_installed f.instance_variable_set(:@tap, CoreTap.instance) - setup_tab_for_prefix(outdated_prefix, :tap => "homebrew/core") - setup_tab_for_prefix(greater_prefix, :tap => "user/repo") + setup_tab_for_prefix(outdated_prefix, tap: "homebrew/core") + setup_tab_for_prefix(greater_prefix, tap: "user/repo") assert_predicate f.outdated_versions, :empty? - setup_tab_for_prefix(greater_prefix, :tap => "homebrew/core") + setup_tab_for_prefix(greater_prefix, tap: "homebrew/core") reset_outdated_versions assert_predicate f.outdated_versions, :empty? @@ -668,12 +668,12 @@ class OutdatedVersionsTests < Homebrew::TestCase extra_outdated_prefix = HOMEBREW_CELLAR/"#{f.name}/1.0" setup_tab_for_prefix(outdated_prefix) - setup_tab_for_prefix(extra_outdated_prefix, :tap => "homebrew/core") + setup_tab_for_prefix(extra_outdated_prefix, tap: "homebrew/core") reset_outdated_versions refute_predicate f.outdated_versions, :empty? - setup_tab_for_prefix(outdated_prefix, :tap => "user/repo") + setup_tab_for_prefix(outdated_prefix, tap: "user/repo") reset_outdated_versions refute_predicate f.outdated_versions, :empty? @@ -681,18 +681,18 @@ class OutdatedVersionsTests < Homebrew::TestCase def test_same_version_tap_installed f.instance_variable_set(:@tap, CoreTap.instance) - setup_tab_for_prefix(same_prefix, :tap => "homebrew/core") + setup_tab_for_prefix(same_prefix, tap: "homebrew/core") assert_predicate f.outdated_versions, :empty? - setup_tab_for_prefix(same_prefix, :tap => "user/repo") + setup_tab_for_prefix(same_prefix, tap: "user/repo") reset_outdated_versions assert_predicate f.outdated_versions, :empty? end def test_outdated_installed_head_less_than_stable - tab = setup_tab_for_prefix(head_prefix, :versions => { "stable" => "1.0" }) + tab = setup_tab_for_prefix(head_prefix, versions: { "stable" => "1.0" }) refute_predicate f.outdated_versions, :empty? # Tab.for_keg(head_prefix) will be fetched from CACHE but we write it anyway @@ -710,7 +710,7 @@ class OutdatedVersionsTests < Homebrew::TestCase head_prefix_c = HOMEBREW_CELLAR.join("testball/HEAD-5658946") setup_tab_for_prefix(outdated_stable_prefix) - tab_a = setup_tab_for_prefix(head_prefix_a, :versions => { "stable" => "1.0" }) + tab_a = setup_tab_for_prefix(head_prefix_a, versions: { "stable" => "1.0" }) setup_tab_for_prefix(head_prefix_b) initial_env = ENV.to_hash @@ -720,7 +720,7 @@ class OutdatedVersionsTests < Homebrew::TestCase @f = formula("testball") do url "foo" version "2.10" - head "file://#{testball_repo}", :using => :git + head "file://#{testball_repo}", using: :git end %w[AUTHOR COMMITTER].each do |role| @@ -738,20 +738,20 @@ class OutdatedVersionsTests < Homebrew::TestCase end end - refute_predicate f.outdated_versions(:fetch_head => true), :empty? + refute_predicate f.outdated_versions(fetch_head: true), :empty? tab_a.source["versions"] = { "stable" => f.version.to_s } tab_a.write reset_outdated_versions - refute_predicate f.outdated_versions(:fetch_head => true), :empty? + refute_predicate f.outdated_versions(fetch_head: true), :empty? head_prefix_a.rmtree reset_outdated_versions - refute_predicate f.outdated_versions(:fetch_head => true), :empty? + refute_predicate f.outdated_versions(fetch_head: true), :empty? - setup_tab_for_prefix(head_prefix_c, :source_modified_time => 1) + setup_tab_for_prefix(head_prefix_c, source_modified_time: 1) reset_outdated_versions - assert_predicate f.outdated_versions(:fetch_head => true), :empty? + assert_predicate f.outdated_versions(fetch_head: true), :empty? ensure ENV.replace(initial_env) testball_repo.rmtree if testball_repo.exist? @@ -770,7 +770,7 @@ class OutdatedVersionsTests < Homebrew::TestCase end prefix = HOMEBREW_CELLAR.join("testball/0.1") - setup_tab_for_prefix(prefix, :versions => { "stable" => "0.1" }) + setup_tab_for_prefix(prefix, versions: { "stable" => "0.1" }) refute_predicate f.outdated_versions, :empty? ensure @@ -785,22 +785,22 @@ class OutdatedVersionsTests < Homebrew::TestCase end prefix_a = HOMEBREW_CELLAR.join("testball/20141009") - setup_tab_for_prefix(prefix_a, :versions => { "stable" => "20141009", "version_scheme" => 1 }) + setup_tab_for_prefix(prefix_a, versions: { "stable" => "20141009", "version_scheme" => 1 }) prefix_b = HOMEBREW_CELLAR.join("testball/2.14") - setup_tab_for_prefix(prefix_b, :versions => { "stable" => "2.14", "version_scheme" => 2 }) + setup_tab_for_prefix(prefix_b, versions: { "stable" => "2.14", "version_scheme" => 2 }) refute_predicate f.outdated_versions, :empty? reset_outdated_versions prefix_c = HOMEBREW_CELLAR.join("testball/20141009") - setup_tab_for_prefix(prefix_c, :versions => { "stable" => "20141009", "version_scheme" => 3 }) + setup_tab_for_prefix(prefix_c, versions: { "stable" => "20141009", "version_scheme" => 3 }) refute_predicate f.outdated_versions, :empty? reset_outdated_versions prefix_d = HOMEBREW_CELLAR.join("testball/20141011") - setup_tab_for_prefix(prefix_d, :versions => { "stable" => "20141009", "version_scheme" => 3 }) + setup_tab_for_prefix(prefix_d, versions: { "stable" => "20141009", "version_scheme" => 3 }) assert_predicate f.outdated_versions, :empty? ensure f.rack.rmtree @@ -815,13 +815,13 @@ class OutdatedVersionsTests < Homebrew::TestCase head_prefix = HOMEBREW_CELLAR.join("testball/HEAD") - setup_tab_for_prefix(head_prefix, :versions => { "stable" => "1.0", "version_scheme" => 1 }) + setup_tab_for_prefix(head_prefix, versions: { "stable" => "1.0", "version_scheme" => 1 }) refute_predicate f.outdated_versions, :empty? reset_outdated_versions head_prefix.rmtree - setup_tab_for_prefix(head_prefix, :versions => { "stable" => "1.0", "version_scheme" => 2 }) + setup_tab_for_prefix(head_prefix, versions: { "stable" => "1.0", "version_scheme" => 2 }) assert_predicate f.outdated_versions, :empty? ensure head_prefix.rmtree diff --git a/Library/Homebrew/test/test_integration_cmds.rb b/Library/Homebrew/test/test_integration_cmds.rb index 3eef41515..43b8689af 100644 --- a/Library/Homebrew/test/test_integration_cmds.rb +++ b/Library/Homebrew/test/test_integration_cmds.rb @@ -160,7 +160,7 @@ class IntegrationCommandTests < Homebrew::TestCase def setup_remote_tap(name) tap = Tap.fetch name - tap.install(:full_clone => false, :quiet => true) unless tap.installed? + tap.install(full_clone: false, quiet: true) unless tap.installed? tap end diff --git a/Library/Homebrew/test/test_language_python.rb b/Library/Homebrew/test/test_language_python.rb index d9d4f3458..d1e3867f7 100644 --- a/Library/Homebrew/test/test_language_python.rb +++ b/Library/Homebrew/test/test_language_python.rb @@ -5,7 +5,7 @@ require "resource" class LanguagePythonTests < Homebrew::TestCase def setup @dir = Pathname.new(mktmpdir) - resource = stub("resource", :stage => true) + resource = stub("resource", stage: true) formula_bin = @dir/"formula_bin" @formula = mock("formula") do stubs(:resource).returns(resource) @@ -20,7 +20,7 @@ class LanguagePythonTests < Homebrew::TestCase def test_virtualenv_creation @formula.expects(:resource).with("homebrew-virtualenv").returns( - mock("resource", :stage => true) + mock("resource", stage: true) ) @venv.create end @@ -28,7 +28,7 @@ class LanguagePythonTests < Homebrew::TestCase # or at least doesn't crash the second time def test_virtualenv_creation_is_idempotent @formula.expects(:resource).with("homebrew-virtualenv").returns( - mock("resource", :stage => true) + mock("resource", stage: true) ) @venv.create FileUtils.mkdir_p @dir/"bin" diff --git a/Library/Homebrew/test/test_patch.rb b/Library/Homebrew/test/test_patch.rb index 3b489b35c..120f0a3a5 100644 --- a/Library/Homebrew/test/test_patch.rb +++ b/Library/Homebrew/test/test_patch.rb @@ -58,7 +58,7 @@ class LegacyPatchTests < Homebrew::TestCase def test_p0_hash_to_string patches = Patch.normalize_legacy_patches( - :p0 => "http://example.com/patch.diff" + p0: "http://example.com/patch.diff" ) assert_equal 1, patches.length @@ -67,7 +67,7 @@ class LegacyPatchTests < Homebrew::TestCase def test_p1_hash_to_string patches = Patch.normalize_legacy_patches( - :p1 => "http://example.com/patch.diff" + p1: "http://example.com/patch.diff" ) assert_equal 1, patches.length @@ -76,8 +76,8 @@ class LegacyPatchTests < Homebrew::TestCase def test_mixed_hash_to_strings patches = Patch.normalize_legacy_patches( - :p1 => "http://example.com/patch1.diff", - :p0 => "http://example.com/patch0.diff" + p1: "http://example.com/patch1.diff", + p0: "http://example.com/patch0.diff" ) assert_equal 2, patches.length assert_equal 1, patches.count { |p| p.strip == :p0 } @@ -86,10 +86,10 @@ class LegacyPatchTests < Homebrew::TestCase def test_mixed_hash_to_arrays patches = Patch.normalize_legacy_patches( - :p1 => ["http://example.com/patch10.diff", - "http://example.com/patch11.diff"], - :p0 => ["http://example.com/patch00.diff", - "http://example.com/patch01.diff"] + p1: ["http://example.com/patch10.diff", + "http://example.com/patch11.diff"], + p0: ["http://example.com/patch00.diff", + "http://example.com/patch01.diff"] ) assert_equal 4, patches.length diff --git a/Library/Homebrew/test/test_patching.rb b/Library/Homebrew/test/test_patching.rb index 8511981e1..18b848b10 100644 --- a/Library/Homebrew/test/test_patching.rb +++ b/Library/Homebrew/test/test_patching.rb @@ -163,7 +163,7 @@ class PatchingTests < Homebrew::TestCase def test_patch_p0 assert_patched formula { def patches - { :p0 => PATCH_URL_B } + { p0: PATCH_URL_B } end } end @@ -179,7 +179,7 @@ class PatchingTests < Homebrew::TestCase def test_patch_hash assert_patched formula { def patches - { :p1 => PATCH_URL_A } + { p1: PATCH_URL_A } end } end @@ -187,7 +187,7 @@ class PatchingTests < Homebrew::TestCase def test_patch_hash_array assert_patched formula { def patches - { :p1 => [PATCH_URL_A] } + { p1: [PATCH_URL_A] } end } end diff --git a/Library/Homebrew/test/test_requirement.rb b/Library/Homebrew/test/test_requirement.rb index 0281ad70c..580d42bfa 100644 --- a/Library/Homebrew/test/test_requirement.rb +++ b/Library/Homebrew/test/test_requirement.rb @@ -36,14 +36,14 @@ class RequirementTests < Homebrew::TestCase def test_satisfy_true req = Class.new(Requirement) do - satisfy(:build_env => false) { true } + satisfy(build_env: false) { true } end.new assert_predicate req, :satisfied? end def test_satisfy_false req = Class.new(Requirement) do - satisfy(:build_env => false) { false } + satisfy(build_env: false) { false } end.new refute_predicate req, :satisfied? end @@ -67,7 +67,7 @@ class RequirementTests < Homebrew::TestCase def test_satisfy_build_env_can_be_disabled req = Class.new(Requirement) do - satisfy(:build_env => false) { true } + satisfy(build_env: false) { true } end.new ENV.expects(:with_build_environment).never diff --git a/Library/Homebrew/test/test_resource.rb b/Library/Homebrew/test/test_resource.rb index b0e0d1b72..c1b526cb2 100644 --- a/Library/Homebrew/test/test_resource.rb +++ b/Library/Homebrew/test/test_resource.rb @@ -12,42 +12,42 @@ class ResourceTests < Homebrew::TestCase end def test_url_with_specs - @resource.url("foo", :branch => "master") + @resource.url("foo", branch: "master") assert_equal "foo", @resource.url - assert_equal({ :branch => "master" }, @resource.specs) + assert_equal({ branch: "master" }, @resource.specs) end def test_url_with_custom_download_strategy_class strategy = Class.new(AbstractDownloadStrategy) - @resource.url("foo", :using => strategy) + @resource.url("foo", using: strategy) assert_equal "foo", @resource.url assert_equal strategy, @resource.download_strategy end def test_url_with_specs_and_download_strategy strategy = Class.new(AbstractDownloadStrategy) - @resource.url("foo", :using => strategy, :branch => "master") + @resource.url("foo", using: strategy, branch: "master") assert_equal "foo", @resource.url - assert_equal({ :branch => "master" }, @resource.specs) + assert_equal({ branch: "master" }, @resource.specs) assert_equal strategy, @resource.download_strategy end def test_url_with_custom_download_strategy_symbol - @resource.url("foo", :using => :git) + @resource.url("foo", using: :git) assert_equal "foo", @resource.url assert_equal GitDownloadStrategy, @resource.download_strategy end def test_raises_for_unknown_download_strategy_class - assert_raises(TypeError) { @resource.url("foo", :using => Class.new) } + assert_raises(TypeError) { @resource.url("foo", using: Class.new) } end def test_does_not_mutate_specs_hash - specs = { :using => :git, :branch => "master" } + specs = { using: :git, branch: "master" } @resource.url("foo", specs) - assert_equal({ :branch => "master" }, @resource.specs) + assert_equal({ branch: "master" }, @resource.specs) assert_equal(:git, @resource.using) - assert_equal({ :using => :git, :branch => "master" }, specs) + assert_equal({ using: :git, branch: "master" }, specs) end def test_version @@ -70,7 +70,7 @@ class ResourceTests < Homebrew::TestCase end def test_version_from_tag - @resource.url("http://example.com/foo-1.0.tar.gz", :tag => "v1.0.2") + @resource.url("http://example.com/foo-1.0.tar.gz", tag: "v1.0.2") assert_version_equal "1.0.2", @resource.version assert_predicate @resource.version, :detected_from_url? end @@ -109,7 +109,7 @@ class ResourceTests < Homebrew::TestCase def test_verify_download_integrity_missing fn = Pathname.new("test") - fn.stubs(:file? => true) + fn.stubs(file?: true) fn.expects(:verify_checksum).raises(ChecksumMissingError) fn.expects(:sha256) @@ -117,7 +117,7 @@ class ResourceTests < Homebrew::TestCase end def test_verify_download_integrity_mismatch - fn = stub(:file? => true) + fn = stub(file?: true) checksum = @resource.sha256(TEST_SHA256) fn.expects(:verify_checksum).with(checksum) diff --git a/Library/Homebrew/test/test_sandbox.rb b/Library/Homebrew/test/test_sandbox.rb index cb33c3ffa..2a062cb10 100644 --- a/Library/Homebrew/test/test_sandbox.rb +++ b/Library/Homebrew/test/test_sandbox.rb @@ -49,8 +49,8 @@ class SandboxTest < Homebrew::TestCase end def test_complains_on_failure - Utils.expects(:popen_read => "foo") - ARGV.stubs(:verbose? => true) + Utils.expects(popen_read: "foo") + ARGV.stubs(verbose?: true) out, _err = capture_io do assert_raises(ErrorDuringExecution) { @sandbox.exec "false" } end @@ -63,8 +63,8 @@ class SandboxTest < Homebrew::TestCase Mar 17 02:55:06 sandboxd[342]: Python(49765) deny file-write-unlink /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/errors.pyc bar EOS - Utils.expects(:popen_read => with_bogus_error) - ARGV.stubs(:verbose? => true) + Utils.expects(popen_read: with_bogus_error) + ARGV.stubs(verbose?: true) out, _err = capture_io do assert_raises(ErrorDuringExecution) { @sandbox.exec "false" } end diff --git a/Library/Homebrew/test/test_software_spec.rb b/Library/Homebrew/test/test_software_spec.rb index efd3eff95..d9226f8c3 100644 --- a/Library/Homebrew/test/test_software_spec.rb +++ b/Library/Homebrew/test/test_software_spec.rb @@ -36,18 +36,18 @@ class SoftwareSpecTests < Homebrew::TestCase end def test_set_owner - owner = stub :name => "some_name", - :full_name => "some_name", - :tap => "homebrew/core" + owner = stub name: "some_name", + full_name: "some_name", + tap: "homebrew/core" @spec.owner = owner assert_equal owner, @spec.owner end def test_resource_owner @spec.resource("foo") { url "foo-1.0" } - @spec.owner = stub :name => "some_name", - :full_name => "some_name", - :tap => "homebrew/core" + @spec.owner = stub name: "some_name", + full_name: "some_name", + tap: "homebrew/core" assert_equal "some_name", @spec.name @spec.resources.each_value { |r| assert_equal @spec, r.owner } end @@ -55,9 +55,9 @@ class SoftwareSpecTests < Homebrew::TestCase def test_resource_without_version_receives_owners_version @spec.url("foo-42") @spec.resource("bar") { url "bar" } - @spec.owner = stub :name => "some_name", - :full_name => "some_name", - :tap => "homebrew/core" + @spec.owner = stub name: "some_name", + full_name: "some_name", + tap: "homebrew/core" assert_version_equal "42", @spec.resource("bar").version end @@ -155,10 +155,10 @@ class BottleSpecificationTests < Homebrew::TestCase def test_checksum_setters checksums = { - :snow_leopard_32 => "deadbeef"*8, - :snow_leopard => "faceb00c"*8, - :lion => "baadf00d"*8, - :mountain_lion => "8badf00d"*8, + snow_leopard_32: "deadbeef"*8, + snow_leopard: "faceb00c"*8, + lion: "baadf00d"*8, + mountain_lion: "8badf00d"*8, } checksums.each_pair do |cat, digest| diff --git a/Library/Homebrew/test/test_tab.rb b/Library/Homebrew/test/test_tab.rb index 0b8fb2a64..2efaee983 100644 --- a/Library/Homebrew/test/test_tab.rb +++ b/Library/Homebrew/test/test_tab.rb @@ -61,7 +61,7 @@ class TabTests < Homebrew::TestCase end def test_universal? - tab = Tab.new(:used_options => %w[--universal]) + tab = Tab.new(used_options: %w[--universal]) assert_predicate tab, :universal? end @@ -132,7 +132,7 @@ class TabTests < Homebrew::TestCase def test_create_from_alias alias_path = CoreTap.instance.alias_dir/"bar" - f = formula(:alias_path => alias_path) { url "foo-1.0" } + f = formula(alias_path: alias_path) { url "foo-1.0" } compiler = DevelopmentTools.default_compiler stdlib = :libcxx tab = Tab.create(f, compiler, stdlib) @@ -149,7 +149,7 @@ class TabTests < Homebrew::TestCase def test_for_formula_from_alias alias_path = CoreTap.instance.alias_dir/"bar" - f = formula(:alias_path => alias_path) { url "foo-1.0" } + f = formula(alias_path: alias_path) { url "foo-1.0" } tab = Tab.for_formula(f) assert_equal alias_path.to_s, tab.source["path"] diff --git a/Library/Homebrew/test/test_tap.rb b/Library/Homebrew/test/test_tap.rb index dfbb89384..fafac252f 100644 --- a/Library/Homebrew/test/test_tap.rb +++ b/Library/Homebrew/test/test_tap.rb @@ -182,7 +182,7 @@ class TapTest < Homebrew::TestCase already_tapped_tap = Tap.new("Homebrew", "foo") assert_equal true, already_tapped_tap.installed? right_remote = @tap.remote - assert_raises(TapAlreadyTappedError) { already_tapped_tap.install :clone_target => right_remote } + assert_raises(TapAlreadyTappedError) { already_tapped_tap.install clone_target: right_remote } end def test_install_tap_remote_mismatch_error @@ -191,13 +191,13 @@ class TapTest < Homebrew::TestCase touch @tap.path/".git/shallow" assert_equal true, already_tapped_tap.installed? wrong_remote = "#{@tap.remote}-oops" - assert_raises(TapRemoteMismatchError) { already_tapped_tap.install :clone_target => wrong_remote, :full_clone => true } + assert_raises(TapRemoteMismatchError) { already_tapped_tap.install clone_target: wrong_remote, full_clone: true } end def test_install_tap_already_unshallow_error setup_git_repo already_tapped_tap = Tap.new("Homebrew", "foo") - assert_raises(TapAlreadyUnshallowError) { already_tapped_tap.install :full_clone => true } + assert_raises(TapAlreadyUnshallowError) { already_tapped_tap.install full_clone: true } end def test_uninstall_tap_unavailable_error @@ -208,7 +208,7 @@ class TapTest < Homebrew::TestCase def test_install_git_error tap = Tap.new("user", "repo") assert_raises(ErrorDuringExecution) do - shutup { tap.install :clone_target => "file:///not/existed/remote/url" } + shutup { tap.install clone_target: "file:///not/existed/remote/url" } end refute_predicate tap, :installed? refute_predicate Tap::TAP_DIRECTORY/"user", :exist? @@ -219,7 +219,7 @@ class TapTest < Homebrew::TestCase setup_git_repo tap = Tap.new("Homebrew", "bar") - shutup { tap.install :clone_target => @tap.path/".git" } + shutup { tap.install clone_target: @tap.path/".git" } assert_predicate tap, :installed? assert_predicate HOMEBREW_PREFIX/"share/man/man1/brew-tap-cmd.1", :file? shutup { tap.uninstall } diff --git a/Library/Homebrew/test/test_update_report.rb b/Library/Homebrew/test/test_update_report.rb index d30c56fc3..b3ae865a5 100644 --- a/Library/Homebrew/test/test_update_report.rb +++ b/Library/Homebrew/test/test_update_report.rb @@ -30,8 +30,8 @@ class ReportTests < Homebrew::TestCase end def perform_update(fixture_name = "") - Formulary.stubs(:factory).returns(stub(:pkg_version => "1.0")) - FormulaVersions.stubs(:new).returns(stub(:formula_at_revision => "2.0")) + Formulary.stubs(:factory).returns(stub(pkg_version: "1.0")) + FormulaVersions.stubs(:new).returns(stub(formula_at_revision: "2.0")) @reporter.diff = fixture(fixture_name) @hub.add(@reporter) if @reporter.updated? end diff --git a/Library/Homebrew/test/test_utils.rb b/Library/Homebrew/test/test_utils.rb index fa66aefe2..c88c0f416 100644 --- a/Library/Homebrew/test/test_utils.rb +++ b/Library/Homebrew/test/test_utils.rb @@ -227,9 +227,9 @@ class UtilTests < Homebrew::TestCase s = truncate_text_to_approximate_size(long_s, n) assert_equal n, s.length assert_match(/^x+#{Regexp.escape(glue)}x+$/, s) - s = truncate_text_to_approximate_size(long_s, n, :front_weight => 0.0) + s = truncate_text_to_approximate_size(long_s, n, front_weight: 0.0) assert_equal glue + ("x" * (n - glue.length)), s - s = truncate_text_to_approximate_size(long_s, n, :front_weight => 1.0) + s = truncate_text_to_approximate_size(long_s, n, front_weight: 1.0) assert_equal(("x" * (n - glue.length)) + glue, s) end @@ -237,8 +237,8 @@ class UtilTests < Homebrew::TestCase ARGV.stubs(:homebrew_developer?).returns false e = assert_raises(FormulaMethodDeprecatedError) do odeprecated("method", "replacement", - :caller => ["#{HOMEBREW_LIBRARY}/Taps/homebrew/homebrew-core/"], - :die => true) + caller: ["#{HOMEBREW_LIBRARY}/Taps/homebrew/homebrew-core/"], + die: true) end assert_match "method", e.message assert_match "replacement", e.message diff --git a/Library/Homebrew/test/test_versions.rb b/Library/Homebrew/test/test_versions.rb index 734117609..2a1a33a59 100644 --- a/Library/Homebrew/test/test_versions.rb +++ b/Library/Homebrew/test/test_versions.rb @@ -3,7 +3,7 @@ require "version" class VersionTests < Homebrew::TestCase def test_accepts_objects_responding_to_to_str - value = stub(:to_str => "0.1") + value = stub(to_str: "0.1") assert_equal "0.1", Version.create(value).to_s end @@ -452,7 +452,7 @@ class VersionParsingTests < Homebrew::TestCase def test_from_url assert_version_detected "1.2.3", - "http://github.com/foo/bar.git", :tag => "v1.2.3" + "http://github.com/foo/bar.git", tag: "v1.2.3" end end diff --git a/Library/Homebrew/test/testing_env.rb b/Library/Homebrew/test/testing_env.rb index bc25f8ef8..cbbc5eff1 100644 --- a/Library/Homebrew/test/testing_env.rb +++ b/Library/Homebrew/test/testing_env.rb @@ -73,7 +73,7 @@ module Homebrew TEST_SHA256 = "deadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef".freeze def formula(name = "formula_name", path = Formulary.core_path(name), spec = :stable, alias_path: nil, &block) - @_f = Class.new(Formula, &block).new(name, path, spec, :alias_path => alias_path) + @_f = Class.new(Formula, &block).new(name, path, spec, alias_path: alias_path) end def mktmpdir(prefix_suffix = nil, &block) diff --git a/Library/Homebrew/utils.rb b/Library/Homebrew/utils.rb index 755a8a1d6..2e1a677b3 100644 --- a/Library/Homebrew/utils.rb +++ b/Library/Homebrew/utils.rb @@ -163,7 +163,7 @@ def odeprecated(method, replacement = nil, options = {}) end def odisabled(method, replacement = nil, options = {}) - options = { :die => true, :caller => caller }.merge(options) + options = { die: true, caller: caller }.merge(options) odeprecated(method, replacement, options) end @@ -587,7 +587,7 @@ def truncate_text_to_approximate_size(s, max_bytes, options = {}) end out = front + glue_bytes + back out.force_encoding("UTF-8") - out.encode!("UTF-16", :invalid => :replace) + out.encode!("UTF-16", invalid: :replace) out.encode!("UTF-8") out end diff --git a/Library/Homebrew/utils/analytics.rb b/Library/Homebrew/utils/analytics.rb index a72850655..e176f0566 100644 --- a/Library/Homebrew/utils/analytics.rb +++ b/Library/Homebrew/utils/analytics.rb @@ -55,10 +55,10 @@ module Utils def report_event(category, action, label = os_prefix_ci, value = nil) report(:event, - :ec => category, - :ea => action, - :el => label, - :ev => value) + ec: category, + ea: action, + el: label, + ev: value) end def report_exception(exception, options = {}) @@ -69,12 +69,12 @@ module Utils fatal = options.fetch(:fatal, true) ? "1" : "0" report(:exception, - :exd => exception.class.name, - :exf => fatal) + exd: exception.class.name, + exf: fatal) end def report_screenview(screen_name) - report(:screenview, :cd => screen_name) + report(:screenview, cd: screen_name) end end end diff --git a/Library/Homebrew/utils/github.rb b/Library/Homebrew/utils/github.rb index d3f304122..9431fa15f 100644 --- a/Library/Homebrew/utils/github.rb +++ b/Library/Homebrew/utils/github.rb @@ -235,8 +235,8 @@ module GitHub def build_search_qualifier_string(qualifiers) { - :repo => "Homebrew/homebrew-core", - :in => "title", + repo: "Homebrew/homebrew-core", + in: "title", }.update(qualifiers).map do |qualifier, value| "#{qualifier}:#{value}" end.join("+") @@ -253,14 +253,14 @@ module GitHub def issues_for_formula(name, options = {}) tap = options[:tap] || CoreTap.instance - issues_matching(name, :state => "open", :repo => "#{tap.user}/homebrew-#{tap.repo}") + issues_matching(name, state: "open", repo: "#{tap.user}/homebrew-#{tap.repo}") end def print_pull_requests_matching(query) return [] if ENV["HOMEBREW_NO_GITHUB_API"] ohai "Searching pull requests..." - open_or_closed_prs = issues_matching(query, :type => "pr") + open_or_closed_prs = issues_matching(query, type: "pr") open_prs = open_or_closed_prs.select { |i| i["state"] == "open" } if !open_prs.empty? diff --git a/Library/Homebrew/utils/shell.rb b/Library/Homebrew/utils/shell.rb index 7f749186f..302167d47 100644 --- a/Library/Homebrew/utils/shell.rb +++ b/Library/Homebrew/utils/shell.rb @@ -1,12 +1,12 @@ module Utils SHELL_PROFILE_MAP = { - :bash => "~/.bash_profile", - :csh => "~/.cshrc", - :fish => "~/.config/fish/config.fish", - :ksh => "~/.kshrc", - :sh => "~/.bash_profile", - :tcsh => "~/.tcshrc", - :zsh => "~/.zshrc", + bash: "~/.bash_profile", + csh: "~/.cshrc", + fish: "~/.config/fish/config.fish", + ksh: "~/.kshrc", + sh: "~/.bash_profile", + tcsh: "~/.tcshrc", + zsh: "~/.zshrc", }.freeze module Shell diff --git a/Library/Homebrew/version.rb b/Library/Homebrew/version.rb index 0d9f45149..520db6626 100644 --- a/Library/Homebrew/version.rb +++ b/Library/Homebrew/version.rb @@ -33,7 +33,7 @@ class Version when NullToken 0 when NumericToken - other.value == 0 ? 0 : -1 + other.value.zero? ? 0 : -1 when AlphaToken, BetaToken, RCToken 1 else @@ -292,9 +292,9 @@ class Version stem = if spec.directory? spec.basename.to_s - elsif %r{((?:sourceforge\.net|sf\.net)/.*)/download$}.match(spec_s) + elsif %r{((?:sourceforge\.net|sf\.net)/.*)/download$} =~ spec_s Pathname.new(spec.dirname).stem - elsif %r{\.[^a-zA-Z]+$}.match(spec_s) + elsif /\.[^a-zA-Z]+$/ =~ spec_s Pathname.new(spec_s).basename else spec.stem |
