Skip to content

Commit

Permalink
Fix 1.9.3dev unused variable warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
drbrain committed Dec 31, 2010
1 parent 6cfc91e commit 0e4b776
Show file tree
Hide file tree
Showing 17 changed files with 33 additions and 65 deletions.
4 changes: 2 additions & 2 deletions lib/rubygems/security.rb
Expand Up @@ -685,8 +685,8 @@ def self.build_cert(name, key, opt = {})

ef = OpenSSL::X509::ExtensionFactory.new nil, cert

cert.extensions = opt[:cert_exts].map do |name, value|
ef.create_extension name, value
cert.extensions = opt[:cert_exts].map do |ext_name, value|
ef.create_extension ext_name, value
end

i_key = opt[:issuer_key] || key
Expand Down
1 change: 1 addition & 0 deletions lib/rubygems/server.rb
Expand Up @@ -673,6 +673,7 @@ def root(req, res)
template = ERB.new(DOC_TEMPLATE)
res['content-type'] = 'text/html'

# this is used by binding, 1.9.3dev warns anyways
values = { "gem_count" => specs.size.to_s, "specs" => specs,
"total_file_count" => total_file_count.to_s }

Expand Down
2 changes: 1 addition & 1 deletion lib/rubygems/source_index.rb
Expand Up @@ -325,7 +325,7 @@ def outdated
begin
fetcher = Gem::SpecFetcher.fetcher
remotes = fetcher.find_matching dependency
remotes = remotes.map { |(name, version,_),_| version }
remotes = remotes.map { |(_, version, _), _| version }
rescue Gem::RemoteFetcher::FetchError => e
raise unless fetcher.warn_legacy e do
require 'rubygems/source_info_cache'
Expand Down
1 change: 0 additions & 1 deletion lib/rubygems/spec_fetcher.rb
Expand Up @@ -191,7 +191,6 @@ def legacy_repos

def suggest_gems_from_name gem_name
gem_name = gem_name.downcase
gem_starts_with = gem_name[0,1]
max = gem_name.size / 2
specs = list.values.flatten(1) # flatten(1) is 1.8.7 and up

Expand Down
4 changes: 2 additions & 2 deletions lib/rubygems/specification.rb
Expand Up @@ -691,7 +691,7 @@ def same_attributes?(other)
private :same_attributes?

def hash # :nodoc:
@@attributes.inject(0) { |hash_code, (name, default_value)|
@@attributes.inject(0) { |hash_code, (name, _)|
hash_code ^ self.send(name).hash
}
end
Expand Down Expand Up @@ -722,7 +722,7 @@ def encode_with coder # :nodoc:
def to_yaml(opts = {}) # :nodoc:
return super if YAML.const_defined?(:ENGINE) && !YAML::ENGINE.syck?

yaml = YAML.quick_emit object_id, opts do |out|
YAML.quick_emit object_id, opts do |out|
out.map taguri, to_yaml_style do |map|
encode_with map
end
Expand Down
4 changes: 3 additions & 1 deletion test/gem_package_tar_test_case.rb
Expand Up @@ -120,8 +120,10 @@ def to_oct(n, pad_size)

def util_entry(tar)
io = TempIO.new tar

header = Gem::Package::TarHeader.from io
entry = Gem::Package::TarReader::Entry.new header, io

Gem::Package::TarReader::Entry.new header, io
end

def util_dir_entry
Expand Down
2 changes: 1 addition & 1 deletion test/gemutilities.rb
Expand Up @@ -159,7 +159,7 @@ def teardown

Gem.clear_paths

Gem.class_eval { @ruby = ruby } if ruby = @orig_ruby
Gem.class_eval { @ruby = _ } if _ = @orig_ruby

if @orig_ENV_HOME then
ENV['HOME'] = @orig_ENV_HOME
Expand Down
4 changes: 2 additions & 2 deletions test/test_gem_commands_outdated_command.rb
Expand Up @@ -14,8 +14,8 @@ def test_initialize
end

def test_execute
local_01 = quick_gem 'foo', '0.1'
local_02 = quick_gem 'foo', '0.2'
quick_gem 'foo', '0.1'
quick_gem 'foo', '0.2'
remote_10 = quick_gem 'foo', '1.0'
remote_20 = quick_gem 'foo', '2.0'

Expand Down
6 changes: 0 additions & 6 deletions test/test_gem_commands_query_command.rb
Expand Up @@ -64,9 +64,6 @@ def test_execute_platform
end

def test_execute_all
a1_name = @a1.full_name
a2_name = @a2.full_name

@cmd.handle_options %w[-r --all]

use_ui @ui do
Expand All @@ -86,9 +83,6 @@ def test_execute_all
end

def test_execute_all_prerelease
a1_name = @a1.full_name
a2_name = @a2.full_name

@cmd.handle_options %w[-r --all --prerelease]

use_ui @ui do
Expand Down
8 changes: 4 additions & 4 deletions test/test_gem_commands_specification_command.rb
Expand Up @@ -25,8 +25,8 @@ def test_execute
end

def test_execute_all
foo1 = quick_gem 'foo', '0.0.1'
foo2 = quick_gem 'foo', '0.0.2'
quick_gem 'foo', '0.0.1'
quick_gem 'foo', '0.0.2'

@cmd.options[:args] = %w[foo]
@cmd.options[:all] = true
Expand Down Expand Up @@ -56,8 +56,8 @@ def test_execute_bad_name
end

def test_execute_exact_match
foo = quick_gem 'foo'
foo_bar = quick_gem 'foo_bar'
quick_gem 'foo'
quick_gem 'foo_bar'

@cmd.options[:args] = %w[foo]

Expand Down
16 changes: 8 additions & 8 deletions test/test_gem_dependency_installer.rb
Expand Up @@ -56,8 +56,8 @@ def setup
@fetcher = Gem::FakeFetcher.new
Gem::RemoteFetcher.fetcher = @fetcher

si = util_setup_spec_fetcher(@a1, @a1_pre, @b1, @b1_pre, @c1_pre, @d1, @d2,
@x1_m, @x1_o, @w1, @y1, @y1_1_p, @z1)
util_setup_spec_fetcher(@a1, @a1_pre, @b1, @b1_pre, @c1_pre, @d1, @d2,
@x1_m, @x1_o, @w1, @y1, @y1_1_p, @z1)

util_clear_gems
end
Expand All @@ -78,7 +78,7 @@ def test_install
end

def test_install_all_dependencies
e1, e1_gem = util_gem 'e', '1' do |s|
_, e1_gem = util_gem 'e', '1' do |s|
s.add_dependency 'b'
end

Expand Down Expand Up @@ -190,9 +190,9 @@ def test_install_dependency_existing
end

def test_install_dependency_old
e1, e1_gem = util_gem 'e', '1'
f1, f1_gem = util_gem 'f', '1', 'e' => nil
f2, f2_gem = util_gem 'f', '2'
_, e1_gem = util_gem 'e', '1'
_, f1_gem = util_gem 'f', '1', 'e' => nil
_, f2_gem = util_gem 'f', '2'

FileUtils.mv e1_gem, @tempdir
FileUtils.mv f1_gem, @tempdir
Expand Down Expand Up @@ -610,7 +610,7 @@ def test_find_gems_with_sources_prerelease
def assert_resolve expected, *specs
util_clear_gems

si = util_setup_spec_fetcher(*specs)
util_setup_spec_fetcher(*specs)

inst = Gem::DependencyInstaller.new
inst.find_spec_by_name_and_version 'a'
Expand Down Expand Up @@ -661,7 +661,7 @@ def test_gather_dependencies_old_required

util_clear_gems

si = util_setup_spec_fetcher @d1, @d2, e1
util_setup_spec_fetcher @d1, @d2, e1

inst = Gem::DependencyInstaller.new
inst.find_spec_by_name_and_version 'e'
Expand Down
9 changes: 0 additions & 9 deletions test/test_gem_ext_ext_conf_builder.rb
Expand Up @@ -28,15 +28,6 @@ def test_class_build
Gem::Ext::ExtConfBuilder.build 'extconf.rb', nil, @dest_path, output
end

expected = [
"ruby extconf.rb",
"creating Makefile\n",
"make",
"make: Nothing to be done for `all'.\n",
"make install",
"make: Nothing to be done for `install'.\n"
]

assert_match(/^#{Gem.ruby} extconf.rb/, output[0])
assert_equal "creating Makefile\n", output[1]
case RUBY_PLATFORM
Expand Down
15 changes: 0 additions & 15 deletions test/test_gem_ext_rake_builder.rb
Expand Up @@ -33,13 +33,6 @@ def test_class_build

output = output.join "\n"

expected = [
"#{@@ruby} mkrf_conf.rb",
"",
"#{@@rake} RUBYARCHDIR=#{@dest_path} RUBYLIBDIR=#{@dest_path}",
"(in #{realdir})\n"
]

refute_match %r%^rake failed:%, output
assert_match %r%^#{Regexp.escape @@ruby} mkrf_conf\.rb%, output
assert_match %r%^#{Regexp.escape @@rake} RUBYARCHDIR=#{Regexp.escape @dest_path} RUBYLIBDIR=#{Regexp.escape @dest_path}%, output
Expand All @@ -64,14 +57,6 @@ def test_class_build_fail
end
end

expected = <<-EOF.strip
rake failed:
#{@@ruby} mkrf_conf.rb
#{@@rake} RUBYARCHDIR=#{@dest_path} RUBYLIBDIR=#{@dest_path}
EOF

assert_match %r%^rake failed:%, error.message
assert_match %r%^#{Regexp.escape @@ruby} mkrf_conf\.rb%, error.message
assert_match %r%^#{Regexp.escape @@rake} RUBYARCHDIR=#{Regexp.escape @dest_path} RUBYLIBDIR=#{Regexp.escape @dest_path}%, error.message
Expand Down
5 changes: 0 additions & 5 deletions test/test_gem_installer.rb
Expand Up @@ -58,10 +58,6 @@ def test_build_extensions_extconf_bad
assert_equal '', @ui.error

gem_make_out = File.join @gemhome, 'gems', @spec.full_name, 'gem_make.out'
expected = <<-EOF
#{Gem.ruby} extconf.rb
#{Gem.ruby}: No such file or directory -- extconf.rb (LoadError)
EOF

assert_match %r%#{Regexp.escape Gem.ruby} extconf\.rb%,
File.read(gem_make_out)
Expand Down Expand Up @@ -655,7 +651,6 @@ def test_install_missing_dirs

use_ui @ui do
Dir.chdir @tempdir do Gem::Builder.new(@spec).build end
gem = File.join @tempdir, @spec.file_name

@installer.install
end
Expand Down
1 change: 0 additions & 1 deletion test/test_gem_platform.rb
Expand Up @@ -117,7 +117,6 @@ def test_initialize_mswin32_vc6

def test_initialize_platform
platform = Gem::Platform.new 'cpu-my_platform1'
expected = Gem::Platform.new platform

assert_equal 'cpu', platform.cpu
assert_equal 'my_platform', platform.os
Expand Down
4 changes: 3 additions & 1 deletion test/test_gem_remote_fetcher.rb
Expand Up @@ -646,11 +646,13 @@ def @fetcher.connection_for uri

def assert_error(exception_class=Exception)
got_exception = false

begin
yield
rescue exception_class => ex
rescue exception_class
got_exception = true
end

assert got_exception, "Expected exception conforming to #{exception_class}"
end

Expand Down
12 changes: 6 additions & 6 deletions test/test_gem_server.rb
Expand Up @@ -92,7 +92,7 @@ def test_latest_specs_gz
def test_listen
util_listen

out, err = capture_io do
capture_io do
@server.listen
end

Expand All @@ -102,10 +102,10 @@ def test_listen
def test_listen_addresses
util_listen

out, err = capture_io do
capture_io do
@server.listen %w[a b]
end

assert_equal 2, @server.server.listeners.length
end

Expand All @@ -125,7 +125,7 @@ def test_quick_a_1_gemspec_rz
end

def test_quick_a_1_mswin32_gemspec_rz
a1_p = quick_gem 'a', '1' do |s| s.platform = Gem::Platform.local end
quick_gem 'a', '1' do |s| s.platform = Gem::Platform.local end

data = StringIO.new "GET /quick/a-1-#{Gem::Platform.local}.gemspec.rz HTTP/1.0\r\n\r\n"
@req.parse data
Expand All @@ -143,7 +143,7 @@ def test_quick_a_1_mswin32_gemspec_rz
end

def test_quick_common_substrings
ab1 = quick_gem 'ab', '1'
quick_gem 'ab', '1'

data = StringIO.new "GET /quick/a-1.gemspec.rz HTTP/1.0\r\n\r\n"
@req.parse data
Expand Down Expand Up @@ -236,7 +236,7 @@ def test_quick_marshal_a_1_gemspec_rz
end

def test_quick_marshal_a_1_mswin32_gemspec_rz
a1_p = quick_gem 'a', '1' do |s| s.platform = Gem::Platform.local end
quick_gem 'a', '1' do |s| s.platform = Gem::Platform.local end

data = StringIO.new "GET /quick/Marshal.#{Gem.marshal_version}/a-1-#{Gem::Platform.local}.gemspec.rz HTTP/1.0\r\n\r\n"
@req.parse data
Expand Down

0 comments on commit 0e4b776

Please sign in to comment.