summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Giddins <segiddins@segiddins.me>2015-11-26 12:34:13 -0600
committerSamuel Giddins <segiddins@segiddins.me>2015-11-26 12:34:13 -0600
commit69832acfd333267d1bedc6b2467e5c0f0c1c67e1 (patch)
tree8fd3fd34e7440bc266e7062d13601ce617f69438
parent5782a9f536ba4440d74e4d4fcda25b26721982b3 (diff)
downloadbundler-69832acfd333267d1bedc6b2467e5c0f0c1c67e1.tar.gz
[RuboCop] Enable Style/Next
-rw-r--r--.rubocop_todo.yml13
-rwxr-xr-xexe/bundle11
-rwxr-xr-xexe/bundler11
-rw-r--r--lib/bundler/definition.rb9
-rw-r--r--lib/bundler/dsl.rb15
-rw-r--r--lib/bundler/resolver.rb65
-rw-r--r--lib/bundler/source/path.rb18
-rw-r--r--spec/support/artifice/endpoint.rb19
8 files changed, 69 insertions, 92 deletions
diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml
index 860bfbb461..7fa5daf6c7 100644
--- a/.rubocop_todo.yml
+++ b/.rubocop_todo.yml
@@ -160,19 +160,6 @@ Style/MultilineBlockChain:
Style/MultilineOperationIndentation:
Enabled: false
-# Offense count: 10
-# Cop supports --auto-correct.
-# Configuration parameters: EnforcedStyle, MinBodyLength, SupportedStyles.
-Style/Next:
- Exclude:
- - 'exe/bundle'
- - 'exe/bundler'
- - 'lib/bundler/definition.rb'
- - 'lib/bundler/dsl.rb'
- - 'lib/bundler/resolver.rb'
- - 'lib/bundler/source/path.rb'
- - 'spec/support/artifice/endpoint.rb'
-
# Offense count: 13
# Cop supports --auto-correct.
Style/ParallelAssignment:
diff --git a/exe/bundle b/exe/bundle
index 186af6f367..5baa52235a 100755
--- a/exe/bundle
+++ b/exe/bundle
@@ -6,12 +6,11 @@ Signal.trap("INT") { exit 1 }
require "bundler"
# Check if an older version of bundler is installed
$LOAD_PATH.each do |path|
- if 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 << "Please remove your old versions.\n"
- err << "An easy way to do this is by running `gem cleanup bundler`."
- abort(err)
- end
+ 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 << "Please remove your old versions.\n"
+ err << "An easy way to do this is by running `gem cleanup bundler`."
+ abort(err)
end
require "bundler/friendly_errors"
diff --git a/exe/bundler b/exe/bundler
index 186af6f367..5baa52235a 100755
--- a/exe/bundler
+++ b/exe/bundler
@@ -6,12 +6,11 @@ Signal.trap("INT") { exit 1 }
require "bundler"
# Check if an older version of bundler is installed
$LOAD_PATH.each do |path|
- if 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 << "Please remove your old versions.\n"
- err << "An easy way to do this is by running `gem cleanup bundler`."
- abort(err)
- end
+ 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 << "Please remove your old versions.\n"
+ err << "An easy way to do this is by running `gem cleanup bundler`."
+ abort(err)
end
require "bundler/friendly_errors"
diff --git a/lib/bundler/definition.rb b/lib/bundler/definition.rb
index 437d075123..b327f25e99 100644
--- a/lib/bundler/definition.rb
+++ b/lib/bundler/definition.rb
@@ -368,11 +368,10 @@ module Bundler
@locked_deps.each {|d| both_sources[d.name][1] = d.source }
both_sources.each do |name, (dep, lock_source)|
- if (dep.nil? && !lock_source.nil?) || (!dep.nil? && !lock_source.nil? && !lock_source.can_lock?(dep))
- gemfile_source_name = (dep && dep.source) || "no specified source"
- lockfile_source_name = lock_source || "no specified source"
- changed << "* #{name} from `#{gemfile_source_name}` to `#{lockfile_source_name}`"
- end
+ next unless (dep.nil? && !lock_source.nil?) || (!dep.nil? && !lock_source.nil? && !lock_source.can_lock?(dep))
+ gemfile_source_name = (dep && dep.source) || "no specified source"
+ lockfile_source_name = lock_source || "no specified source"
+ changed << "* #{name} from `#{gemfile_source_name}` to `#{lockfile_source_name}`"
end
msg << "\n\nYou have added to the Gemfile:\n" << added.join("\n") if added.any?
diff --git a/lib/bundler/dsl.rb b/lib/bundler/dsl.rb
index 70a1c89928..772a058418 100644
--- a/lib/bundler/dsl.rb
+++ b/lib/bundler/dsl.rb
@@ -299,15 +299,14 @@ module Bundler
end
%w(git path).each do |type|
- if param = opts[type]
- if version.first && version.first =~ /^\s*=?\s*(\d[^\s]*)\s*$/
- options = opts.merge("name" => name, "version" => $1)
- else
- options = opts.dup
- end
- source = send(type, param, options) {}
- opts["source"] = source
+ next unless param = opts[type]
+ if version.first && version.first =~ /^\s*=?\s*(\d[^\s]*)\s*$/
+ options = opts.merge("name" => name, "version" => $1)
+ else
+ options = opts.dup
end
+ source = send(type, param, options) {}
+ opts["source"] = source
end
opts["source"] ||= @source
diff --git a/lib/bundler/resolver.rb b/lib/bundler/resolver.rb
index 00d7e6d1df..edced0077f 100644
--- a/lib/bundler/resolver.rb
+++ b/lib/bundler/resolver.rb
@@ -94,14 +94,13 @@ module Bundler
specs = {}
@activated.each do |p|
- if s = @specs[p]
- platform = generic(Gem::Platform.new(s.platform))
- next if specs[platform]
+ next unless s = @specs[p]
+ platform = generic(Gem::Platform.new(s.platform))
+ next if specs[platform]
- lazy_spec = LazySpecification.new(name, version, platform, source)
- lazy_spec.dependencies.replace s.dependencies
- specs[platform] = lazy_spec
- end
+ lazy_spec = LazySpecification.new(name, version, platform, source)
+ lazy_spec.dependencies.replace s.dependencies
+ specs[platform] = lazy_spec
end
specs.values
end
@@ -156,12 +155,11 @@ module Bundler
@dependencies ||= begin
dependencies = {}
ALL.each do |p|
- if spec = @specs[p]
- dependencies[p] = []
- spec.dependencies.each do |dep|
- next if dep.type == :development
- dependencies[p] << DepProxy.new(dep, p)
- end
+ next unless spec = @specs[p]
+ dependencies[p] = []
+ spec.dependencies.each do |dep|
+ next if dep.type == :development
+ dependencies[p] << DepProxy.new(dep, p)
end
end
dependencies
@@ -331,30 +329,29 @@ module Bundler
def verify_gemfile_dependencies_are_found!(requirements)
requirements.each do |requirement|
next if requirement.name == "bundler"
- if search_for(requirement).empty?
- if (base = @base[requirement.name]) && !base.empty?
- version = base.first.version
- message = "You have requested:\n" \
- " #{requirement.name} #{requirement.requirement}\n\n" \
- "The bundle currently has #{requirement.name} locked at #{version}.\n" \
- "Try running `bundle update #{requirement.name}`\n\n" \
- "If you are updating multiple gems in your Gemfile at once,\n" \
- "try passing them all to `bundle update`"
- 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
+ next unless search_for(requirement).empty?
+ if (base = @base[requirement.name]) && !base.empty?
+ version = base.first.version
+ message = "You have requested:\n" \
+ " #{requirement.name} #{requirement.requirement}\n\n" \
+ "The bundle currently has #{requirement.name} locked at #{version}.\n" \
+ "Try running `bundle update #{requirement.name}`\n\n" \
+ "If you are updating multiple gems in your Gemfile at once,\n" \
+ "try passing them all to `bundle update`"
+ 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 = "Could not find gem '#{requirement}' in any of the gem sources " \
- "listed in your Gemfile or available on this machine."
+ message << "Source does not contain any versions of '#{requirement}'"
end
- raise GemNotFound, message
+ else
+ message = "Could not find gem '#{requirement}' in any of the gem sources " \
+ "listed in your Gemfile or available on this machine."
end
+ raise GemNotFound, message
end
end
end
diff --git a/lib/bundler/source/path.rb b/lib/bundler/source/path.rb
index 292412044c..4192015cb7 100644
--- a/lib/bundler/source/path.rb
+++ b/lib/bundler/source/path.rb
@@ -132,11 +132,10 @@ module Bundler
if File.directory?(expanded_path)
# We sort depth-first since `<<` will override the earlier-found specs
Dir["#{expanded_path}/#{@glob}"].sort_by {|p| -p.split(File::SEPARATOR).size }.each do |file|
- if spec = Bundler.load_gemspec(file, :validate)
- spec.loaded_from = file.to_s
- spec.source = self
- index << spec
- end
+ next unless spec = Bundler.load_gemspec(file, :validate)
+ spec.loaded_from = file.to_s
+ spec.source = self
+ index << spec
end
if index.empty? && @name && @version
@@ -212,11 +211,10 @@ module Bundler
return unless Gem.respond_to?(hooks_meth)
Gem.send(hooks_meth).each do |hook|
result = hook.call(installer)
- if result == false
- location = " at #{$1}" if hook.inspect =~ /@(.*:\d+)/
- message = "#{type} hook#{location} failed for #{installer.spec.full_name}"
- raise InstallHookError, message
- end
+ next unless result == false
+ location = " at #{$1}" if hook.inspect =~ /@(.*:\d+)/
+ message = "#{type} hook#{location} failed for #{installer.spec.full_name}"
+ raise InstallHookError, message
end
end
end
diff --git a/spec/support/artifice/endpoint.rb b/spec/support/artifice/endpoint.rb
index 2ac0483ac6..931bbc48e8 100644
--- a/spec/support/artifice/endpoint.rb
+++ b/spec/support/artifice/endpoint.rb
@@ -21,16 +21,15 @@ class Endpoint < Sinatra::Base
Bundler::Deprecate.skip_during do
Marshal.load(File.open(gem_repo.join("specs.4.8")).read).map do |name, version, platform|
spec = load_spec(name, version, platform, gem_repo)
- if gem_names.include?(spec.name)
- {
- :name => spec.name,
- :number => spec.version.version,
- :platform => spec.platform.to_s,
- :dependencies => spec.dependencies.select {|dep| dep.type == :runtime }.map do |dep|
- [dep.name, dep.requirement.requirements.map {|a| a.join(" ") }.join(", ")]
- end
- }
- end
+ next unless gem_names.include?(spec.name)
+ {
+ :name => spec.name,
+ :number => spec.version.version,
+ :platform => spec.platform.to_s,
+ :dependencies => spec.dependencies.select {|dep| dep.type == :runtime }.map do |dep|
+ [dep.name, dep.requirement.requirements.map {|a| a.join(" ") }.join(", ")]
+ end
+ }
end.compact
end
end