diff options
author | Homu <homu@barosl.com> | 2016-02-01 13:29:43 +0900 |
---|---|---|
committer | Homu <homu@barosl.com> | 2016-02-01 13:29:43 +0900 |
commit | f9a3a5148e7902ae4e30e837060806067e9025f5 (patch) | |
tree | f7ea8eaf4b1766b2860ec75bcebc2bbdf6cb29d8 | |
parent | c71bdfc892214babefc4c993bba0e23546fe7367 (diff) | |
parent | 44c88916e832cbeb5c81b0dd9034a2eb74ec981c (diff) | |
download | bundler-f9a3a5148e7902ae4e30e837060806067e9025f5.tar.gz |
Auto merge of #4258 - bundler:seg-rubocop-0.36, r=segiddins
RuboCop 0.36 & Frozen String Literals
260 files changed, 639 insertions, 263 deletions
diff --git a/.rubocop.yml b/.rubocop.yml index 03f007416e..c2ce653729 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -2,6 +2,7 @@ inherit_from: - .rubocop_todo.yml AllCops: + TargetRubyVersion: 1.9 Exclude: - tmp/**/* - lib/bundler/vendor/**/* @@ -24,9 +25,15 @@ Lint/UnusedMethodArgument: Style/AccessModifierIndentation: EnforcedStyle: outdent +Style/Alias: + EnforcedStyle: prefer_alias_method + Style/AlignParameters: EnforcedStyle: with_fixed_indentation +Style/FrozenStringLiteralComment: + EnforcedStyle: always + Style/MultilineBlockChain: Enabled: false @@ -57,7 +64,7 @@ Style/StringLiteralsInInterpolation: # Having these make it easier to *not* forget to add one when adding a new # value and you can simply copy the previous line. -Style/TrailingComma: +Style/TrailingCommaInLiteral: EnforcedStyleForMultiline: comma Style/TrailingUnderscoreVariable: @@ -84,7 +91,7 @@ Style/EachWithObject: Style/SpecialGlobalVars: Enabled: false -Style/TrailingComma: +Style/TrailingCommaInArguments: Enabled: false Performance/FlatMap: diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index a97947f794..3ee0c03b15 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by # `rubocop --auto-gen-config` -# on 2015-11-21 00:03:12 -0600 using RuboCop version 0.35.1. +# on 2016-01-14 15:41:59 -0600 using RuboCop version 0.36.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 @@ -22,9 +22,15 @@ Lint/HandleExceptions: - 'lib/bundler/vendored_persistent.rb' # Offense count: 1 +Lint/IneffectiveAccessModifier: + Exclude: + - 'lib/bundler/settings.rb' + +# Offense count: 4 Lint/NestedMethodDefinition: Exclude: - - 'lib/bundler/graph.rb' + - 'lib/bundler/inline.rb' + - 'spec/support/builders.rb' # Offense count: 5 Lint/RescueException: @@ -35,6 +41,11 @@ Lint/RescueException: - 'lib/bundler/rubygems_integration.rb' - 'lib/bundler/worker.rb' +# Offense count: 1 +Lint/UselessAccessModifier: + Exclude: + - 'lib/bundler/fetcher.rb' + # Offense count: 7 Lint/UselessAssignment: Exclude: @@ -42,8 +53,9 @@ Lint/UselessAssignment: - 'lib/bundler/index.rb' - 'lib/bundler/installer.rb' -# Offense count: 1031 -# Configuration parameters: AllowURI, URISchemes. +# Offense count: 1057 +# Configuration parameters: AllowHeredoc, AllowURI, URISchemes. +# URISchemes: http, https Metrics/LineLength: Max: 207 @@ -52,10 +64,34 @@ Metrics/LineLength: Metrics/ParameterLists: Max: 6 -# Offense count: 50 +# Offense count: 53 Metrics/PerceivedComplexity: Max: 54 +# Offense count: 6 +# Cop supports --auto-correct. +Performance/RedundantBlockCall: + Exclude: + - 'lib/bundler/dsl.rb' + - 'lib/bundler/gem_helper.rb' + - 'lib/bundler/retry.rb' + - 'lib/bundler/shared_helpers.rb' + - 'spec/support/helpers.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +Performance/RedundantMatch: + Exclude: + - 'lib/bundler/definition.rb' + - 'lib/bundler/lockfile_parser.rb' + +# Offense count: 8 +# Cop supports --auto-correct. +Performance/RedundantMerge: + Exclude: + - 'lib/bundler/cli/gem.rb' + - 'spec/support/helpers.rb' + # Offense count: 1 Style/AccessorMethodName: Exclude: @@ -70,19 +106,39 @@ Style/CaseEquality: # Offense count: 22 # Configuration parameters: EnforcedStyle, SupportedStyles. +# SupportedStyles: nested, compact Style/ClassAndModuleChildren: Enabled: false -# Offense count: 119 -# Configuration parameters: Exclude. +# Offense count: 14 +# Cop supports --auto-correct. +# Configuration parameters: SingleLineConditionsOnly. +Style/ConditionalAssignment: + Exclude: + - 'lib/bundler.rb' + - 'lib/bundler/cli.rb' + - 'lib/bundler/cli/gem.rb' + - 'lib/bundler/cli/lock.rb' + - 'lib/bundler/cli/outdated.rb' + - 'lib/bundler/cli/platform.rb' + - 'lib/bundler/dsl.rb' + - 'lib/bundler/lazy_specification.rb' + - 'lib/bundler/mirror.rb' + - 'lib/bundler/psyched_yaml.rb' + - 'lib/bundler/rubygems_integration.rb' + - 'lib/bundler/source/git.rb' + - 'lib/bundler/source/rubygems.rb' + +# Offense count: 122 Style/Documentation: Enabled: false -# Offense count: 1 -# Configuration parameters: Exclude. -Style/FileName: +# Offense count: 2 +# Cop supports --auto-correct. +# Configuration parameters: AllowForAlignment, ForceEqualSignAlignment. +Style/ExtraSpacing: Exclude: - - 'lib/bundler/templates/Executable' + - 'lib/bundler/cli.rb' # Offense count: 4 # Configuration parameters: AllowedVariables. @@ -92,10 +148,18 @@ Style/GlobalVars: - 'spec/spec_helper.rb' - 'spec/support/helpers.rb' -# Offense count: 32 -# Configuration parameters: MinBodyLength. -Style/GuardClause: - Enabled: false +# Offense count: 2 +Style/IfInsideElse: + Exclude: + - 'lib/bundler/cli/install.rb' + - 'lib/bundler/definition.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +# Configuration parameters: SupportedStyles, IndentationWidth. +# SupportedStyles: special_inside_parentheses, consistent, align_brackets +Style/IndentArray: + EnforcedStyle: consistent # Offense count: 2 Style/ModuleFunction: @@ -103,8 +167,27 @@ Style/ModuleFunction: - 'lib/bundler/shared_helpers.rb' - 'spec/support/path.rb' +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, SupportedStyles, IndentationWidth. +# SupportedStyles: aligned, indented +Style/MultilineMethodCallIndentation: + Enabled: false + +# Offense count: 8 +Style/NestedParenthesizedCalls: + Exclude: + - 'lib/bundler/fetcher.rb' + - 'lib/bundler/resolver.rb' + - 'spec/bundler/shared_helpers_spec.rb' + - 'spec/commands/lock_spec.rb' + - 'spec/runtime/setup_spec.rb' + # Offense count: 8 # Configuration parameters: NamePrefix, NamePrefixBlacklist, NameWhitelist. +# NamePrefix: is_, has_, have_ +# NamePrefixBlacklist: is_, has_, have_ +# NameWhitelist: is_a? Style/PredicateName: Exclude: - 'lib/bundler/definition.rb' @@ -114,7 +197,54 @@ Style/PredicateName: - 'lib/bundler/source/git/git_proxy.rb' - 'lib/bundler/source/path.rb' -# Offense count: 7 +# Offense count: 9 # Configuration parameters: EnforcedStyle, SupportedStyles. +# SupportedStyles: compact, exploded Style/RaiseArgs: Enabled: false + +# Offense count: 3 +# Cop supports --auto-correct. +Style/RedundantParentheses: + Exclude: + - 'lib/bundler/cli/console.rb' + - 'lib/bundler/dsl.rb' + - 'spec/support/ruby_ext.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: AllowForAlignment. +Style/SpaceAroundOperators: + Exclude: + - 'lib/bundler/retry.rb' + +# Offense count: 11 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyleForMultiline, SupportedStyles. +# SupportedStyles: comma, consistent_comma, no_comma +Style/TrailingCommaInLiteral: + Exclude: + - 'lib/bundler/cli/gem.rb' + - 'lib/bundler/dependency.rb' + - 'lib/bundler/fetcher.rb' + - 'lib/bundler/gem_helpers.rb' + - 'lib/bundler/graph.rb' + - 'lib/bundler/ruby_version.rb' + - 'lib/bundler/similarity_detector.rb' + - 'spec/support/artifice/endpoint.rb' + - 'spec/support/rubygems_ext.rb' + +# Offense count: 20 +# Cop supports --auto-correct. +Style/UnneededInterpolation: + Exclude: + - 'lib/bundler/cli/config.rb' + - 'lib/bundler/definition.rb' + - 'lib/bundler/env.rb' + - 'spec/bundler/shared_helpers_spec.rb' + - 'spec/cache/git_spec.rb' + - 'spec/commands/exec_spec.rb' + - 'spec/support/artifice/endpoint.rb' + - 'spec/support/artifice/endpoint_500.rb' + - 'spec/support/fakeweb/windows.rb' + - 'spec/support/rubygems_ext.rb' diff --git a/.travis.yml b/.travis.yml index b099e0e9db..d89ed44967 100644 --- a/.travis.yml +++ b/.travis.yml @@ -39,7 +39,7 @@ env: # We need to know if changes to rubygems will break bundler on release - RGV=master # Test the latest rubygems release with all of our supported rubies - - RGV=v2.5.1 + - RGV=v2.5.2 - RGV=v2.4.8 matrix: @@ -1,4 +1,5 @@ # -*- encoding: utf-8 -*- +# frozen_string_literal: true $:.unshift File.expand_path("../lib", __FILE__) require "shellwords" require "benchmark" @@ -33,7 +34,7 @@ namespace :spec do deps = Hash[BUNDLER_SPEC.development_dependencies.map do |d| [d.name, d.requirement.to_s] end] - deps["rubocop"] ||= "= 0.35.1" if RUBY_VERSION >= "1.9.3" # can't go in the gemspec because of the ruby version requirement + deps["rubocop"] ||= "= 0.36.0" if RUBY_VERSION >= "1.9.3" # can't go in the gemspec because of the ruby version requirement # JRuby can't build ronn or rdiscount, so we skip that if defined?(RUBY_ENGINE) && RUBY_ENGINE == "jruby" @@ -64,7 +65,7 @@ namespace :spec do sh "sudo apt-get install graphviz -y 2>&1 | tail -n 2" # Install the gems with a consistent version of RubyGems - sh "gem update --system 2.5.1" + sh "gem update --system 2.5.2" $LOAD_PATH.unshift("./spec") require "support/rubygems_ext" @@ -87,7 +88,7 @@ begin if RUBY_VERSION >= "1.9.3" # can't go in the gemspec because of the ruby version requirement - gem "rubocop", "= 0.35.1" + gem "rubocop", "= 0.36.0" require "rubocop/rake_task" RuboCop::RakeTask.new end @@ -121,7 +122,7 @@ begin rubyopt = ENV["RUBYOPT"] # When editing this list, also edit .travis.yml! branches = %w(master) - releases = %w(v1.3.6 v1.3.7 v1.4.2 v1.5.3 v1.6.2 v1.7.2 v1.8.29 v2.0.14 v2.1.11 v2.2.5 v2.4.8 v2.5.1) + releases = %w(v1.3.6 v1.3.7 v1.4.2 v1.5.3 v1.6.2 v1.7.2 v1.8.29 v2.0.14 v2.1.11 v2.2.5 v2.4.8 v2.5.2) (branches + releases).each do |rg| desc "Run specs with Rubygems #{rg}" RSpec::Core::RakeTask.new(rg) do |t| @@ -1,4 +1,5 @@ #!/usr/bin/env ruby +# frozen_string_literal: true require "rubygems" @@ -1,4 +1,5 @@ #!/usr/bin/env ruby +# frozen_string_literal: true require "rubygems" diff --git a/bin/rubocop b/bin/rubocop index 8142053393..7460dafaf6 100755 --- a/bin/rubocop +++ b/bin/rubocop @@ -1,4 +1,5 @@ #!/usr/bin/env ruby +# frozen_string_literal: true require "rubygems" @@ -7,7 +8,7 @@ bundler_spec.dependencies.each do |dep| gem dep.name, dep.requirement.to_s end -gem "rubocop", "= 0.35.1" +gem "rubocop", "= 0.36.0" Gem::Specification.unresolved_deps.each do |_name, dep| gem dep.name, *dep.requirement diff --git a/bundler.gemspec b/bundler.gemspec index 52d5692826..0df67402b2 100644 --- a/bundler.gemspec +++ b/bundler.gemspec @@ -1,4 +1,5 @@ # coding: utf-8 +# frozen_string_literal: true lib = File.expand_path("../lib/", __FILE__) $:.unshift lib unless $:.include?(lib) require "bundler/version" diff --git a/exe/bundle b/exe/bundle index a6068daad3..3fb4ccfce9 100755 --- a/exe/bundle +++ b/exe/bundle @@ -1,4 +1,5 @@ #!/usr/bin/env ruby +# frozen_string_literal: true # Exit cleanly from an early interrupt Signal.trap("INT") { exit 1 } @@ -7,7 +8,8 @@ require "bundler" # Check if an older version of bundler is installed $LOAD_PATH.each do |path| next unless path =~ %r{/bundler-0\.(\d+)} && $1.to_i < 9 - err = "Looks like you have a version of bundler that's older than 0.9.\n" + err = String.new + err << "Looks like you have a version of bundler that's older than 0.9.\n" err << "Please remove your old versions.\n" err << "An easy way to do this is by running `gem cleanup bundler`." abort(err) diff --git a/exe/bundle_ruby b/exe/bundle_ruby index 346dbf2ae2..49767304e2 100755 --- a/exe/bundle_ruby +++ b/exe/bundle_ruby @@ -1,4 +1,5 @@ #!/usr/bin/env ruby +# frozen_string_literal: true Signal.trap("INT") { exit 1 } @@ -38,7 +39,7 @@ module Bundler def gem(name, *args) end - def group(*args, &blk) + def group(*args) end end end diff --git a/exe/bundler b/exe/bundler index 5baa52235a..af6c03e12e 100755 --- a/exe/bundler +++ b/exe/bundler @@ -1,4 +1,5 @@ #!/usr/bin/env ruby +# frozen_string_literal: true # Exit cleanly from an early interrupt Signal.trap("INT") { exit 1 } @@ -7,7 +8,8 @@ require "bundler" # Check if an older version of bundler is installed $LOAD_PATH.each do |path| next unless path =~ %r{/bundler-0\.(\d+)} && $1.to_i < 9 - err = "Looks like you have a version of bundler that's older than 0.9.\n" + err = String.new + err << "Looks like you have a version of bundler that's older than 0.9.\n" err << "Please remove your old versions.\n" err << "An easy way to do this is by running `gem cleanup bundler`." abort(err) diff --git a/lib/bundler.rb b/lib/bundler.rb index 474253aabd..2e7f324002 100644 --- a/lib/bundler.rb +++ b/lib/bundler.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "fileutils" require "pathname" require "rbconfig" @@ -385,7 +386,8 @@ module Bundler eval(contents, TOPLEVEL_BINDING, path.expand_path.to_s) rescue ScriptError, StandardError => e original_line = e.backtrace.find {|line| line.include?(path.to_s) } - msg = "There was a #{e.class} while loading #{path.basename}: \n#{e.message}" + msg = String.new + msg << "There was a #{e.class} while loading #{path.basename}: \n#{e.message}" msg << " from\n #{original_line}" if original_line msg << "\n" @@ -424,10 +426,9 @@ module Bundler def upgrade_lockfile lockfile = default_lockfile - if lockfile.exist? && lockfile.read(3) == "---" - Bundler.ui.warn "Detected Gemfile.lock generated by 0.9, deleting..." - lockfile.rmtree - end + return unless lockfile.exist? && lockfile.read(3) == "---" + Bundler.ui.warn "Detected Gemfile.lock generated by 0.9, deleting..." + lockfile.rmtree end end end diff --git a/lib/bundler/capistrano.rb b/lib/bundler/capistrano.rb index 12499c7bf4..2a4954d964 100644 --- a/lib/bundler/capistrano.rb +++ b/lib/bundler/capistrano.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true # Capistrano task for Bundler. # # Just add "require 'bundler/capistrano'" in your Capistrano deploy.rb, and diff --git a/lib/bundler/cli.rb b/lib/bundler/cli.rb index b6eb708f32..2445172321 100644 --- a/lib/bundler/cli.rb +++ b/lib/bundler/cli.rb @@ -1,10 +1,11 @@ +# frozen_string_literal: true require "bundler" require "bundler/vendored_thor" module Bundler class CLI < Thor include Thor::Actions - AUTO_INSTALL_CMDS = %w(show binstubs outdated exec open console licenses clean) + AUTO_INSTALL_CMDS = %w(show binstubs outdated exec open console licenses clean).freeze def self.start(*) super diff --git a/lib/bundler/cli/binstubs.rb b/lib/bundler/cli/binstubs.rb index cf9ce02c4d..8452ca3bfe 100644 --- a/lib/bundler/cli/binstubs.rb +++ b/lib/bundler/cli/binstubs.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "bundler/cli/common" module Bundler diff --git a/lib/bundler/cli/cache.rb b/lib/bundler/cli/cache.rb index 8bc876baea..c8c63e926c 100644 --- a/lib/bundler/cli/cache.rb +++ b/lib/bundler/cli/cache.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true module Bundler class CLI::Cache attr_reader :options diff --git a/lib/bundler/cli/check.rb b/lib/bundler/cli/check.rb index fd09425e4a..f6a1022306 100644 --- a/lib/bundler/cli/check.rb +++ b/lib/bundler/cli/check.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true module Bundler class CLI::Check attr_reader :options diff --git a/lib/bundler/cli/clean.rb b/lib/bundler/cli/clean.rb index d70a5b9b89..895b6567fa 100644 --- a/lib/bundler/cli/clean.rb +++ b/lib/bundler/cli/clean.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true module Bundler class CLI::Clean attr_reader :options diff --git a/lib/bundler/cli/common.rb b/lib/bundler/cli/common.rb index b90544ba3a..491ea04a11 100644 --- a/lib/bundler/cli/common.rb +++ b/lib/bundler/cli/common.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true module Bundler module CLI::Common def self.without_groups_message diff --git a/lib/bundler/cli/config.rb b/lib/bundler/cli/config.rb index cfb8b660e8..32724f687d 100644 --- a/lib/bundler/cli/config.rb +++ b/lib/bundler/cli/config.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true module Bundler class CLI::Config attr_reader :name, :options, :scope, :thor @@ -9,10 +10,9 @@ module Bundler @thor = thor @name = peek = args.shift @scope = "global" - if peek && peek =~ /^\-\-/ - @name = args.shift - @scope = $' - end + return unless peek && peek.start_with?("--") + @name = args.shift + @scope = peek[2..-1] end def run @@ -59,7 +59,7 @@ module Bundler def new_value pathname = Pathname.new(args.join(" ")) - if name.match(/\Alocal\./) && pathname.directory? + if name.start_with?("local.") && pathname.directory? pathname.expand_path.to_s else args.join(" ") diff --git a/lib/bundler/cli/console.rb b/lib/bundler/cli/console.rb index 6e4e1b6686..5e72cdbf0f 100644 --- a/lib/bundler/cli/console.rb +++ b/lib/bundler/cli/console.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true module Bundler class CLI::Console attr_reader :options, :group diff --git a/lib/bundler/cli/exec.rb b/lib/bundler/cli/exec.rb index 8b828edf87..4ccc4ba55a 100644 --- a/lib/bundler/cli/exec.rb +++ b/lib/bundler/cli/exec.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "bundler/current_ruby" module Bundler diff --git a/lib/bundler/cli/gem.rb b/lib/bundler/cli/gem.rb index 96d5a6849a..72a1880c52 100644 --- a/lib/bundler/cli/gem.rb +++ b/lib/bundler/cli/gem.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "pathname" module Bundler @@ -5,7 +6,7 @@ module Bundler TEST_FRAMEWORK_VERSIONS = { "rspec" => "3.0", "minitest" => "5.0" - } + }.freeze attr_reader :options, :gem_name, :thor, :name, :target @@ -135,10 +136,8 @@ module Bundler `git add .` end - if options[:edit] - # Open gemspec in editor - thor.run("#{options["edit"]} \"#{target.join("#{name}.gemspec")}\"") - end + # Open gemspec in editor + open_editor(options["edit"], target.join("#{name}.gemspec")) if options[:edit] end private @@ -207,5 +206,9 @@ module Bundler exit 1 end end + + def open_editor(editor, file) + thor.run(%(#{editor} "#{file}")) + end end end diff --git a/lib/bundler/cli/init.rb b/lib/bundler/cli/init.rb index 1d201a90f5..4bbdee1f48 100644 --- a/lib/bundler/cli/init.rb +++ b/lib/bundler/cli/init.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true module Bundler class CLI::Init attr_reader :options diff --git a/lib/bundler/cli/inject.rb b/lib/bundler/cli/inject.rb index a17bce036f..e319feb201 100644 --- a/lib/bundler/cli/inject.rb +++ b/lib/bundler/cli/inject.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true module Bundler class CLI::Inject attr_reader :options, :name, :version, :gems diff --git a/lib/bundler/cli/install.rb b/lib/bundler/cli/install.rb index 4640ad9485..0e8599963b 100644 --- a/lib/bundler/cli/install.rb +++ b/lib/bundler/cli/install.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true module Bundler class CLI::Install attr_reader :options @@ -165,10 +166,9 @@ module Bundler end def confirm_without_groups - if Bundler.settings.without.any? - require "bundler/cli/common" - Bundler.ui.confirm Bundler::CLI::Common.without_groups_message - end + return unless Bundler.settings.without.any? + require "bundler/cli/common" + Bundler.ui.confirm Bundler::CLI::Common.without_groups_message end def dependencies_count_for(definition) diff --git a/lib/bundler/cli/lock.rb b/lib/bundler/cli/lock.rb index 457826dfb5..e95e9ff636 100644 --- a/lib/bundler/cli/lock.rb +++ b/lib/bundler/cli/lock.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true module Bundler class CLI::Lock attr_reader :options diff --git a/lib/bundler/cli/open.rb b/lib/bundler/cli/open.rb index 0bf42038d9..d4dba703cd 100644 --- a/lib/bundler/cli/open.rb +++ b/lib/bundler/cli/open.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "bundler/cli/common" require "shellwords" diff --git a/lib/bundler/cli/outdated.rb b/lib/bundler/cli/outdated.rb index 179635b803..3c85d0bdcd 100644 --- a/lib/bundler/cli/outdated.rb +++ b/lib/bundler/cli/outdated.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "bundler/cli/common" module Bundler diff --git a/lib/bundler/cli/package.rb b/lib/bundler/cli/package.rb index de53cb6d8d..cf65e8a68c 100644 --- a/lib/bundler/cli/package.rb +++ b/lib/bundler/cli/package.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true module Bundler class CLI::Package attr_reader :options diff --git a/lib/bundler/cli/platform.rb b/lib/bundler/cli/platform.rb index 28641a4c8b..aec08789a9 100644 --- a/lib/bundler/cli/platform.rb +++ b/lib/bundler/cli/platform.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true module Bundler class CLI::Platform attr_reader :options diff --git a/lib/bundler/cli/show.rb b/lib/bundler/cli/show.rb index 50cf0a97d5..d67b086dd1 100644 --- a/lib/bundler/cli/show.rb +++ b/lib/bundler/cli/show.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "bundler/cli/common" module Bundler diff --git a/lib/bundler/cli/update.rb b/lib/bundler/cli/update.rb index 62abc13b58..1a76a88c3d 100644 --- a/lib/bundler/cli/update.rb +++ b/lib/bundler/cli/update.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true module Bundler class CLI::Update attr_reader :options, :gems @@ -63,10 +64,9 @@ module Bundler private def without_groups_messages - if Bundler.settings.without.any? - require "bundler/cli/common" - Bundler.ui.confirm Bundler::CLI::Common.without_groups_message - end + return unless Bundler.settings.without.any? + require "bundler/cli/common" + Bundler.ui.confirm Bundler::CLI::Common.without_groups_message end end end diff --git a/lib/bundler/cli/viz.rb b/lib/bundler/cli/viz.rb index 3e1b29a513..7ccd306d63 100644 --- a/lib/bundler/cli/viz.rb +++ b/lib/bundler/cli/viz.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true module Bundler class CLI::Viz attr_reader :options, :gem_name @@ -15,12 +16,9 @@ module Bundler Bundler.ui.warn "Make sure you have the graphviz ruby gem. You can install it with:" Bundler.ui.warn "`gem install ruby-graphviz`" rescue StandardError => e - if e.message =~ /GraphViz not installed or dot not in PATH/ - Bundler.ui.error e.message - Bundler.ui.warn "Please install GraphViz. On a Mac with homebrew, you can run `brew install graphviz`." - else - raise - end + raise unless e.message =~ /GraphViz not installed or dot not in PATH/ + Bundler.ui.error e.message + Bundler.ui.warn "Please install GraphViz. On a Mac with homebrew, you can run `brew install graphviz`." end end end diff --git a/lib/bundler/constants.rb b/lib/bundler/constants.rb index 704bcac84f..5b1c0a8cb1 100644 --- a/lib/bundler/constants.rb +++ b/lib/bundler/constants.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true module Bundler WINDOWS = RbConfig::CONFIG["host_os"] =~ /(msdos|mswin|djgpp|mingw)/ FREEBSD = RbConfig::CONFIG["host_os"] =~ /bsd/ diff --git a/lib/bundler/current_ruby.rb b/lib/bundler/current_ruby.rb index 671171dc37..a7fa2f3a89 100644 --- a/lib/bundler/current_ruby.rb +++ b/lib/bundler/current_ruby.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true module Bundler # Returns current version of Ruby # diff --git a/lib/bundler/definition.rb b/lib/bundler/definition.rb index 636d643a94..d98d8b15b6 100644 --- a/lib/bundler/definition.rb +++ b/lib/bundler/definition.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "bundler/lockfile_parser" require "digest/sha1" require "set" @@ -347,12 +348,13 @@ module Bundler end def ensure_equivalent_gemfile_and_lockfile(explicit_flag = false) - msg = "You are trying to install in deployment mode after changing\n" \ - "your Gemfile. Run `bundle install` elsewhere and add the\n" \ - "updated #{Bundler.default_lockfile.relative_path_from(SharedHelpers.pwd)} to version control." + msg = String.new + msg << "You are trying to install in deployment mode after changing\n" \ + "your Gemfile. Run `bundle install` elsewhere and add the\n" \ + "updated #{Bundler.default_lockfile.relative_path_from(SharedHelpers.pwd)} to version control." unless explicit_flag - msg += "\n\nIf this is a development machine, remove the #{Bundler.default_gemfile} " \ + msg << "\n\nIf this is a development machine, remove the #{Bundler.default_gemfile} " \ "freeze \nby running `bundle install --no-deployment`." end diff --git a/lib/bundler/dep_proxy.rb b/lib/bundler/dep_proxy.rb index 4efd99c9bb..998975bbaf 100644 --- a/lib/bundler/dep_proxy.rb +++ b/lib/bundler/dep_proxy.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true module Bundler class DepProxy attr_reader :__platform, :dep diff --git a/lib/bundler/dependency.rb b/lib/bundler/dependency.rb index a62808d23c..1b1808b40a 100644 --- a/lib/bundler/dependency.rb +++ b/lib/bundler/dependency.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "rubygems/dependency" require "bundler/shared_helpers" require "bundler/rubygems_ext" diff --git a/lib/bundler/deployment.rb b/lib/bundler/deployment.rb index 163f61eabb..23968e7084 100644 --- a/lib/bundler/deployment.rb +++ b/lib/bundler/deployment.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true module Bundler class Deployment def self.define_task(context, task_method = :task, opts = {}) diff --git a/lib/bundler/deprecate.rb b/lib/bundler/deprecate.rb index 02eb4b0918..1ab4de1a28 100644 --- a/lib/bundler/deprecate.rb +++ b/lib/bundler/deprecate.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true module Bundler if defined? ::Deprecate Deprecate = ::Deprecate diff --git a/lib/bundler/dsl.rb b/lib/bundler/dsl.rb index 57be120d9f..b3b6bfdcce 100644 --- a/lib/bundler/dsl.rb +++ b/lib/bundler/dsl.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "bundler/dependency" require "bundler/ruby_dsl" @@ -93,9 +94,8 @@ module Bundler if current.requirement != dep.requirement if current.type == :development @dependencies.delete current - elsif dep.type == :development - return else + return if dep.type == :development raise GemfileError, "You cannot specify the same gem twice with different version requirements.\n" \ "You specified: #{current.name} (#{current.requirement}) and #{dep.name} (#{dep.requirement})" end @@ -109,9 +109,8 @@ module Bundler if current.source != dep.source if current.type == :development @dependencies.delete current - elsif dep.type == :development - return else + return if dep.type == :development raise GemfileError, "You cannot specify the same gem twice coming from different sources.\n" \ "You specified that #{dep.name} (#{dep.requirement}) should come from " \ "#{current.source || "an unspecified source"} and #{dep.source}\n" @@ -347,7 +346,8 @@ module Bundler def validate_keys(command, opts, valid_keys) invalid_keys = opts.keys - valid_keys if invalid_keys.any? - message = "You passed #{invalid_keys.map {|k| ":" + k }.join(", ")} " + message = String.new + message << "You passed #{invalid_keys.map {|k| ":" + k }.join(", ")} " message << if invalid_keys.size > 1 "as options for #{command}, but they are invalid." else @@ -452,7 +452,7 @@ module Bundler @to_s ||= begin trace_line, description = parse_line_number_from_description - m = "\n[!] " + m = String.new("\n[!] ") m << description m << ". Bundler cannot continue.\n" diff --git a/lib/bundler/endpoint_specification.rb b/lib/bundler/endpoint_specification.rb index 24f1637b9e..b26fdaf9cc 100644 --- a/lib/bundler/endpoint_specification.rb +++ b/lib/bundler/endpoint_specification.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true module Bundler # used for Creating Specifications from the Gemcutter Endpoint class EndpointSpecification < Gem::Specification @@ -83,10 +84,9 @@ module Bundler end def _local_specification - if @loaded_from && File.exist?(local_specification_path) - eval(File.read(local_specification_path)).tap do |spec| - spec.loaded_from = @loaded_from - end + return unless @loaded_from && File.exist?(local_specification_path) + eval(File.read(local_specification_path)).tap do |spec| + spec.loaded_from = @loaded_from end end diff --git a/lib/bundler/env.rb b/lib/bundler/env.rb index 93d35900ae..baf6a10f31 100644 --- a/lib/bundler/env.rb +++ b/lib/bundler/env.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "bundler/rubygems_integration" require "bundler/source/git/git_proxy" diff --git a/lib/bundler/environment.rb b/lib/bundler/environment.rb index 0e4ed37814..4e072602e6 100644 --- a/lib/bundler/environment.rb +++ b/lib/bundler/environment.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true module Bundler class Environment attr_reader :root diff --git a/lib/bundler/errors.rb b/lib/bundler/errors.rb index 9fc7b6df7b..eec8d00ef5 100644 --- a/lib/bundler/errors.rb +++ b/lib/bundler/errors.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true module Bundler class BundlerError < StandardError def self.status_code(code) diff --git a/lib/bundler/fetcher.rb b/lib/bundler/fetcher.rb index 2511b964d6..348c29dcbe 100644 --- a/lib/bundler/fetcher.rb +++ b/lib/bundler/fetcher.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "bundler/vendored_persistent" require "cgi" require "securerandom" @@ -53,15 +54,17 @@ module Bundler # Exceptions classes that should bypass retry attempts. If your password didn't work the # first time, it's not going to the third time. - FAIL_ERRORS = [AuthenticationRequiredError, BadAuthenticationError, FallbackError] NET_ERRORS = [:HTTPBadGateway, :HTTPBadRequest, :HTTPFailedDependency, :HTTPForbidden, :HTTPInsufficientStorage, :HTTPMethodNotAllowed, :HTTPMovedPermanently, :HTTPNoContent, :HTTPNotFound, :HTTPNotImplemented, :HTTPPreconditionFailed, :HTTPRequestEntityTooLarge, :HTTPRequestURITooLong, :HTTPUnauthorized, :HTTPUnprocessableEntity, - :HTTPUnsupportedMediaType, :HTTPVersionNotSupported] - FAIL_ERRORS << Gem::Requirement::BadRequirementError if defined?(Gem::Requirement::BadRequirementError) - FAIL_ERRORS.push(*NET_ERRORS.map {|e| SharedHelpers.const_get_safely(e, Net) }.compact) + :HTTPUnsupportedMediaType, :HTTPVersionNotSupported].freeze + FAIL_ERRORS = begin + fail_errors = [AuthenticationRequiredError, BadAuthenticationError, FallbackError] + fail_errors << Gem::Requirement::BadRequirementError if defined?(Gem::Requirement::BadRequirementError) + fail_errors.push(*NET_ERRORS.map {|e| SharedHelpers.const_get_safely(e, Net) }.compact) + end.freeze class << self attr_accessor :disable_endpoint, :api_timeout, :redirect_limit, :max_retries @@ -127,11 +130,10 @@ module Bundler specs.each do |name, version, platform, dependencies| next if name == "bundler" - spec = nil - if dependencies - spec = EndpointSpecification.new(name, version, platform, dependencies) + spec = if dependencies + EndpointSpecification.new(name, version, platform, dependencies) else - spec = RemoteSpecification.new(name, version, platform, self) + RemoteSpecification.new(name, version, platform, self) end spec.source = source spec.remote = @remote @@ -151,10 +153,10 @@ module Bundler fetchers.shift until fetchers.first.available? - if remote_uri.scheme == "file" || Bundler::Fetcher.disable_endpoint - @use_api = false + @use_api = if remote_uri.scheme == "file" || Bundler::Fetcher.disable_endpoint + false else - @use_api = fetchers.first.api_fetcher? + fetchers.first.api_fetcher? end end @@ -162,7 +164,7 @@ module Bundler @user_agent ||= begin ruby = Bundler::RubyVersion.system - agent = "bundler/#{Bundler::VERSION}" + agent = String.new("bundler/#{Bundler::VERSION}") agent << " rubygems/#{Gem::VERSION}" agent << " ruby/#{ruby.version}" agent << " (#{ruby.host})" @@ -198,9 +200,8 @@ module Bundler end def http_proxy - if uri = connection.proxy_uri - uri.to_s - end + return unless uri = connection.proxy_uri + uri.to_s end def inspect @@ -209,7 +210,7 @@ module Bundler private - FETCHERS = [CompactIndex, Dependency, Index] + FETCHERS = [CompactIndex, Dependency, Index].freeze def cis env_cis = { @@ -269,7 +270,7 @@ module Bundler Errno::EINVAL, Errno::ECONNRESET, Errno::ETIMEDOUT, Errno::EAGAIN, Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError, Net::ProtocolError, Net::HTTP::Persistent::Error, Zlib::BufError - ] + ].freeze def bundler_cert_store store = OpenSSL::X509::Store.new diff --git a/lib/bundler/fetcher/base.rb b/lib/bundler/fetcher/base.rb index 1d1adc73db..f7210bd03d 100644 --- a/lib/bundler/fetcher/base.rb +++ b/lib/bundler/fetcher/base.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true module Bundler class Fetcher class Base diff --git a/lib/bundler/fetcher/compact_index.rb b/lib/bundler/fetcher/compact_index.rb index 0dd9b130be..f249ec1835 100644 --- a/lib/bundler/fetcher/compact_index.rb +++ b/lib/bundler/fetcher/compact_index.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "bundler/fetcher/base" require "bundler/worker" diff --git a/lib/bundler/fetcher/dependency.rb b/lib/bundler/fetcher/dependency.rb index fdf91c1710..274b34eefd 100644 --- a/lib/bundler/fetcher/dependency.rb +++ b/lib/bundler/fetcher/dependency.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "bundler/fetcher/base" require "cgi" diff --git a/lib/bundler/fetcher/downloader.rb b/lib/bundler/fetcher/downloader.rb index 68f63ed54d..204e33387e 100644 --- a/lib/bundler/fetcher/downloader.rb +++ b/lib/bundler/fetcher/downloader.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true module Bundler class Fetcher class Downloader @@ -46,11 +47,8 @@ module Bundler end connection.request(uri, req) rescue NoMethodError => e - if ["undefined method", "use_ssl="].all? {|snippet| e.message.include? snippet } - raise LoadError.new("cannot load such file -- openssl") - else - raise e - end + raise unless ["undefined method", "use_ssl="].all? {|snippet| e.message.include? snippet } + raise LoadError.new("cannot load such file -- openssl") rescue OpenSSL::SSL::SSLError raise CertificateFailureError.new(uri) rescue *HTTP_ERRORS => e diff --git a/lib/bundler/fetcher/index.rb b/lib/bundler/fetcher/index.rb index 1d8aa657a8..d8e212989e 100644 --- a/lib/bundler/fetcher/index.rb +++ b/lib/bundler/fetcher/index.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "bundler/fetcher/base" require "rubygems/remote_fetcher" @@ -13,11 +14,8 @@ module Bundler when /401/ raise AuthenticationRequiredError, remote_uri when /403/ - if remote_uri.userinfo - raise BadAuthenticationError, remote_uri - else - raise AuthenticationRequiredError, remote_uri - end + raise BadAuthenticationError, remote_uri if remote_uri.userinfo + raise AuthenticationRequiredError, remote_uri else Bundler.ui.trace e raise HTTPError, "Could not fetch specs from #{display_uri}" diff --git a/lib/bundler/friendly_errors.rb b/lib/bundler/friendly_errors.rb index fd98bf55e1..b453e8e625 100644 --- a/lib/bundler/friendly_errors.rb +++ b/lib/bundler/friendly_errors.rb @@ -1,4 +1,5 @@ # encoding: utf-8 +# frozen_string_literal: true require "cgi" require "bundler/vendored_thor" @@ -68,7 +69,7 @@ module Bundler Error details #{e.class}: #{e.message} - #{e.backtrace.join("\n ")} + #{e.backtrace.join("\n ")} #{Bundler::Env.new.report(:print_gemfile => false, :print_gemspecs => false).gsub(/\n/, "\n ").strip} --- TEMPLATE END ---------------------------------------------------------------- diff --git a/lib/bundler/gem_helper.rb b/lib/bundler/gem_helper.rb index 8cfbeb4df1..41c574bfd2 100644 --- a/lib/bundler/gem_helper.rb +++ b/lib/bundler/gem_helper.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "bundler/vendored_thor" unless defined?(Thor) require "bundler" @@ -91,18 +92,17 @@ module Bundler protected def rubygem_push(path) - if Pathname.new("~/.gem/credentials").expand_path.exist? - allowed_push_host = nil - gem_command = "gem push '#{path}'" - if @gemspec.respond_to?(:metadata) - allowed_push_host = @gemspec.metadata["allowed_push_host"] - gem_command << " --host #{allowed_push_host}" if allowed_push_host - end - sh(gem_command) - Bundler.ui.confirm "Pushed #{name} #{version} to #{allowed_push_host ? allowed_push_host : "rubygems.org."}" - else + unless Pathname.new("~/.gem/credentials").expand_path.file? raise "Your rubygems.org credentials aren't set. Run `gem push` to set them." end + allowed_push_host = nil + gem_command = "gem push '#{path}'" + if @gemspec.respond_to?(:metadata) + allowed_push_host = @gemspec.metadata["allowed_push_host"] + gem_command += " --host #{allowed_push_host}" if allowed_push_host + end + sh(gem_command) + Bundler.ui.confirm "Pushed #{name} #{version} to #{allowed_push_host ? allowed_push_host : "rubygems.org."}" end def built_gem_path @@ -122,10 +122,9 @@ module Bundler end def already_tagged? - if sh("git tag").split(/\n/).include?(version_tag) - Bundler.ui.confirm "Tag #{version_tag} has already been created." - true - end + return false unless sh("git tag").split(/\n/).include?(version_tag) + Bundler.ui.confirm "Tag #{version_tag} has already been created." + true end def guard_clean @@ -164,22 +163,22 @@ module Bundler def sh(cmd, &block) out, code = sh_with_code(cmd, &block) - if code == 0 - out - else + unless code.zero? raise(out.empty? ? "Running `#{cmd}` failed. Run this command directly for more detailed output." : out) end + out end def sh_with_code(cmd, &block) - cmd << " 2>&1" + cmd += " 2>&1" outbuf = String.new Bundler.ui.debug(cmd) SharedHelpers.chdir(base) do outbuf = `#{cmd}` - block.call(outbuf) if $? == 0 && block + status = $?.exitstatus + block.call(outbuf) if status.zero? && block + [outbuf, status] end - [outbuf, $?] end def gem_push? diff --git a/lib/bundler/gem_helpers.rb b/lib/bundler/gem_helpers.rb index 146998957d..5c824ffefc 100644 --- a/lib/bundler/gem_helpers.rb +++ b/lib/bundler/gem_helpers.rb @@ -1,6 +1,7 @@ +# frozen_string_literal: true module Bundler module GemHelpers - GENERIC_CACHE = {} + GENERIC_CACHE = {} # rubocop:disable MutableConstant GENERICS = [ [Gem::Platform.new("java"), Gem::Platform.new("java")], [Gem::Platform.new("mswin32"), Gem::Platform.new("mswin32")], @@ -9,7 +10,7 @@ module Bundler [Gem::Platform.new("x64-mingw32"), Gem::Platform.new("x64-mingw32")], [Gem::Platform.new("x86_64-mingw32"), Gem::Platform.new("x64-mingw32")], [Gem::Platform.new("mingw32"), Gem::Platform.new("x86-mingw32")] - ] + ].freeze def generic(p) return p if p == Gem::Platform::RUBY diff --git a/lib/bundler/gem_remote_fetcher.rb b/lib/bundler/gem_remote_fetcher.rb index 8a823da963..481838a5e2 100644 --- a/lib/bundler/gem_remote_fetcher.rb +++ b/lib/bundler/gem_remote_fetcher.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "rubygems/remote_fetcher" module Bundler diff --git a/lib/bundler/gem_tasks.rb b/lib/bundler/gem_tasks.rb index 0ff383bf8b..230e7f28f2 100644 --- a/lib/bundler/gem_tasks.rb +++ b/lib/bundler/gem_tasks.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "rake/clean" CLOBBER.include "pkg" diff --git a/lib/bundler/graph.rb b/lib/bundler/graph.rb index 414ec712fa..c7e957ad7a 100644 --- a/lib/bundler/graph.rb +++ b/lib/bundler/graph.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "set" module Bundler class Graph @@ -31,25 +32,23 @@ module Bundler def _populate_relations parent_dependencies = _groups.values.to_set.flatten loop do - if parent_dependencies.empty? - break - else - tmp = Set.new - parent_dependencies.each do |dependency| - # if the dependency is a prerelease, allow to_spec to be non-nil - dependency.prerelease = true - - child_dependencies = dependency.to_spec.runtime_dependencies.to_set - @relations[dependency.name] += child_dependencies.map(&:name).to_set - tmp += child_dependencies - - @node_options[dependency.name] = _make_label(dependency, :node) - child_dependencies.each do |c_dependency| - @edge_options["#{dependency.name}_#{c_dependency.name}"] = _make_label(c_dependency, :edge) - end + break if parent_dependencies.empty? + + tmp = Set.new + parent_dependencies.each do |dependency| + # if the dependency is a prerelease, allow to_spec to be non-nil + dependency.prerelease = true + + child_dependencies = dependency.to_spec.runtime_dependencies.to_set + @relations[dependency.name] += child_dependencies.map(&:name).to_set + tmp += child_dependencies + + @node_options[dependency.name] = _make_label(dependency, :node) + child_dependencies.each do |c_dependency| + @edge_options["#{dependency.name}_#{c_dependency.name}"] = _make_label(c_dependency, :edge) end - parent_dependencies = tmp end + parent_dependencies = tmp end end diff --git a/lib/bundler/index.rb b/lib/bundler/index.rb index 1fa90e71ee..f2defe1cff 100644 --- a/lib/bundler/index.rb +++ b/lib/bundler/index.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "set" module Bundler @@ -139,12 +140,9 @@ module Bundler end def add_source(index) - if index.is_a?(Index) - @sources << index - @sources.uniq! # need to use uniq! here instead of checking for the item before adding - else - raise ArgumentError, "Source must be an index, not #{index.class}" - end + raise ArgumentError, "Source must be an index, not #{index.class}" unless index.is_a?(Index) + @sources << index + @sources.uniq! # need to use uniq! here instead of checking for the item before adding end private diff --git a/lib/bundler/injector.rb b/lib/bundler/injector.rb index ef98fad888..c27e2499ca 100644 --- a/lib/bundler/injector.rb +++ b/lib/bundler/injector.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true module Bundler class Injector def self.inject(new_deps) diff --git a/lib/bundler/inline.rb b/lib/bundler/inline.rb index 9df19b02ad..da4afd01bb 100644 --- a/lib/bundler/inline.rb +++ b/lib/bundler/inline.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true # Allows for declaring a Gemfile inline in a ruby script, optionally installing # any gems that aren't already installed on the user's system. # diff --git a/lib/bundler/installer.rb b/lib/bundler/installer.rb index 8257458476..3a54a02151 100644 --- a/lib/bundler/installer.rb +++ b/lib/bundler/installer.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "erb" require "rubygems/dependency_installer" require "bundler/worker" @@ -190,9 +191,8 @@ module Bundler end end - unless local - options["local"] ? @definition.resolve_with_cache! : @definition.resolve_remotely! - end + return if local + options["local"] ? @definition.resolve_with_cache! : @definition.resolve_remotely! end end end diff --git a/lib/bundler/installer/gem_installer.rb b/lib/bundler/installer/gem_installer.rb index f6f865b2ab..441c72108f 100644 --- a/lib/bundler/installer/gem_installer.rb +++ b/lib/bundler/installer/gem_installer.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true module Bundler class GemInstaller attr_reader :spec, :standalone, :worker, :force, :installer diff --git a/lib/bundler/installer/parallel_installer.rb b/lib/bundler/installer/parallel_installer.rb index 674c45af25..0a276aa9ea 100644 --- a/lib/bundler/installer/parallel_installer.rb +++ b/lib/bundler/installer/parallel_installer.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "bundler/worker" require "bundler/installer/gem_installer" diff --git a/lib/bundler/installer/standalone.rb b/lib/bundler/installer/standalone.rb index 40100b9540..69cfbfc455 100644 --- a/lib/bundler/installer/standalone.rb +++ b/lib/bundler/installer/standalone.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true module Bundler class Standalone def initialize(groups, definition) diff --git a/lib/bundler/lazy_specification.rb b/lib/bundler/lazy_specification.rb index b3d0d4e732..ccaa791cc8 100644 --- a/lib/bundler/lazy_specification.rb +++ b/lib/bundler/lazy_specification.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "uri" require "rubygems/spec_fetcher" require "bundler/match_platform" diff --git a/lib/bundler/lockfile_parser.rb b/lib/bundler/lockfile_parser.rb index 1412cb879b..94e88dbd0c 100644 --- a/lib/bundler/lockfile_parser.rb +++ b/lib/bundler/lockfile_parser.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "strscan" # Some versions of the Bundler 1.1 RC series introduced corrupted @@ -14,16 +15,16 @@ module Bundler class LockfileParser attr_reader :sources, :dependencies, :specs, :platforms, :bundler_version, :ruby_version - BUNDLED = "BUNDLED WITH" - DEPENDENCIES = "DEPENDENCIES" - PLATFORMS = "PLATFORMS" - RUBY = "RUBY VERSION" - GIT = "GIT" - GEM = "GEM" - PATH = "PATH" - SPECS = " specs:" + BUNDLED = "BUNDLED WITH".freeze + DEPENDENCIES = "DEPENDENCIES".freeze + PLATFORMS = "PLATFORMS".freeze + RUBY = "RUBY VERSION".freeze + GIT = "GIT".freeze + GEM = "GEM".freeze + PATH = "PATH".freeze + SPECS = " specs:".freeze OPTIONS = /^ ([a-z]+): (.*)$/i - SOURCE = [GIT, GEM, PATH] + SOURCE = [GIT, GEM, PATH].freeze def initialize(lockfile) @platforms = [] @@ -89,7 +90,7 @@ module Bundler GIT => Bundler::Source::Git, GEM => Bundler::Source::Rubygems, PATH => Bundler::Source::Path, - } + }.freeze def parse_source(line) case line @@ -134,7 +135,7 @@ module Bundler end end - NAME_VERSION = '(?! )(.*?)(?: \(([^-]*)(?:-(.*))?\))?' + NAME_VERSION = '(?! )(.*?)(?: \(([^-]*)(?:-(.*))?\))?'.freeze NAME_VERSION_2 = /^ {2}#{NAME_VERSION}(!)?$/ NAME_VERSION_4 = /^ {4}#{NAME_VERSION}$/ NAME_VERSION_6 = /^ {6}#{NAME_VERSION}$/ @@ -192,9 +193,8 @@ module Bundler def parse_bundled_with(line) line = line.strip - if Gem::Version.correct?(line) - @bundler_version = Gem::Version.create(line) - end + return unless Gem::Version.correct?(line) + @bundler_version = Gem::Version.create(line) end def parse_ruby(line) diff --git a/lib/bundler/match_platform.rb b/lib/bundler/match_platform.rb index f4b9492c25..fed418b593 100644 --- a/lib/bundler/match_platform.rb +++ b/lib/bundler/match_platform.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "bundler/gem_helpers" module Bundler diff --git a/lib/bundler/mirror.rb b/lib/bundler/mirror.rb index 45534be035..4978462bb3 100644 --- a/lib/bundler/mirror.rb +++ b/lib/bundler/mirror.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true module Bundler class Settings # Class used to build the mirror set and then find a mirror for a given URI diff --git a/lib/bundler/path_preserver.rb b/lib/bundler/path_preserver.rb index c37d7aa087..f5701cd67b 100644 --- a/lib/bundler/path_preserver.rb +++ b/lib/bundler/path_preserver.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true module Bundler module PathPreserver def self.preserve_path_in_environment(env_var, env) diff --git a/lib/bundler/psyched_yaml.rb b/lib/bundler/psyched_yaml.rb index 429cdb85f2..2c85cb0a53 100644 --- a/lib/bundler/psyched_yaml.rb +++ b/lib/bundler/psyched_yaml.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true # Psych could be a gem, so try to ask for it begin gem "psych" diff --git a/lib/bundler/remote_specification.rb b/lib/bundler/remote_specification.rb index 2ed4fadadc..29735fc6ab 100644 --- a/lib/bundler/remote_specification.rb +++ b/lib/bundler/remote_specification.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "uri" require "rubygems/spec_fetcher" diff --git a/lib/bundler/resolver.rb b/lib/bundler/resolver.rb index a10c03b0f6..d22ab34e98 100644 --- a/lib/bundler/resolver.rb +++ b/lib/bundler/resolver.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true module Bundler class Resolver require "bundler/vendored_molinillo" @@ -12,7 +13,7 @@ module Bundler end def message - conflicts.sort.reduce("") do |o, (name, conflict)| + conflicts.sort.reduce(String.new) do |o, (name, conflict)| o << %(Bundler could not find compatible versions for gem "#{name}":\n) if conflict.locked_requirement o << %( In snapshot (#{Bundler.default_lockfile.basename}):\n) @@ -216,11 +217,10 @@ module Bundler # @param [Integer] depth the current depth of the resolution process. # @return [void] def debug(depth = 0) - if debug? - debug_info = yield - debug_info = debug_info.inspect unless debug_info.is_a?(String) - STDERR.puts debug_info.split("\n").map {|s| " " * depth + s } - end + return unless debug? + debug_info = yield + debug_info = debug_info.inspect unless debug_info.is_a?(String) + STDERR.puts debug_info.split("\n").map {|s| " " * depth + s } end def debug? @@ -342,12 +342,12 @@ module Bundler elsif requirement.source name = requirement.name versions = @source_requirements[name][name].map(&:version) - message = "Could not find gem '#{requirement}' in #{requirement.source}.\n" - if versions.any? - message << "Source contains '#{name}' at: #{versions.join(", ")}" - else - message << "Source does not contain any versions of '#{requirement}'" - end + message = String.new("Could not find gem '#{requirement}' in #{requirement.source}.\n") + message << if versions.any? + "Source contains '#{name}' at: #{versions.join(", ")}" + else + "Source does not contain any versions of '#{requirement}'" + end else message = "Could not find gem '#{requirement}' in any of the gem sources " \ "listed in your Gemfile or available on this machine." diff --git a/lib/bundler/retry.rb b/lib/bundler/retry.rb index 4b0fff4bd5..bf4d6ab7f7 100644 --- a/lib/bundler/retry.rb +++ b/lib/bundler/retry.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true module Bundler # General purpose class for retrying code that may fail class Retry diff --git a/lib/bundler/ruby_dsl.rb b/lib/bundler/ruby_dsl.rb index 46587e98cf..47f2bcc337 100644 --- a/lib/bundler/ruby_dsl.rb +++ b/lib/bundler/ruby_dsl.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true module Bundler module RubyDsl def ruby(ruby_version, options = {}) diff --git a/lib/bundler/ruby_version.rb b/lib/bundler/ruby_version.rb index 71ed828f71..b8f3b8a863 100644 --- a/lib/bundler/ruby_version.rb +++ b/lib/bundler/ruby_version.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true module Bundler class RubyVersion attr_reader :version, :patchlevel, :engine, :engine_version @@ -23,7 +24,7 @@ module Bundler end def to_s - output = "ruby #{version}" + output = String.new("ruby #{version}") output << "p#{patchlevel}" if patchlevel output << " (#{engine} #{engine_version})" unless engine == "ruby" diff --git a/lib/bundler/rubygems_ext.rb b/lib/bundler/rubygems_ext.rb index e1051a3851..22c22a2dd0 100644 --- a/lib/bundler/rubygems_ext.rb +++ b/lib/bundler/rubygems_ext.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "pathname" if defined?(Gem::QuickLoader) @@ -78,7 +79,7 @@ module Gem end def to_gemfile(path = nil) - gemfile = "source 'https://rubygems.org'\n" + gemfile = String.new("source 'https://rubygems.org'\n") gemfile << dependencies_to_gemfile(nondevelopment_dependencies) unless development_dependencies.empty? gemfile << "\n" diff --git a/lib/bundler/rubygems_gem_installer.rb b/lib/bundler/rubygems_gem_installer.rb index 5d7be0cb7e..43637e1e60 100644 --- a/lib/bundler/rubygems_gem_installer.rb +++ b/lib/bundler/rubygems_gem_installer.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "rubygems/installer" module Bundler diff --git a/lib/bundler/rubygems_integration.rb b/lib/bundler/rubygems_integration.rb index 5818f5b16a..c8ebe2cb9a 100644 --- a/lib/bundler/rubygems_integration.rb +++ b/lib/bundler/rubygems_integration.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "monitor" require "rubygems" require "rubygems/config_file" diff --git a/lib/bundler/runtime.rb b/lib/bundler/runtime.rb index 400a0c878d..6ef476b9dc 100644 --- a/lib/bundler/runtime.rb +++ b/lib/bundler/runtime.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "digest/sha1" module Bundler @@ -52,7 +53,7 @@ module Bundler /^Missing API definition file in (.+)$/i, /^cannot load such file -- (.+)$/i, /^dlopen\([^)]*\): Library not loaded: (.+)$/i, - ] + ].freeze def require(*groups) groups.map!(&:to_sym) @@ -273,11 +274,10 @@ module Bundler man_subdir unless Dir[man_subdir + "/man?/"].empty? end.compact - unless manuals.empty? - ENV["MANPATH"] = manuals.concat( - ENV["MANPATH"].to_s.split(File::PATH_SEPARATOR) - ).uniq.join(File::PATH_SEPARATOR) - end + return if manuals.empty? + ENV["MANPATH"] = manuals.concat( + ENV["MANPATH"].to_s.split(File::PATH_SEPARATOR) + ).uniq.join(File::PATH_SEPARATOR) end def remove_dir(dir, dry_run) diff --git a/lib/bundler/settings.rb b/lib/bundler/settings.rb index 31f1fdd7f2..634d9dc14a 100644 --- a/lib/bundler/settings.rb +++ b/lib/bundler/settings.rb @@ -1,10 +1,11 @@ +# frozen_string_literal: true require "uri" module Bundler class Settings BOOL_KEYS = %w(frozen cache_all no_prune disable_local_branch_check disable_shared_gems ignore_messages gem.mit gem.coc silence_root_warning).freeze NUMBER_KEYS = %w(retry timeout redirect ssl_verify_mode).freeze - DEFAULT_CONFIG = { :retry => 3, :timeout => 10, :redirect => 5 } + DEFAULT_CONFIG = { :retry => 3, :timeout => 10, :redirect => 5 }.freeze def initialize(root = nil) @root = root diff --git a/lib/bundler/setup.rb b/lib/bundler/setup.rb index db13967bb1..9aae6478cd 100644 --- a/lib/bundler/setup.rb +++ b/lib/bundler/setup.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "bundler/shared_helpers" if Bundler::SharedHelpers.in_bundle? diff --git a/lib/bundler/shared_helpers.rb b/lib/bundler/shared_helpers.rb index 48038ac78b..ca26f7b4bf 100644 --- a/lib/bundler/shared_helpers.rb +++ b/lib/bundler/shared_helpers.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "pathname" require "rubygems" @@ -162,10 +163,9 @@ module Bundler def set_rubyopt rubyopt = [ENV["RUBYOPT"]].compact - if rubyopt.empty? || rubyopt.first !~ %r{-rbundler/setup} - rubyopt.unshift %(-rbundler/setup) - ENV["RUBYOPT"] = rubyopt.join(" ") - end + return if !rubyopt.empty? && rubyopt.first =~ %r{-rbundler/setup} + rubyopt.unshift %(-rbundler/setup) + ENV["RUBYOPT"] = rubyopt.join(" ") end def set_rubylib diff --git a/lib/bundler/similarity_detector.rb b/lib/bundler/similarity_detector.rb index 624238552c..e9c1413ea3 100644 --- a/lib/bundler/similarity_detector.rb +++ b/lib/bundler/similarity_detector.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true module Bundler class SimilarityDetector SimilarityScore = Struct.new(:string, :distance) diff --git a/lib/bundler/source.rb b/lib/bundler/source.rb index 0bcf9c3cfe..5f1eb130b7 100644 --- a/lib/bundler/source.rb +++ b/lib/bundler/source.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true module Bundler class Source autoload :Rubygems, "bundler/source/rubygems" @@ -17,7 +18,7 @@ module Bundler locked_spec = Bundler.locked_gems.specs.find {|s| s.name == spec.name } locked_spec_version = locked_spec.version if locked_spec if locked_spec_version && spec.version != locked_spec_version - message << " (was #{locked_spec_version})" + message += " (was #{locked_spec_version})" end end diff --git a/lib/bundler/source/git.rb b/lib/bundler/source/git.rb index b11de1e4bc..90bbd13d34 100644 --- a/lib/bundler/source/git.rb +++ b/lib/bundler/source/git.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "fileutils" require "uri" require "digest/sha1" @@ -35,7 +36,7 @@ module Bundler end def to_lock - out = "GIT\n" + out = String.new("GIT\n") out << " remote: #{@uri}\n" out << " revision: #{revision}\n" %w(ref branch tag submodules).each do |opt| diff --git a/lib/bundler/source/git/git_proxy.rb b/lib/bundler/source/git/git_proxy.rb index a9f782e8d6..19e0db86fa 100644 --- a/lib/bundler/source/git/git_proxy.rb +++ b/lib/bundler/source/git/git_proxy.rb @@ -1,9 +1,11 @@ +# frozen_string_literal: true module Bundler class Source class Git < Path class GitNotInstalledError < GitError def initialize - msg = "You need to install git to be able to use gems from git repositories. " + msg = String.new + msg << "You need to install git to be able to use gems from git repositories. " msg << "For help installing git, please refer to GitHub's tutorial at https://help.github.com/articles/set-up-git" super msg end @@ -11,7 +13,8 @@ module Bundler class GitNotAllowedError < GitError def initialize(command) - msg = "Bundler is trying to run a `git #{command}` at runtime. You probably need to run `bundle install`. However, " + msg = String.new + msg << "Bundler is trying to run a `git #{command}` at runtime. You probably need to run `bundle install`. However, " msg << "this error message could probably be more useful. Please submit a ticket at http://github.com/bundler/bundler/issues " msg << "with steps to reproduce as well as the following\n\nCALLER: #{caller.join("\n")}" super msg @@ -20,7 +23,8 @@ module Bundler class GitCommandError < GitError def initialize(command, path = nil, extra_info = nil) - msg = "Git error: command `git #{command}` in directory #{SharedHelpers.pwd} has failed." + msg = String.new + msg << "Git error: command `git #{command}` in directory #{SharedHelpers.pwd} has failed." msg << "\n#{extra_info}" if extra_info msg << "\nIf this error persists you could try removing the cache directory '#{path}'" if path && path.exist? super msg diff --git a/lib/bundler/source/path.rb b/lib/bundler/source/path.rb index 24a01b4060..6bfd2e88c7 100644 --- a/lib/bundler/source/path.rb +++ b/lib/bundler/source/path.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true module Bundler class Source class Path < Source @@ -7,7 +8,7 @@ module Bundler attr_writer :name attr_accessor :version - DEFAULT_GLOB = "{,*,*/*}.gemspec" + DEFAULT_GLOB = "{,*,*/*}.gemspec".freeze def initialize(options) @options = options @@ -156,10 +157,14 @@ module Bundler end end end - elsif File.exist?(expanded_path) - raise PathError, "The path `#{expanded_path}` is not a directory." else - raise PathError, "The path `#{expanded_path}` does not exist." + message = String.new("The path `#{expanded_path}` ") + message << if File.exist?(expanded_path) + "is not a directory." + else + "does not exist." + end + raise PathError, message end index diff --git a/lib/bundler/source/path/installer.rb b/lib/bundler/source/path/installer.rb index 74542dd913..0aa27bd564 100644 --- a/lib/bundler/source/path/installer.rb +++ b/lib/bundler/source/path/installer.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true module Bundler class Source class Path diff --git a/lib/bundler/source/rubygems.rb b/lib/bundler/source/rubygems.rb index 1315677a52..cebb68a700 100644 --- a/lib/bundler/source/rubygems.rb +++ b/lib/bundler/source/rubygems.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "uri" require "rubygems/user_interaction" require "rubygems/spec_fetcher" @@ -118,7 +119,7 @@ module Bundler unless Bundler.settings[:no_install] message = "Installing #{version_message(spec)}" - message << " with native extensions" if spec.extensions.any? + message += " with native extensions" if spec.extensions.any? Bundler.ui.confirm message path = cached_gem(spec) diff --git a/lib/bundler/source/rubygems/remote.rb b/lib/bundler/source/rubygems/remote.rb index 4cd8ea23b8..32265fb600 100644 --- a/lib/bundler/source/rubygems/remote.rb +++ b/lib/bundler/source/rubygems/remote.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true module Bundler class Source class Rubygems diff --git a/lib/bundler/source_list.rb b/lib/bundler/source_list.rb index c0336bfdd6..dc62c8926a 100644 --- a/lib/bundler/source_list.rb +++ b/lib/bundler/source_list.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true module Bundler class SourceList attr_reader :path_sources, diff --git a/lib/bundler/spec_set.rb b/lib/bundler/spec_set.rb index 855a6e3317..5ec546e8e3 100644 --- a/lib/bundler/spec_set.rb +++ b/lib/bundler/spec_set.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "tsort" require "forwardable" diff --git a/lib/bundler/ssl_certs/certificate_manager.rb b/lib/bundler/ssl_certs/certificate_manager.rb index 558bd9ef50..76639a0cf1 100644 --- a/lib/bundler/ssl_certs/certificate_manager.rb +++ b/lib/bundler/ssl_certs/certificate_manager.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "fileutils" require "net/https" require "openssl" diff --git a/lib/bundler/stub_specification.rb b/lib/bundler/stub_specification.rb index ca5cbe6d9d..f4ee7d0644 100644 --- a/lib/bundler/stub_specification.rb +++ b/lib/bundler/stub_specification.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "bundler/remote_specification" module Bundler diff --git a/lib/bundler/templates/Executable b/lib/bundler/templates/Executable index cc9e06cfec..b72c267dd1 100755 --- a/lib/bundler/templates/Executable +++ b/lib/bundler/templates/Executable @@ -1,4 +1,5 @@ #!/usr/bin/env <%= Bundler.settings[:shebang] || RbConfig::CONFIG['ruby_install_name'] %> +# frozen_string_literal: true # # This file was generated by Bundler. # diff --git a/lib/bundler/templates/Gemfile b/lib/bundler/templates/Gemfile index 8d5b66ea29..3f953369c3 100644 --- a/lib/bundler/templates/Gemfile +++ b/lib/bundler/templates/Gemfile @@ -1,3 +1,4 @@ +# frozen_string_literal: true # A sample Gemfile source "https://rubygems.org" diff --git a/lib/bundler/ui.rb b/lib/bundler/ui.rb index 7400f80ab1..794c000dc4 100644 --- a/lib/bundler/ui.rb +++ b/lib/bundler/ui.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true module Bundler module UI autoload :RGProxy, "bundler/ui/rg_proxy" diff --git a/lib/bundler/ui/rg_proxy.rb b/lib/bundler/ui/rg_proxy.rb index 1c9c2deaba..95a1ecdf0c 100644 --- a/lib/bundler/ui/rg_proxy.rb +++ b/lib/bundler/ui/rg_proxy.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "bundler/ui" require "rubygems/user_interaction" diff --git a/lib/bundler/ui/shell.rb b/lib/bundler/ui/shell.rb index 2c0076dc06..425ffae332 100644 --- a/lib/bundler/ui/shell.rb +++ b/lib/bundler/ui/shell.rb @@ -1,9 +1,10 @@ +# frozen_string_literal: true require "bundler/vendored_thor" module Bundler module UI class Shell - LEVELS = %w(silent error warn confirm info debug) + LEVELS = %w(silent error warn confirm info debug).freeze attr_writer :shell diff --git a/lib/bundler/ui/silent.rb b/lib/bundler/ui/silent.rb index 3eb3199b5c..9f387d9e9f 100644 --- a/lib/bundler/ui/silent.rb +++ b/lib/bundler/ui/silent.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true module Bundler module UI class Silent diff --git a/lib/bundler/vendored_molinillo.rb b/lib/bundler/vendored_molinillo.rb index 795d63a3d3..7b231263cb 100644 --- a/lib/bundler/vendored_molinillo.rb +++ b/lib/bundler/vendored_molinillo.rb @@ -1,2 +1,3 @@ +# frozen_string_literal: true module Bundler; end require "bundler/vendor/molinillo/lib/molinillo" diff --git a/lib/bundler/vendored_persistent.rb b/lib/bundler/vendored_persistent.rb index ef404f35d5..d5ae513c59 100644 --- a/lib/bundler/vendored_persistent.rb +++ b/lib/bundler/vendored_persistent.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true # We forcibly require OpenSSL, because net/http/persistent will only autoload # it. On some Rubies, autoload fails but explicit require succeeds. begin diff --git a/lib/bundler/vendored_thor.rb b/lib/bundler/vendored_thor.rb index 114483db02..0d0b45bfba 100644 --- a/lib/bundler/vendored_thor.rb +++ b/lib/bundler/vendored_thor.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true module Bundler; end require "bundler/vendor/thor/lib/thor" require "bundler/vendor/thor/lib/thor/actions" diff --git a/lib/bundler/version.rb b/lib/bundler/version.rb index 9a3c7dde22..5267367d01 100644 --- a/lib/bundler/version.rb +++ b/lib/bundler/version.rb @@ -1,3 +1,8 @@ +# frozen_string_literal: true + +# Ruby 1.9.3 and old RubyGems don't play nice with frozen version strings +# rubocop:disable MutableConstant + module Bundler # We're doing this because we might write tests that deal # with other versions of bundler and we are unsure how to diff --git a/lib/bundler/vlad.rb b/lib/bundler/vlad.rb index 5e20ae6dac..d017ca475a 100644 --- a/lib/bundler/vlad.rb +++ b/lib/bundler/vlad.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true # Vlad task for Bundler. # # Just add "require 'bundler/vlad'" in your Vlad deploy.rb, and diff --git a/lib/bundler/worker.rb b/lib/bundler/worker.rb index addd9cc8a1..3ef5addcee 100644 --- a/lib/bundler/worker.rb +++ b/lib/bundler/worker.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "thread" module Bundler @@ -24,7 +25,7 @@ module Bundler @request_queue = Queue.new @response_queue = Queue.new @func = func - @threads = size.times.map do |i| + @threads = Array.new(size) do |i| Thread.start { process_queue(i) }.tap do |thread| thread.name = "#{name} Worker ##{i}" if thread.respond_to?(:name=) end diff --git a/spec/bundler/bundler_spec.rb b/spec/bundler/bundler_spec.rb index 923217da15..9d4353f718 100644 --- a/spec/bundler/bundler_spec.rb +++ b/spec/bundler/bundler_spec.rb @@ -1,4 +1,5 @@ # encoding: utf-8 +# frozen_string_literal: true require "spec_helper" require "bundler" diff --git a/spec/bundler/cli_spec.rb b/spec/bundler/cli_spec.rb index a2f87e45fa..b48af7c81a 100644 --- a/spec/bundler/cli_spec.rb +++ b/spec/bundler/cli_spec.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "spec_helper" require "bundler/cli" diff --git a/spec/bundler/definition_spec.rb b/spec/bundler/definition_spec.rb index 8dc4bd28f0..443a2c9703 100644 --- a/spec/bundler/definition_spec.rb +++ b/spec/bundler/definition_spec.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "spec_helper" require "bundler/definition" diff --git a/spec/bundler/dsl_spec.rb b/spec/bundler/dsl_spec.rb index 9553c8fd43..77d663d754 100644 --- a/spec/bundler/dsl_spec.rb +++ b/spec/bundler/dsl_spec.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "spec_helper" describe Bundler::Dsl do diff --git a/spec/bundler/endpoint_specification_spec.rb b/spec/bundler/endpoint_specification_spec.rb index 0340c36261..fccf1842fc 100644 --- a/spec/bundler/endpoint_specification_spec.rb +++ b/spec/bundler/endpoint_specification_spec.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "spec_helper" describe Bundler::EndpointSpecification do diff --git a/spec/bundler/env_spec.rb b/spec/bundler/env_spec.rb index 1c38ca87df..305fcce351 100644 --- a/spec/bundler/env_spec.rb +++ b/spec/bundler/env_spec.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "spec_helper" require "bundler/settings" diff --git a/spec/bundler/fetcher/base_spec.rb b/spec/bundler/fetcher/base_spec.rb index 4ca47e4723..5a8c7647b9 100644 --- a/spec/bundler/fetcher/base_spec.rb +++ b/spec/bundler/fetcher/base_spec.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "spec_helper" describe Bundler::Fetcher::Base do diff --git a/spec/bundler/fetcher/dependency_spec.rb b/spec/bundler/fetcher/dependency_spec.rb index b78d82b98b..fd0d5ed9d3 100644 --- a/spec/bundler/fetcher/dependency_spec.rb +++ b/spec/bundler/fetcher/dependency_spec.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "spec_helper" describe Bundler::Fetcher::Dependency do @@ -92,7 +93,7 @@ describe Bundler::Fetcher::Dependency do it "should return a hash with the remote_uri and the list of specs" do expect(subject.specs(gem_names, full_dependency_list, last_spec_list)).to eq([ ["top", gem_version2, "ruby", faraday], - ["boulder", gem_version1, "ruby", resque] + ["boulder", gem_version1, "ruby", resque], ]) end end @@ -225,20 +226,20 @@ describe Bundler::Fetcher::Dependency do [ { :dependencies => { - "resque" => "req3,req4" + "resque" => "req3,req4", }, :name => "typhoeus", :number => "1.0.1", - :platform => "ruby" + :platform => "ruby", }, { :dependencies => { - "faraday" => "req1,req2" + "faraday" => "req1,req2", }, :name => "grape", :number => "2.0.2", - :platform => "jruby" - } + :platform => "jruby", + }, ] end diff --git a/spec/bundler/fetcher/downloader_spec.rb b/spec/bundler/fetcher/downloader_spec.rb index eade22f441..ebfaf90534 100644 --- a/spec/bundler/fetcher/downloader_spec.rb +++ b/spec/bundler/fetcher/downloader_spec.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "spec_helper" describe Bundler::Fetcher::Downloader do diff --git a/spec/bundler/fetcher/index_spec.rb b/spec/bundler/fetcher/index_spec.rb index 52acd9cebf..e22dc143ae 100644 --- a/spec/bundler/fetcher/index_spec.rb +++ b/spec/bundler/fetcher/index_spec.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "spec_helper" describe Bundler::Fetcher::Index do diff --git a/spec/bundler/fetcher_spec.rb b/spec/bundler/fetcher_spec.rb index f1204e7b47..5ebffc42ff 100644 --- a/spec/bundler/fetcher_spec.rb +++ b/spec/bundler/fetcher_spec.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "spec_helper" require "bundler/fetcher" diff --git a/spec/bundler/friendly_errors_spec.rb b/spec/bundler/friendly_errors_spec.rb index e178170967..ae197a4bab 100644 --- a/spec/bundler/friendly_errors_spec.rb +++ b/spec/bundler/friendly_errors_spec.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "spec_helper" require "bundler" require "bundler/friendly_errors" diff --git a/spec/bundler/gem_helper_spec.rb b/spec/bundler/gem_helper_spec.rb index 7c07a9d215..def926e364 100644 --- a/spec/bundler/gem_helper_spec.rb +++ b/spec/bundler/gem_helper_spec.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "spec_helper" require "rake" require "bundler/gem_helper" diff --git a/spec/bundler/mirror_spec.rb b/spec/bundler/mirror_spec.rb index 88436fd029..bd6d9bc636 100644 --- a/spec/bundler/mirror_spec.rb +++ b/spec/bundler/mirror_spec.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "spec_helper" require "bundler/mirror" diff --git a/spec/bundler/psyched_yaml_spec.rb b/spec/bundler/psyched_yaml_spec.rb index 2cc7dff842..4b7715b482 100644 --- a/spec/bundler/psyched_yaml_spec.rb +++ b/spec/bundler/psyched_yaml_spec.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "spec_helper" require "bundler/psyched_yaml" diff --git a/spec/bundler/remote_specification_spec.rb b/spec/bundler/remote_specification_spec.rb index 1ff986b9a1..527f48facc 100644 --- a/spec/bundler/remote_specification_spec.rb +++ b/spec/bundler/remote_specification_spec.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "spec_helper" describe Bundler::RemoteSpecification do diff --git a/spec/bundler/retry_spec.rb b/spec/bundler/retry_spec.rb index 280ab07d08..cafa099b51 100644 --- a/spec/bundler/retry_spec.rb +++ b/spec/bundler/retry_spec.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "spec_helper" describe Bundler::Retry do diff --git a/spec/bundler/ruby_version_spec.rb b/spec/bundler/ruby_version_spec.rb index d7ab0105fd..9c9eda04dc 100644 --- a/spec/bundler/ruby_version_spec.rb +++ b/spec/bundler/ruby_version_spec.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "spec_helper" require "bundler/ruby_version" diff --git a/spec/bundler/rubygems_integration_spec.rb b/spec/bundler/rubygems_integration_spec.rb index 84ce709913..917d673b51 100644 --- a/spec/bundler/rubygems_integration_spec.rb +++ b/spec/bundler/rubygems_integration_spec.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "spec_helper" describe Bundler::RubygemsIntegration do diff --git a/spec/bundler/settings_spec.rb b/spec/bundler/settings_spec.rb index 24c71744e1..239f5e6ade 100644 --- a/spec/bundler/settings_spec.rb +++ b/spec/bundler/settings_spec.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "spec_helper" require "bundler/settings" diff --git a/spec/bundler/shared_helpers_spec.rb b/spec/bundler/shared_helpers_spec.rb index a72fc34a74..d72a7f49c9 100644 --- a/spec/bundler/shared_helpers_spec.rb +++ b/spec/bundler/shared_helpers_spec.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "spec_helper" require "bundler/shared_helpers" @@ -187,14 +188,14 @@ describe Bundler::SharedHelpers do end it "ensures bundle bin path is in ENV['PATH']" do subject.set_bundle_environment - paths = (ENV["PATH"]).split(File::PATH_SEPARATOR) - expect(paths.include? "#{Bundler.bundle_path}/bin").to eq(true) + paths = ENV["PATH"].split(File::PATH_SEPARATOR) + expect(paths).to include("#{Bundler.bundle_path}/bin") end end shared_examples_for "ENV['RUBYOPT'] gets set correctly" do it "ensures -rbundler/setup is at the beginning of ENV['RUBYOPT']" do subject.set_bundle_environment - expect(ENV["RUBYOPT"].split(" ").first.include? "-rbundler/setup").to eq(true) + expect(ENV["RUBYOPT"].split(" ").first).to include("-rbundler/setup") end end shared_examples_for "ENV['RUBYLIB'] gets set correctly" do diff --git a/spec/bundler/source/git/git_proxy_spec.rb b/spec/bundler/source/git/git_proxy_spec.rb index 7e2083d595..10741b89a7 100644 --- a/spec/bundler/source/git/git_proxy_spec.rb +++ b/spec/bundler/source/git/git_proxy_spec.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "spec_helper" describe Bundler::Source::Git::GitProxy do diff --git a/spec/bundler/source/rubygems/remote_spec.rb b/spec/bundler/source/rubygems/remote_spec.rb index 599887d47a..a541bf1468 100644 --- a/spec/bundler/source/rubygems/remote_spec.rb +++ b/spec/bundler/source/rubygems/remote_spec.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "spec_helper" require "bundler/source/rubygems/remote" diff --git a/spec/bundler/source/rubygems_spec.rb b/spec/bundler/source/rubygems_spec.rb index 33cb3672dc..9fb4bf0ad3 100644 --- a/spec/bundler/source/rubygems_spec.rb +++ b/spec/bundler/source/rubygems_spec.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "spec_helper" describe Bundler::Source::Rubygems do diff --git a/spec/bundler/source_list_spec.rb b/spec/bundler/source_list_spec.rb index 3beac46f41..d7567d6e11 100644 --- a/spec/bundler/source_list_spec.rb +++ b/spec/bundler/source_list_spec.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "spec_helper" describe Bundler::SourceList do diff --git a/spec/bundler/source_spec.rb b/spec/bundler/source_spec.rb index 5e1fb0ad9d..1b4e4bdde9 100644 --- a/spec/bundler/source_spec.rb +++ b/spec/bundler/source_spec.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "spec_helper" describe Bundler::Source do @@ -85,7 +86,7 @@ describe Bundler::Source do let(:spec) { double(:spec, :source => subject) } it "should return true" do - expect(subject.can_lock? spec).to be_truthy + expect(subject.can_lock?(spec)).to be_truthy end end @@ -93,7 +94,7 @@ describe Bundler::Source do let(:spec) { double(:spec, :source => double(:other_source)) } it "should return false" do - expect(subject.can_lock? spec).to be_falsey + expect(subject.can_lock?(spec)).to be_falsey end end end diff --git a/spec/bundler/ssl_certs/certificate_manager_spec.rb b/spec/bundler/ssl_certs/certificate_manager_spec.rb index 57c071dafc..5a1650b432 100644 --- a/spec/bundler/ssl_certs/certificate_manager_spec.rb +++ b/spec/bundler/ssl_certs/certificate_manager_spec.rb @@ -1,10 +1,11 @@ +# frozen_string_literal: true require "spec_helper" require "bundler/ssl_certs/certificate_manager" describe Bundler::SSLCerts::CertificateManager do let(:rubygems_path) { root } - let(:stub_cert) { File.join("#{root}", "lib", "rubygems", "ssl_certs", "ssl-cert.pem") } - let(:rubygems_certs_dir) { File.join("#{root}", "lib", "rubygems", "ssl_certs") } + let(:stub_cert) { File.join(root.to_s, "lib", "rubygems", "ssl_certs", "ssl-cert.pem") } + let(:rubygems_certs_dir) { File.join(root.to_s, "lib", "rubygems", "ssl_certs") } subject { described_class.new(rubygems_path) } @@ -15,7 +16,7 @@ describe Bundler::SSLCerts::CertificateManager do end after do - rubygems_dir = File.join("#{root}", "lib", "rubygems") + rubygems_dir = File.join(root.to_s, "lib", "rubygems") FileUtils.rm_rf(rubygems_dir) end @@ -50,7 +51,7 @@ describe Bundler::SSLCerts::CertificateManager do describe "#up_to_date?" do context "when bundler certs and rubygems certs are the same" do before do - bundler_certs = Dir[File.join("#{root}", "lib", "bundler", "ssl_certs", "*.pem")] + bundler_certs = Dir[File.join(root.to_s, "lib", "bundler", "ssl_certs", "*.pem")] FileUtils.rm(stub_cert) FileUtils.cp(bundler_certs, rubygems_certs_dir) end diff --git a/spec/cache/cache_path_spec.rb b/spec/cache/cache_path_spec.rb index c0e73ca588..594162886a 100644 --- a/spec/cache/cache_path_spec.rb +++ b/spec/cache/cache_path_spec.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "spec_helper" describe "bundle package" do diff --git a/spec/cache/gems_spec.rb b/spec/cache/gems_spec.rb index 9ee5efb32f..a1bb8751dd 100644 --- a/spec/cache/gems_spec.rb +++ b/spec/cache/gems_spec.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "spec_helper" describe "bundle cache" do diff --git a/spec/cache/git_spec.rb b/spec/cache/git_spec.rb index 001cbb4564..f94b1b3469 100644 --- a/spec/cache/git_spec.rb +++ b/spec/cache/git_spec.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "spec_helper" describe "git base name" do diff --git a/spec/cache/path_spec.rb b/spec/cache/path_spec.rb index 82dfce94ba..b81768102a 100644 --- a/spec/cache/path_spec.rb +++ b/spec/cache/path_spec.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "spec_helper" %w(cache package).each do |cmd| diff --git a/spec/cache/platform_spec.rb b/spec/cache/platform_spec.rb index 6b73f90f05..e3702aaaf6 100644 --- a/spec/cache/platform_spec.rb +++ b/spec/cache/platform_spec.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "spec_helper" describe "bundle cache with multiple platforms" do diff --git a/spec/commands/binstubs_spec.rb b/spec/commands/binstubs_spec.rb index df5588fcf1..ee319e016c 100644 --- a/spec/commands/binstubs_spec.rb +++ b/spec/commands/binstubs_spec.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "spec_helper" describe "bundle binstubs <gem>" do diff --git a/spec/commands/check_spec.rb b/spec/commands/check_spec.rb index 02e81156ab..9f2053e15b 100644 --- a/spec/commands/check_spec.rb +++ b/spec/commands/check_spec.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "spec_helper" describe "bundle check" do @@ -305,7 +306,7 @@ describe "bundle check" do L if bundler_version - lock << "\n BUNDLED WITH\n #{bundler_version}\n" + lock += "\n BUNDLED WITH\n #{bundler_version}\n" end lock diff --git a/spec/commands/clean_spec.rb b/spec/commands/clean_spec.rb index 9d4c96fc0f..95035555d4 100644 --- a/spec/commands/clean_spec.rb +++ b/spec/commands/clean_spec.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "spec_helper" describe "bundle clean" do diff --git a/spec/commands/config_spec.rb b/spec/commands/config_spec.rb index 33134bef0c..2c31e48940 100644 --- a/spec/commands/config_spec.rb +++ b/spec/commands/config_spec.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "spec_helper" describe ".bundle/config" do @@ -50,8 +51,8 @@ describe ".bundle/config" do end it "can also be set explicitly" do - bundle "config --global foo global" - run "puts Bundler.settings[:foo]" + bundle! "config --global foo global" + run! "puts Bundler.settings[:foo]" expect(out).to eq("global") end diff --git a/spec/commands/console_spec.rb b/spec/commands/console_spec.rb index 4b1de42e8a..b771c6a940 100644 --- a/spec/commands/console_spec.rb +++ b/spec/commands/console_spec.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "spec_helper" describe "bundle console" do diff --git a/spec/commands/exec_spec.rb b/spec/commands/exec_spec.rb index 05c1109ee7..ee766cdb5f 100644 --- a/spec/commands/exec_spec.rb +++ b/spec/commands/exec_spec.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "spec_helper" describe "bundle exec" do diff --git a/spec/commands/help_spec.rb b/spec/commands/help_spec.rb index 53c0c0b9a6..704b99a0e8 100644 --- a/spec/commands/help_spec.rb +++ b/spec/commands/help_spec.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "spec_helper" describe "bundle help" do diff --git a/spec/commands/init_spec.rb b/spec/commands/init_spec.rb index ef405d121d..70d1143055 100644 --- a/spec/commands/init_spec.rb +++ b/spec/commands/init_spec.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "spec_helper" describe "bundle init" do diff --git a/spec/commands/inject_spec.rb b/spec/commands/inject_spec.rb index 4aed64d633..d0112915ca 100644 --- a/spec/commands/inject_spec.rb +++ b/spec/commands/inject_spec.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "spec_helper" describe "bundle inject" do diff --git a/spec/commands/install_spec.rb b/spec/commands/install_spec.rb index fcd8b98dfb..9c81457068 100644 --- a/spec/commands/install_spec.rb +++ b/spec/commands/install_spec.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "spec_helper" describe "bundle install with gem sources" do diff --git a/spec/commands/licenses_spec.rb b/spec/commands/licenses_spec.rb index 9be0d57838..dd9f261eb3 100644 --- a/spec/commands/licenses_spec.rb +++ b/spec/commands/licenses_spec.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "spec_helper" describe "bundle licenses" do diff --git a/spec/commands/lock_spec.rb b/spec/commands/lock_spec.rb index f1379cc8ca..7f32409ea6 100644 --- a/spec/commands/lock_spec.rb +++ b/spec/commands/lock_spec.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "spec_helper" describe "bundle lock" do diff --git a/spec/commands/newgem_spec.rb b/spec/commands/newgem_spec.rb index 732097dacc..c48a1eb4a1 100644 --- a/spec/commands/newgem_spec.rb +++ b/spec/commands/newgem_spec.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "spec_helper" describe "bundle gem" do diff --git a/spec/commands/open_spec.rb b/spec/commands/open_spec.rb index f443cfe9d3..6fa219f889 100644 --- a/spec/commands/open_spec.rb +++ b/spec/commands/open_spec.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "spec_helper" describe "bundle open" do diff --git a/spec/commands/outdated_spec.rb b/spec/commands/outdated_spec.rb index c0b70c1f11..5db12f0269 100644 --- a/spec/commands/outdated_spec.rb +++ b/spec/commands/outdated_spec.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "spec_helper" describe "bundle outdated" do diff --git a/spec/commands/package_spec.rb b/spec/commands/package_spec.rb index f9be542f60..5194ab8051 100644 --- a/spec/commands/package_spec.rb +++ b/spec/commands/package_spec.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "spec_helper" describe "bundle package" do diff --git a/spec/commands/show_spec.rb b/spec/commands/show_spec.rb index 9da787c831..7cfa02d418 100644 --- a/spec/commands/show_spec.rb +++ b/spec/commands/show_spec.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "spec_helper" describe "bundle show" do diff --git a/spec/commands/update_spec.rb b/spec/commands/update_spec.rb index 4eadd956f1..31d5a21975 100644 --- a/spec/commands/update_spec.rb +++ b/spec/commands/update_spec.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "spec_helper" describe "bundle update" do diff --git a/spec/commands/viz_spec.rb b/spec/commands/viz_spec.rb index 2052fd273f..c680568899 100644 --- a/spec/commands/viz_spec.rb +++ b/spec/commands/viz_spec.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "spec_helper" describe "bundle viz", :ruby => "1.9.3", :if => Bundler.which("dot") do diff --git a/spec/install/binstubs_spec.rb b/spec/install/binstubs_spec.rb index 1b34e62567..78865c7f4a 100644 --- a/spec/install/binstubs_spec.rb +++ b/spec/install/binstubs_spec.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "spec_helper" describe "bundle install" do diff --git a/spec/install/bundler_spec.rb b/spec/install/bundler_spec.rb index a5278ef2f8..560272e5cf 100644 --- a/spec/install/bundler_spec.rb +++ b/spec/install/bundler_spec.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "spec_helper" describe "bundle install" do diff --git a/spec/install/deploy_spec.rb b/spec/install/deploy_spec.rb index 88832f2145..a9a072687c 100644 --- a/spec/install/deploy_spec.rb +++ b/spec/install/deploy_spec.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "spec_helper" describe "install with --deployment or --frozen" do diff --git a/spec/install/force_spec.rb b/spec/install/force_spec.rb index 2135c4d7b0..9209392d58 100644 --- a/spec/install/force_spec.rb +++ b/spec/install/force_spec.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "spec_helper" describe "bundle install" do diff --git a/spec/install/gemfile/gemspec_spec.rb b/spec/install/gemfile/gemspec_spec.rb index 7b38dfb961..36c7353045 100644 --- a/spec/install/gemfile/gemspec_spec.rb +++ b/spec/install/gemfile/gemspec_spec.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "spec_helper" describe "bundle install from an existing gemspec" do diff --git a/spec/install/gemfile/git_spec.rb b/spec/install/gemfile/git_spec.rb index c01bf4019a..ecd6462540 100644 --- a/spec/install/gemfile/git_spec.rb +++ b/spec/install/gemfile/git_spec.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "spec_helper" describe "bundle install with git sources" do diff --git a/spec/install/gemfile/groups_spec.rb b/spec/install/gemfile/groups_spec.rb index d64e03186d..2f3f446834 100644 --- a/spec/install/gemfile/groups_spec.rb +++ b/spec/install/gemfile/groups_spec.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "spec_helper" describe "bundle install with groups" do diff --git a/spec/install/gemfile/install_if.rb b/spec/install/gemfile/install_if.rb index 32b04d1cc4..080a35b989 100644 --- a/spec/install/gemfile/install_if.rb +++ b/spec/install/gemfile/install_if.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "spec_helper" describe "bundle install with install_if conditionals" do diff --git a/spec/install/gemfile/path_spec.rb b/spec/install/gemfile/path_spec.rb index ee45bf3efd..64919370be 100644 --- a/spec/install/gemfile/path_spec.rb +++ b/spec/install/gemfile/path_spec.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "spec_helper" describe "bundle install with explicit source paths" do diff --git a/spec/install/gemfile/platform_spec.rb b/spec/install/gemfile/platform_spec.rb index ee7501f759..a562a3bc11 100644 --- a/spec/install/gemfile/platform_spec.rb +++ b/spec/install/gemfile/platform_spec.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "spec_helper" describe "bundle install across platforms" do diff --git a/spec/install/gemfile/ruby_spec.rb b/spec/install/gemfile/ruby_spec.rb index 9b35e3819c..d3536289eb 100644 --- a/spec/install/gemfile/ruby_spec.rb +++ b/spec/install/gemfile/ruby_spec.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "spec_helper" describe "ruby requirement" do diff --git a/spec/install/gemfile/sources_spec.rb b/spec/install/gemfile/sources_spec.rb index 9ebb2c1ed8..e216340fa5 100644 --- a/spec/install/gemfile/sources_spec.rb +++ b/spec/install/gemfile/sources_spec.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "spec_helper" describe "bundle install with gems on multiple sources" do diff --git a/spec/install/gemfile_spec.rb b/spec/install/gemfile_spec.rb index b1b8a1ac24..a0a1cb9a65 100644 --- a/spec/install/gemfile_spec.rb +++ b/spec/install/gemfile_spec.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "spec_helper" describe "bundle install" do diff --git a/spec/install/gems/compact_index_spec.rb b/spec/install/gems/compact_index_spec.rb index 1069027a9d..13645f0ae6 100644 --- a/spec/install/gems/compact_index_spec.rb +++ b/spec/install/gems/compact_index_spec.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "spec_helper" describe "compact index api" do diff --git a/spec/install/gems/dependency_api_spec.rb b/spec/install/gems/dependency_api_spec.rb index 55eba01481..70190dd01b 100644 --- a/spec/install/gems/dependency_api_spec.rb +++ b/spec/install/gems/dependency_api_spec.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "spec_helper" describe "gemcutter's dependency API" do diff --git a/spec/install/gems/env_spec.rb b/spec/install/gems/env_spec.rb index ac3d19730a..072e698d8a 100644 --- a/spec/install/gems/env_spec.rb +++ b/spec/install/gems/env_spec.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "spec_helper" describe "bundle install with ENV conditionals" do diff --git a/spec/install/gems/flex_spec.rb b/spec/install/gems/flex_spec.rb index fe725a5cc8..452cadf35e 100644 --- a/spec/install/gems/flex_spec.rb +++ b/spec/install/gems/flex_spec.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "spec_helper" describe "bundle flex_install" do diff --git a/spec/install/gems/mirror_spec.rb b/spec/install/gems/mirror_spec.rb index 48b97de7bd..8540778d5c 100644 --- a/spec/install/gems/mirror_spec.rb +++ b/spec/install/gems/mirror_spec.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "spec_helper" describe "bundle install with a mirror configured" do diff --git a/spec/install/gems/native_extensions_spec.rb b/spec/install/gems/native_extensions_spec.rb index 8d14acf5f3..6134663fcc 100644 --- a/spec/install/gems/native_extensions_spec.rb +++ b/spec/install/gems/native_extensions_spec.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "spec_helper" describe "installing a gem with native extensions" do diff --git a/spec/install/gems/post_install_spec.rb b/spec/install/gems/post_install_spec.rb index bea2c9b6ee..596fa6412f 100644 --- a/spec/install/gems/post_install_spec.rb +++ b/spec/install/gems/post_install_spec.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "spec_helper" describe "bundle install" do diff --git a/spec/install/gems/resolving_spec.rb b/spec/install/gems/resolving_spec.rb index 5377db233e..49d160063d 100644 --- a/spec/install/gems/resolving_spec.rb +++ b/spec/install/gems/resolving_spec.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "spec_helper" describe "bundle install with gem sources" do diff --git a/spec/install/gems/standalone_spec.rb b/spec/install/gems/standalone_spec.rb index ad1f3eda70..4ce5d92eb0 100644 --- a/spec/install/gems/standalone_spec.rb +++ b/spec/install/gems/standalone_spec.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "spec_helper" describe "bundle install --standalone" do diff --git a/spec/install/gems/sudo_spec.rb b/spec/install/gems/sudo_spec.rb index eaee6d74b2..e102d2da96 100644 --- a/spec/install/gems/sudo_spec.rb +++ b/spec/install/gems/sudo_spec.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "spec_helper" describe "when using sudo", :sudo => true do diff --git a/spec/install/gems/win32_spec.rb b/spec/install/gems/win32_spec.rb index e75177a0ce..69ea035f5e 100644 --- a/spec/install/gems/win32_spec.rb +++ b/spec/install/gems/win32_spec.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "spec_helper" describe "bundle install with win32-generated lockfile" do diff --git a/spec/install/gemspecs_spec.rb b/spec/install/gemspecs_spec.rb index 4300a16cb2..4e2a18679a 100644 --- a/spec/install/gemspecs_spec.rb +++ b/spec/install/gemspecs_spec.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "spec_helper" describe "bundle install" do diff --git a/spec/install/git_spec.rb b/spec/install/git_spec.rb index 7067ec4466..f3a1983740 100644 --- a/spec/install/git_spec.rb +++ b/spec/install/git_spec.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "spec_helper" describe "bundle install" do diff --git a/spec/install/parallel/spec_installation_spec.rb b/spec/install/parallel/spec_installation_spec.rb index 6e92bb4cb8..9a8e1cad31 100644 --- a/spec/install/parallel/spec_installation_spec.rb +++ b/spec/install/parallel/spec_installation_spec.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "spec_helper" require "bundler/installer/parallel_installer" diff --git a/spec/install/path_spec.rb b/spec/install/path_spec.rb index ffc53365c3..cf15021727 100644 --- a/spec/install/path_spec.rb +++ b/spec/install/path_spec.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "spec_helper" describe "bundle install" do diff --git a/spec/install/post_bundle_message_spec.rb b/spec/install/post_bundle_message_spec.rb index 39076461db..11fb5bb0a2 100644 --- a/spec/install/post_bundle_message_spec.rb +++ b/spec/install/post_bundle_message_spec.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "spec_helper" describe "post bundle message" do diff --git a/spec/install/prereleases_spec.rb b/spec/install/prereleases_spec.rb index ddbdea3f56..61676f5dfa 100644 --- a/spec/install/prereleases_spec.rb +++ b/spec/install/prereleases_spec.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "spec_helper" describe "bundle install" do diff --git a/spec/install/security_policy_spec.rb b/spec/install/security_policy_spec.rb index 288154ad13..08a9213e00 100644 --- a/spec/install/security_policy_spec.rb +++ b/spec/install/security_policy_spec.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "spec_helper" require "rubygems/security" diff --git a/spec/install/upgrade_spec.rb b/spec/install/upgrade_spec.rb index a57f974bbb..852a746322 100644 --- a/spec/install/upgrade_spec.rb +++ b/spec/install/upgrade_spec.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "spec_helper" describe "bundle install for the first time with v1.0" do diff --git a/spec/lock/git_spec.rb b/spec/lock/git_spec.rb index 8507ae20c0..69937aaba5 100644 --- a/spec/lock/git_spec.rb +++ b/spec/lock/git_spec.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "spec_helper" describe "bundle lock with git gems" do diff --git a/spec/lock/lockfile_spec.rb b/spec/lock/lockfile_spec.rb index a81eb8a606..6e0713102a 100644 --- a/spec/lock/lockfile_spec.rb +++ b/spec/lock/lockfile_spec.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "spec_helper" describe "the lockfile format" do diff --git a/spec/other/bundle_ruby_spec.rb b/spec/other/bundle_ruby_spec.rb index 37db2490b2..88cd8a7e03 100644 --- a/spec/other/bundle_ruby_spec.rb +++ b/spec/other/bundle_ruby_spec.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "spec_helper" describe "bundle_ruby" do diff --git a/spec/other/cli_dispatch_spec.rb b/spec/other/cli_dispatch_spec.rb index 0dd49c7a40..7aee482bfe 100644 --- a/spec/other/cli_dispatch_spec.rb +++ b/spec/other/cli_dispatch_spec.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "spec_helper" describe "bundle command names" do diff --git a/spec/other/ext_spec.rb b/spec/other/ext_spec.rb index b5b6956106..5508ef8b74 100644 --- a/spec/other/ext_spec.rb +++ b/spec/other/ext_spec.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "spec_helper" describe "Gem::Specification#match_platform" do diff --git a/spec/other/platform_spec.rb b/spec/other/platform_spec.rb index f36cf527ec..7942e604a5 100644 --- a/spec/other/platform_spec.rb +++ b/spec/other/platform_spec.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "spec_helper" describe "bundle platform" do diff --git a/spec/other/ssl_cert_spec.rb b/spec/other/ssl_cert_spec.rb index 1cd22cbb8c..b1b27ebb89 100644 --- a/spec/other/ssl_cert_spec.rb +++ b/spec/other/ssl_cert_spec.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "spec_helper" require "bundler/ssl_certs/certificate_manager" diff --git a/spec/quality_spec.rb b/spec/quality_spec.rb index bbe78a4079..c68bfa1533 100644 --- a/spec/quality_spec.rb +++ b/spec/quality_spec.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "spec_helper" if defined?(Encoding) && Encoding.default_external.name != "UTF-8" @@ -13,9 +14,8 @@ describe "The library itself" do failing_lines << number + 1 if line =~ /^ *(describe|it|context) {1}'{1}/ end - unless failing_lines.empty? - "#{filename} uses inconsistent single quotes on lines #{failing_lines.join(", ")}" - end + return if failing_lines.empty? + "#{filename} uses inconsistent single quotes on lines #{failing_lines.join(", ")}" end def check_for_tab_characters(filename) @@ -24,9 +24,8 @@ describe "The library itself" do failing_lines << number + 1 if line =~ /\t/ end - unless failing_lines.empty? - "#{filename} has tab characters on lines #{failing_lines.join(", ")}" - end + return if failing_lines.empty? + "#{filename} has tab characters on lines #{failing_lines.join(", ")}" end def check_for_extra_spaces(filename) @@ -37,9 +36,8 @@ describe "The library itself" do failing_lines << number + 1 if line =~ /\s+\n$/ end - unless failing_lines.empty? - "#{filename} has spaces on the EOL on lines #{failing_lines.join(", ")}" - end + return if failing_lines.empty? + "#{filename} has spaces on the EOL on lines #{failing_lines.join(", ")}" end RSpec::Matchers.define :be_well_formed do diff --git a/spec/realworld/dependency_api_spec.rb b/spec/realworld/dependency_api_spec.rb index bab5986ea2..c77036fc5f 100644 --- a/spec/realworld/dependency_api_spec.rb +++ b/spec/realworld/dependency_api_spec.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "spec_helper" describe "gemcutter's dependency API", :realworld => true do diff --git a/spec/realworld/edgecases_spec.rb b/spec/realworld/edgecases_spec.rb index fd82c506cf..8295669d19 100644 --- a/spec/realworld/edgecases_spec.rb +++ b/spec/realworld/edgecases_spec.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "spec_helper" describe "real world edgecases", :realworld => true, :sometimes => true do diff --git a/spec/realworld/gemfile_source_header_spec.rb b/spec/realworld/gemfile_source_header_spec.rb index 6c2c05eaa7..be8f45c81b 100644 --- a/spec/realworld/gemfile_source_header_spec.rb +++ b/spec/realworld/gemfile_source_header_spec.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "spec_helper" require "thread" diff --git a/spec/realworld/mirror_probe_spec.rb b/spec/realworld/mirror_probe_spec.rb index ce64981338..981c4b8442 100644 --- a/spec/realworld/mirror_probe_spec.rb +++ b/spec/realworld/mirror_probe_spec.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "spec_helper" require "thread" diff --git a/spec/realworld/parallel_spec.rb b/spec/realworld/parallel_spec.rb index 7154e26dc9..539b8ab287 100644 --- a/spec/realworld/parallel_spec.rb +++ b/spec/realworld/parallel_spec.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "spec_helper" describe "parallel", :realworld => true, :sometimes => true do diff --git a/spec/resolver/basic_spec.rb b/spec/resolver/basic_spec.rb index 0cfaf925da..cb5bc45597 100644 --- a/spec/resolver/basic_spec.rb +++ b/spec/resolver/basic_spec.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "spec_helper" describe "Resolving" do diff --git a/spec/resolver/platform_spec.rb b/spec/resolver/platform_spec.rb index 85a0042a26..d5f217684c 100644 --- a/spec/resolver/platform_spec.rb +++ b/spec/resolver/platform_spec.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "spec_helper" describe "Resolving platform craziness" do diff --git a/spec/runtime/executable_spec.rb b/spec/runtime/executable_spec.rb index a0abee27f5..1ce65bd598 100644 --- a/spec/runtime/executable_spec.rb +++ b/spec/runtime/executable_spec.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "spec_helper" describe "Running bin/* commands" do diff --git a/spec/runtime/gem_tasks_spec.rb b/spec/runtime/gem_tasks_spec.rb index 1cbc35f7bb..c187efd681 100644 --- a/spec/runtime/gem_tasks_spec.rb +++ b/spec/runtime/gem_tasks_spec.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "spec_helper" describe "require 'bundler/gem_tasks'" do diff --git a/spec/runtime/inline_spec.rb b/spec/runtime/inline_spec.rb index a5142d34ed..7d74e8cd14 100644 --- a/spec/runtime/inline_spec.rb +++ b/spec/runtime/inline_spec.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "spec_helper" describe "bundler/inline#gemfile" do @@ -5,7 +6,7 @@ describe "bundler/inline#gemfile" do requires = ["bundler/inline"] requires.unshift File.expand_path("../../support/artifice/" + options.delete(:artifice) + ".rb", __FILE__) if options.key?(:artifice) requires = requires.map {|r| "require '#{r}'" }.join("\n") - @out = ruby("#{requires}\n\n" << code, options) + @out = ruby("#{requires}\n\n" + code, options) end before :each do diff --git a/spec/runtime/load_spec.rb b/spec/runtime/load_spec.rb index b7c856ac3a..c010f8f8e9 100644 --- a/spec/runtime/load_spec.rb +++ b/spec/runtime/load_spec.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "spec_helper" describe "Bundler.load" do diff --git a/spec/runtime/platform_spec.rb b/spec/runtime/platform_spec.rb index cbc12ef495..db99f3556b 100644 --- a/spec/runtime/platform_spec.rb +++ b/spec/runtime/platform_spec.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "spec_helper" describe "Bundler.setup with multi platform stuff" do diff --git a/spec/runtime/require_spec.rb b/spec/runtime/require_spec.rb index e227514838..fbfa398239 100644 --- a/spec/runtime/require_spec.rb +++ b/spec/runtime/require_spec.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "spec_helper" describe "Bundler.require" do diff --git a/spec/runtime/setup_spec.rb b/spec/runtime/setup_spec.rb index 37c1a2d9a2..be3d1baf2b 100644 --- a/spec/runtime/setup_spec.rb +++ b/spec/runtime/setup_spec.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "spec_helper" describe "Bundler.setup" do @@ -915,7 +916,7 @@ describe "Bundler.setup" do L if bundler_version - lock << "\n BUNDLED WITH\n #{bundler_version}\n" + lock += "\n BUNDLED WITH\n #{bundler_version}\n" end lock diff --git a/spec/runtime/with_clean_env_spec.rb b/spec/runtime/with_clean_env_spec.rb index 55c6ed98ed..92607efc76 100644 --- a/spec/runtime/with_clean_env_spec.rb +++ b/spec/runtime/with_clean_env_spec.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "spec_helper" describe "Bundler.with_env helpers" do diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index cd2dc39469..bea836aae6 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true $:.unshift File.expand_path("..", __FILE__) $:.unshift File.expand_path("../../lib", __FILE__) diff --git a/spec/support/artifice/compact_index.rb b/spec/support/artifice/compact_index.rb index e7dfda3bea..88706c3590 100644 --- a/spec/support/artifice/compact_index.rb +++ b/spec/support/artifice/compact_index.rb @@ -1,6 +1,7 @@ +# frozen_string_literal: true require File.expand_path("../endpoint", __FILE__) -$LOAD_PATH.unshift "#{Dir[base_system_gems.join("gems/compact_index*/lib")].first}" +$LOAD_PATH.unshift Dir[base_system_gems.join("gems/compact_index*/lib")].first.to_s require "compact_index" class CompactIndexAPI < Endpoint @@ -28,11 +29,10 @@ class CompactIndexAPI < Endpoint def not_modified?(checksum) etags = parse_etags(request.env["HTTP_IF_NONE_MATCH"]) - if etags.include?(checksum) - headers "ETag" => quote(checksum) - status 304 - body "" - end + return unless etags.include?(checksum) + headers "ETag" => quote(checksum) + status 304 + body "" end def requested_range_for(response_body) @@ -48,7 +48,7 @@ class CompactIndexAPI < Endpoint end def quote(string) - '"' << string << '"' + %("#{string}") end def parse_etags(value) diff --git a/spec/support/artifice/compact_index_api_missing.rb b/spec/support/artifice/compact_index_api_missing.rb index db6528b878..6d15b54b85 100644 --- a/spec/support/artifice/compact_index_api_missing.rb +++ b/spec/support/artifice/compact_index_api_missing.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require File.expand_path("../compact_index", __FILE__) Artifice.deactivate diff --git a/spec/support/artifice/compact_index_basic_authentication.rb b/spec/support/artifice/compact_index_basic_authentication.rb index 5ddcdf7fa7..bffb5b9e2b 100644 --- a/spec/support/artifice/compact_index_basic_authentication.rb +++ b/spec/support/artifice/compact_index_basic_authentication.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require File.expand_path("../compact_index", __FILE__) Artifice.deactivate diff --git a/spec/support/artifice/compact_index_creds_diff_host.rb b/spec/support/artifice/compact_index_creds_diff_host.rb index 6a56c508a2..0c417f0580 100644 --- a/spec/support/artifice/compact_index_creds_diff_host.rb +++ b/spec/support/artifice/compact_index_creds_diff_host.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require File.expand_path("../compact_index", __FILE__) Artifice.deactivate @@ -13,10 +14,9 @@ class CompactIndexCredsDiffHost < CompactIndexAPI end def protected! - unless authorized? - response["WWW-Authenticate"] = %(Basic realm="Testing HTTP Auth") - throw(:halt, [401, "Not authorized\n"]) - end + return if authorized? + response["WWW-Authenticate"] = %(Basic realm="Testing HTTP Auth") + throw(:halt, [401, "Not authorized\n"]) end end diff --git a/spec/support/artifice/compact_index_extra.rb b/spec/support/artifice/compact_index_extra.rb index 3300b70610..8a87fc4343 100644 --- a/spec/support/artifice/compact_index_extra.rb +++ b/spec/support/artifice/compact_index_extra.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require File.expand_path("../compact_index", __FILE__) Artifice.deactivate diff --git a/spec/support/artifice/compact_index_extra_api.rb b/spec/support/artifice/compact_index_extra_api.rb index df4674396a..063e5589d4 100644 --- a/spec/support/artifice/compact_index_extra_api.rb +++ b/spec/support/artifice/compact_index_extra_api.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require File.expand_path("../compact_index", __FILE__) Artifice.deactivate diff --git a/spec/support/artifice/compact_index_extra_missing.rb b/spec/support/artifice/compact_index_extra_missing.rb index 48fffd51a8..2af5ce9c27 100644 --- a/spec/support/artifice/compact_index_extra_missing.rb +++ b/spec/support/artifice/compact_index_extra_missing.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require File.expand_path("../compact_index_extra", __FILE__) Artifice.deactivate diff --git a/spec/support/artifice/compact_index_forbidden.rb b/spec/support/artifice/compact_index_forbidden.rb index 09d03bc88d..b25eea94e7 100644 --- a/spec/support/artifice/compact_index_forbidden.rb +++ b/spec/support/artifice/compact_index_forbidden.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require File.expand_path("../compact_index", __FILE__) Artifice.deactivate diff --git a/spec/support/artifice/compact_index_host_redirect.rb b/spec/support/artifice/compact_index_host_redirect.rb index 2e53cc7814..6c1ab2def6 100644 --- a/spec/support/artifice/compact_index_host_redirect.rb +++ b/spec/support/artifice/compact_index_host_redirect.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require File.expand_path("../compact_index", __FILE__) Artifice.deactivate diff --git a/spec/support/artifice/compact_index_redirects.rb b/spec/support/artifice/compact_index_redirects.rb index 256e73d7f4..ff1d3e43bc 100644 --- a/spec/support/artifice/compact_index_redirects.rb +++ b/spec/support/artifice/compact_index_redirects.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require File.expand_path("../compact_index", __FILE__) Artifice.deactivate diff --git a/spec/support/artifice/compact_index_strict_basic_authentication.rb b/spec/support/artifice/compact_index_strict_basic_authentication.rb index bb1e794b4e..49a072d2b9 100644 --- a/spec/support/artifice/compact_index_strict_basic_authentication.rb +++ b/spec/support/artifice/compact_index_strict_basic_authentication.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require File.expand_path("../compact_index", __FILE__) Artifice.deactivate diff --git a/spec/support/artifice/endopint_marshal_fail_basic_authentication.rb b/spec/support/artifice/endopint_marshal_fail_basic_authentication.rb index 205b25885a..f1f8dc5700 100644 --- a/spec/support/artifice/endopint_marshal_fail_basic_authentication.rb +++ b/spec/support/artifice/endopint_marshal_fail_basic_authentication.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require File.expand_path("../endpoint_marshal_fail", __FILE__) Artifice.deactivate diff --git a/spec/support/artifice/endpoint.rb b/spec/support/artifice/endpoint.rb index 847f1d4b23..b0e9bd0f26 100644 --- a/spec/support/artifice/endpoint.rb +++ b/spec/support/artifice/endpoint.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require File.expand_path("../../path.rb", __FILE__) require File.expand_path("../../../../lib/bundler/deprecate", __FILE__) include Spec::Path diff --git a/spec/support/artifice/endpoint_500.rb b/spec/support/artifice/endpoint_500.rb index 2812a0d208..9bbbd1e2f2 100644 --- a/spec/support/artifice/endpoint_500.rb +++ b/spec/support/artifice/endpoint_500.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require File.expand_path("../../path.rb", __FILE__) include Spec::Path diff --git a/spec/support/artifice/endpoint_api_forbidden.rb b/spec/support/artifice/endpoint_api_forbidden.rb index f9d28c0470..21ad9117ed 100644 --- a/spec/support/artifice/endpoint_api_forbidden.rb +++ b/spec/support/artifice/endpoint_api_forbidden.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require File.expand_path("../endpoint", __FILE__) Artifice.deactivate diff --git a/spec/support/artifice/endpoint_api_missing.rb b/spec/support/artifice/endpoint_api_missing.rb index ca5916938f..6f5b5f1323 100644 --- a/spec/support/artifice/endpoint_api_missing.rb +++ b/spec/support/artifice/endpoint_api_missing.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require File.expand_path("../endpoint", __FILE__) Artifice.deactivate diff --git a/spec/support/artifice/endpoint_basic_authentication.rb b/spec/support/artifice/endpoint_basic_authentication.rb index 0cfba89184..9fafd51a3d 100644 --- a/spec/support/artifice/endpoint_basic_authentication.rb +++ b/spec/support/artifice/endpoint_basic_authentication.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require File.expand_path("../endpoint", __FILE__) Artifice.deactivate diff --git a/spec/support/artifice/endpoint_creds_diff_host.rb b/spec/support/artifice/endpoint_creds_diff_host.rb index 0c10242daf..cd152848fe 100644 --- a/spec/support/artifice/endpoint_creds_diff_host.rb +++ b/spec/support/artifice/endpoint_creds_diff_host.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require File.expand_path("../endpoint", __FILE__) Artifice.deactivate @@ -13,10 +14,9 @@ class EndpointCredsDiffHost < Endpoint end def protected! - unless authorized? - response["WWW-Authenticate"] = %(Basic realm="Testing HTTP Auth") - throw(:halt, [401, "Not authorized\n"]) - end + return if authorized? + response["WWW-Authenticate"] = %(Basic realm="Testing HTTP Auth") + throw(:halt, [401, "Not authorized\n"]) end end diff --git a/spec/support/artifice/endpoint_extra.rb b/spec/support/artifice/endpoint_extra.rb index c50428fe20..ed4e87e65f 100644 --- a/spec/support/artifice/endpoint_extra.rb +++ b/spec/support/artifice/endpoint_extra.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require File.expand_path("../endpoint", __FILE__) Artifice.deactivate diff --git a/spec/support/artifice/endpoint_extra_api.rb b/spec/support/artifice/endpoint_extra_api.rb index d6d1c5a1b4..1e9e1dc60d 100644 --- a/spec/support/artifice/endpoint_extra_api.rb +++ b/spec/support/artifice/endpoint_extra_api.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require File.expand_path("../endpoint", __FILE__) Artifice.deactivate diff --git a/spec/support/artifice/endpoint_extra_missing.rb b/spec/support/artifice/endpoint_extra_missing.rb index 89c4c0c776..dc79705a26 100644 --- a/spec/support/artifice/endpoint_extra_missing.rb +++ b/spec/support/artifice/endpoint_extra_missing.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require File.expand_path("../endpoint_extra", __FILE__) Artifice.deactivate diff --git a/spec/support/artifice/endpoint_fallback.rb b/spec/support/artifice/endpoint_fallback.rb index db02a88758..8a85a41784 100644 --- a/spec/support/artifice/endpoint_fallback.rb +++ b/spec/support/artifice/endpoint_fallback.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require File.expand_path("../endpoint", __FILE__) Artifice.deactivate diff --git a/spec/support/artifice/endpoint_host_redirect.rb b/spec/support/artifice/endpoint_host_redirect.rb index 00c496af58..250416d8cc 100644 --- a/spec/support/artifice/endpoint_host_redirect.rb +++ b/spec/support/artifice/endpoint_host_redirect.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require File.expand_path("../endpoint", __FILE__) Artifice.deactivate diff --git a/spec/support/artifice/endpoint_marshal_fail.rb b/spec/support/artifice/endpoint_marshal_fail.rb index a0dc182e27..0fb75ebf31 100644 --- a/spec/support/artifice/endpoint_marshal_fail.rb +++ b/spec/support/artifice/endpoint_marshal_fail.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require File.expand_path("../endpoint_fallback", __FILE__) Artifice.deactivate diff --git a/spec/support/artifice/endpoint_mirror_source.rb b/spec/support/artifice/endpoint_mirror_source.rb index 39cd3656fa..9fb58ecb29 100644 --- a/spec/support/artifice/endpoint_mirror_source.rb +++ b/spec/support/artifice/endpoint_mirror_source.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require File.expand_path("../endpoint", __FILE__) class EndpointMirrorSource < Endpoint diff --git a/spec/support/artifice/endpoint_redirect.rb b/spec/support/artifice/endpoint_redirect.rb index 2b48fa5344..f80d7600c2 100644 --- a/spec/support/artifice/endpoint_redirect.rb +++ b/spec/support/artifice/endpoint_redirect.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require File.expand_path("../endpoint", __FILE__) Artifice.deactivate diff --git a/spec/support/artifice/endpoint_strict_basic_authentication.rb b/spec/support/artifice/endpoint_strict_basic_authentication.rb index e7329abdc4..4b32cbbf5b 100644 --- a/spec/support/artifice/endpoint_strict_basic_authentication.rb +++ b/spec/support/artifice/endpoint_strict_basic_authentication.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require File.expand_path("../endpoint", __FILE__) Artifice.deactivate diff --git a/spec/support/artifice/endpoint_timeout.rb b/spec/support/artifice/endpoint_timeout.rb index da682204c4..b15650f226 100644 --- a/spec/support/artifice/endpoint_timeout.rb +++ b/spec/support/artifice/endpoint_timeout.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require File.expand_path("../endpoint_fallback", __FILE__) Artifice.deactivate diff --git a/spec/support/builders.rb b/spec/support/builders.rb index 4f5dace604..3a18cbea77 100644 --- a/spec/support/builders.rb +++ b/spec/support/builders.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "bundler/shared_helpers" module Spec @@ -624,7 +625,7 @@ module Spec current_ref = `git rev-parse HEAD`.strip _default_files.keys.each do |path| - _default_files[path] << "\n#{Builders.constantize(name)}_PREV_REF = '#{current_ref}'" + _default_files[path] += "\n#{Builders.constantize(name)}_PREV_REF = '#{current_ref}'" end super(options.merge(:path => libpath, :gemspec => false)) `git add *` diff --git a/spec/support/code_climate.rb b/spec/support/code_climate.rb index cfcd890a40..8f1fb35bcd 100644 --- a/spec/support/code_climate.rb +++ b/spec/support/code_climate.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true module Spec module CodeClimate def self.setup diff --git a/spec/support/fakeweb/windows.rb b/spec/support/fakeweb/windows.rb index 6c674b31b6..f1f21eed3f 100644 --- a/spec/support/fakeweb/windows.rb +++ b/spec/support/fakeweb/windows.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require File.expand_path("../../path.rb", __FILE__) include Spec::Path diff --git a/spec/support/hax.rb b/spec/support/hax.rb index 1fd3ae9936..2cca22c6ab 100644 --- a/spec/support/hax.rb +++ b/spec/support/hax.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "rubygems" class Gem::Platform diff --git a/spec/support/helpers.rb b/spec/support/helpers.rb index 182f7b9bad..8bcae2a45a 100644 --- a/spec/support/helpers.rb +++ b/spec/support/helpers.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true module Spec module Helpers def reset! @@ -122,7 +123,7 @@ module Spec def ruby(ruby, options = {}) expect_err = options.delete(:expect_err) env = (options.delete(:env) || {}).map {|k, v| "#{k}='#{v}' " }.join - ruby.gsub!(/["`\$]/) {|m| "\\#{m}" } + ruby = ruby.gsub(/["`\$]/) {|m| "\\#{m}" } lib_option = options[:no_lib] ? "" : " -I#{lib}" sys_exec(%(#{env}#{Gem.ruby}#{lib_option} -e "#{ruby}"), expect_err) end @@ -284,14 +285,13 @@ module Spec ENV["GEM_PATH"] = system_gem_path.to_s install_gems(*gems) - if block_given? - begin - yield - ensure - ENV["GEM_HOME"] = gem_home - ENV["GEM_PATH"] = gem_path - ENV["PATH"] = path - end + return unless block_given? + begin + yield + ensure + ENV["GEM_HOME"] = gem_home + ENV["GEM_PATH"] = gem_path + ENV["PATH"] = path end end @@ -312,14 +312,13 @@ module Spec gems.each do |gem| gem_command :install, "--no-rdoc --no-ri #{gem}" end - if block_given? - begin - yield - ensure - ENV["GEM_HOME"] = gem_home - ENV["GEM_PATH"] = gem_path - ENV["PATH"] = path - end + return unless block_given? + begin + yield + ensure + ENV["GEM_HOME"] = gem_home + ENV["GEM_PATH"] = gem_path + ENV["PATH"] = path end end diff --git a/spec/support/indexes.rb b/spec/support/indexes.rb index 10067197db..acace96886 100644 --- a/spec/support/indexes.rb +++ b/spec/support/indexes.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true module Spec module Indexes def dep(name, reqs = nil) diff --git a/spec/support/less_than_proc.rb b/spec/support/less_than_proc.rb index 515470968a..27966aa6ed 100644 --- a/spec/support/less_than_proc.rb +++ b/spec/support/less_than_proc.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true class LessThanProc < Proc attr_accessor :present diff --git a/spec/support/matchers.rb b/spec/support/matchers.rb index 58babf2ceb..7047e1be76 100644 --- a/spec/support/matchers.rb +++ b/spec/support/matchers.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true module Spec module Matchers RSpec::Matchers.define :have_dep do |*args| @@ -69,7 +70,7 @@ module Spec def lockfile_should_be(expected) should_be_locked spaces = expected[/\A\s+/, 0] || "" - expected.gsub!(/^#{spaces}/, "") + expected = expected.gsub(/^#{spaces}/, "") expect(bundled_app("Gemfile.lock").read).to eq(expected) end end diff --git a/spec/support/path.rb b/spec/support/path.rb index 42eb9f7364..d1f698acbe 100644 --- a/spec/support/path.rb +++ b/spec/support/path.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "pathname" module Spec diff --git a/spec/support/permissions.rb b/spec/support/permissions.rb index efdb4a5b28..f5636dd70a 100644 --- a/spec/support/permissions.rb +++ b/spec/support/permissions.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true module Spec module Permissions def with_umask(new_umask) diff --git a/spec/support/platforms.rb b/spec/support/platforms.rb index 26753af936..b1dedb05fa 100644 --- a/spec/support/platforms.rb +++ b/spec/support/platforms.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true module Spec module Platforms include Bundler::GemHelpers diff --git a/spec/support/ruby_ext.rb b/spec/support/ruby_ext.rb index 9c5b08c9e5..7f1eabf4b5 100644 --- a/spec/support/ruby_ext.rb +++ b/spec/support/ruby_ext.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true class IO def read_available_bytes(chunk_size = 16_384, select_timeout = 0.02) buffer = [] diff --git a/spec/support/rubygems_ext.rb b/spec/support/rubygems_ext.rb index 2889f44040..64cc41443d 100644 --- a/spec/support/rubygems_ext.rb +++ b/spec/support/rubygems_ext.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "rubygems/user_interaction" require "support/path" unless defined?(Spec::Path) @@ -30,9 +31,9 @@ module Spec if !File.exist?(manifest_path) || !(manifest - File.readlines(manifest_path)).empty? FileUtils.rm_rf(Path.base_system_gems) FileUtils.mkdir_p(Path.base_system_gems) - File.open(manifest_path, "w") {|f| f << manifest.join } puts "installing gems for the tests to use..." DEPS.each {|n, v| install_gem(n, v) } + File.open(manifest_path, "w") {|f| f << manifest.join } end ENV["HOME"] = Path.home.to_s @@ -42,7 +43,7 @@ module Spec def self.install_gem(name, version = nil) cmd = "gem install #{name} --no-rdoc --no-ri" - cmd << " --version #{version}" if version + cmd += " --version #{version}" if version system(cmd) || raise("Installing gem #{name} for the tests to use failed!") end diff --git a/spec/support/sometimes.rb b/spec/support/sometimes.rb index 0ab15d974f..1ecbd36e2d 100644 --- a/spec/support/sometimes.rb +++ b/spec/support/sometimes.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true module Sometimes def run_with_retries(example_to_run, retries) example = RSpec.current_example diff --git a/spec/support/streams.rb b/spec/support/streams.rb index f89c506c93..561b29092b 100644 --- a/spec/support/streams.rb +++ b/spec/support/streams.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "stringio" def capture(*streams) diff --git a/spec/support/sudo.rb b/spec/support/sudo.rb index 2192b09dc8..8c82bb8c0f 100644 --- a/spec/support/sudo.rb +++ b/spec/support/sudo.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true module Spec module Sudo def self.present? diff --git a/spec/update/git_spec.rb b/spec/update/git_spec.rb index 1c69918f25..94426b68d9 100644 --- a/spec/update/git_spec.rb +++ b/spec/update/git_spec.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "spec_helper" describe "bundle update" do diff --git a/spec/update/path_spec.rb b/spec/update/path_spec.rb index 79d8caa945..aa220ad60e 100644 --- a/spec/update/path_spec.rb +++ b/spec/update/path_spec.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "spec_helper" describe "path sources" do |