diff options
author | Andre Arko <andre@arko.net> | 2012-12-10 11:39:29 -0800 |
---|---|---|
committer | Andre Arko <andre@arko.net> | 2012-12-10 14:55:37 -0800 |
commit | 4837fdf55066dc203beffb8d3c64876ba71d44e8 (patch) | |
tree | dd9324a78222450832bdf8c8a2a1e3511542fd42 | |
parent | 646971d18cb2f1928051678a8569bb24eb836c58 (diff) | |
download | bundler-4837fdf55066dc203beffb8d3c64876ba71d44e8.tar.gz |
fix all bundler codebase warnings
- remove unused variables
- renamed block-shadowed variables
- double-assign variables used by erb
-rw-r--r-- | lib/bundler/cli.rb | 5 | ||||
-rw-r--r-- | lib/bundler/fetcher.rb | 2 | ||||
-rw-r--r-- | lib/bundler/installer.rb | 28 | ||||
-rw-r--r-- | lib/bundler/rubygems_integration.rb | 8 |
4 files changed, 22 insertions, 21 deletions
diff --git a/lib/bundler/cli.rb b/lib/bundler/cli.rb index 920548b2ca..567a750164 100644 --- a/lib/bundler/cli.rb +++ b/lib/bundler/cli.rb @@ -576,7 +576,6 @@ module Bundler method_option :format, :type => :string, :default => "png", :aliases => '-F', :banner => "This is output format option. Supported format is png, jpg, svg, dot ..." def viz output_file = File.expand_path(options[:file]) - output_format = options[:format] graph = Graph.new(Bundler.load, output_file, options[:version], options[:requirements], options[:format]) begin @@ -699,8 +698,8 @@ module Bundler # Build an array of Dependency objects out of the arguments deps = [] - gems.each_slice(2) do |name, version| - deps << Bundler::Dependency.new(name, version) + gems.each_slice(2) do |gem_name, gem_version| + deps << Bundler::Dependency.new(gem_name, gem_version) end added = Injector.inject(deps) diff --git a/lib/bundler/fetcher.rb b/lib/bundler/fetcher.rb index 422e8ac1d9..53bec653dc 100644 --- a/lib/bundler/fetcher.rb +++ b/lib/bundler/fetcher.rb @@ -141,7 +141,7 @@ module Bundler response = @@connection.request(uri) rescue Timeout::Error, Errno::EINVAL, Errno::ECONNRESET, Errno::ETIMEDOUT, EOFError, SocketError, Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError, - Errno::EAGAIN, Net::HTTP::Persistent::Error, Net::ProtocolError => e + Errno::EAGAIN, Net::HTTP::Persistent::Error, Net::ProtocolError raise HTTPError, "Network error while fetching #{uri}" end diff --git a/lib/bundler/installer.rb b/lib/bundler/installer.rb index a99f0650bf..95a4f02dda 100644 --- a/lib/bundler/installer.rb +++ b/lib/bundler/installer.rb @@ -17,10 +17,10 @@ module Bundler # Runs the install procedures for a specific Gemfile. # - # Firstly, this method will check to see if Bundler.bundle_path exists + # Firstly, this method will check to see if Bundler.bundle_path exists # and if not then will create it. This is usually the location of gems # on the system, be it RVM or at a system path. - # + # # Secondly, it checks if Bundler has been configured to be "frozen" # Frozen ensures that the Gemfile and the Gemfile.lock file are matching. # This stops a situation where a developer may update the Gemfile but may not run @@ -28,7 +28,7 @@ module Bundler # If this file is not correctly updated then any other developer running # `bundle install` will potentially not install the correct gems. # - # Thirdly, Bundler checks if there are any dependencies specified in the Gemfile using + # Thirdly, Bundler checks if there are any dependencies specified in the Gemfile using # Bundler::Environment#dependencies. If there are no dependencies specified then # Bundler returns a warning message stating so and this method returns. # @@ -40,11 +40,11 @@ module Bundler # Fifthly, Bundler resolves the dependencies either through a cache of gems or by remote. # This then leads into the gems being installed, along with stubs for their executables, # but only if the --binstubs option has been passed or Bundler.options[:bin] has been set - # earlier. - # + # earlier. + # # Sixthly, a new Gemfile.lock is created from the installed gems to ensure that the next time # that a user runs `bundle install` they will receive any updates from this process. - # + # # Finally: TODO add documentation for how the standalone process works. def run(options) # Create the BUNDLE_PATH directory @@ -129,10 +129,11 @@ module Bundler end def generate_bundler_executable_stubs(spec) - bin_path = Bundler.bin_path - template = File.read(File.expand_path('../templates/Executable', __FILE__)) - relative_gemfile_path = Bundler.default_gemfile.relative_path_from(bin_path) - ruby_command = Thor::Util.ruby_command + # double-assignment to avoid warnings about variables that will be used by ERB + bin_path = bin_path = Bundler.bin_path + template = template = File.read(File.expand_path('../templates/Executable', __FILE__)) + relative_gemfile_path = relative_gemfile_path = Bundler.default_gemfile.relative_path_from(bin_path) + ruby_command = ruby_command = Thor::Util.ruby_command spec.executables.each do |executable| next if executable == "bundle" @@ -143,14 +144,15 @@ module Bundler end def generate_standalone_bundler_executable_stubs(spec) + # double-assignment to avoid warnings about variables that will be used by ERB bin_path = Bundler.bin_path template = File.read(File.expand_path('../templates/Executable.standalone', __FILE__)) - ruby_command = Thor::Util.ruby_command + ruby_command = ruby_command = Thor::Util.ruby_command spec.executables.each do |executable| next if executable == "bundle" - standalone_path = Pathname(Bundler.settings[:path]).expand_path.relative_path_from(bin_path) - executable_path = Pathname(spec.full_gem_path).join(spec.bindir, executable).relative_path_from(bin_path) + standalone_path = standalone_path = Pathname(Bundler.settings[:path]).expand_path.relative_path_from(bin_path) + executable_path = executable_path = Pathname(spec.full_gem_path).join(spec.bindir, executable).relative_path_from(bin_path) File.open "#{bin_path}/#{executable}", 'w', 0755 do |f| f.puts ERB.new(template, nil, '-').result(binding) end diff --git a/lib/bundler/rubygems_integration.rb b/lib/bundler/rubygems_integration.rb index cb7c66e4c7..981920edcd 100644 --- a/lib/bundler/rubygems_integration.rb +++ b/lib/bundler/rubygems_integration.rb @@ -100,7 +100,7 @@ module Bundler # Then fetch the prerelease specs begin Gem::SpecFetcher.new.list(false, true).each {|k, v| spec_list[k] += v } - rescue Gem::RemoteFetcher::FetchError => e + rescue Gem::RemoteFetcher::FetchError # ignore if we can't fetch the prerelease specs end end @@ -415,16 +415,16 @@ module Bundler end def fetch_all_remote_specs - tuples, errors = Gem::SpecFetcher.new.available_specs(:complete) + fetched, errors = Gem::SpecFetcher.new.available_specs(:complete) # only raise if we don't get any specs back. # this means we still work if prerelease_specs.4.8.gz # don't exist but specs.4.8.gz do - if tuples.empty? && error = errors.detect {|e| e.is_a?(Gem::SourceFetchProblem) } + if fetched.empty? && error = errors.detect {|e| e.is_a?(Gem::SourceFetchProblem) } raise Gem::RemoteFetcher::FetchError.new(error.error, error.source) end hash = {} - tuples.each do |source,tuples| + fetched.each do |source, tuples| hash[source.uri] = tuples.map { |tuple| tuple.to_a } end |