Skip to content

Commit b923c0c

Browse files
committed
Merge pull request #255 from wconrad/warning-mode-safe
Fix warning-mode nitpicks
2 parents 1803a3b + 7f0dc70 commit b923c0c

File tree

6 files changed

+18
-17
lines changed

6 files changed

+18
-17
lines changed

lib/httpclient.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ def initialize(*args, &block)
420420
load_environment
421421
self.proxy = proxy if proxy
422422
keep_webmock_compat
423-
instance_eval &block if block
423+
instance_eval(&block) if block
424424
end
425425

426426
# webmock 1.6.2 depends on HTTP::Message#body.content to work.
@@ -1102,7 +1102,7 @@ def success_content(res)
11021102
def protect_keep_alive_disconnected
11031103
begin
11041104
yield
1105-
rescue KeepAliveDisconnected => e
1105+
rescue KeepAliveDisconnected
11061106
# Force to create new connection
11071107
Thread.current[:HTTPClient_AcquireNewConnection] = true
11081108
begin

lib/httpclient/auth.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,7 @@ def set?
535535
def get(req)
536536
target_uri = req.header.request_uri
537537
synchronize {
538-
domain_uri, param = @challenge.find { |uri, v|
538+
_domain_uri, param = @challenge.find { |uri, v|
539539
Util.uri_part_of(target_uri, uri)
540540
}
541541
return nil unless param

test/test_auth.rb

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ def self.decode_utf16le(*arg)
124124
end
125125
# Make it work if @value == nil
126126
class SecurityBuffer < FieldSet
127+
remove_method(:data_size) if method_defined?(:data_size)
127128
def data_size
128129
@active && @value ? @value.size : 0
129130
end
@@ -230,7 +231,7 @@ def test_BASIC_auth_multi_thread
230231
c.www_auth.basic_auth.instance_eval { @scheme = "BASIC" }
231232
c.set_auth("http://localhost:#{serverport}/", 'admin', 'admin')
232233

233-
threads = 100.times.map { |idx|
234+
100.times.map { |idx|
234235
Thread.new(idx) { |idx2|
235236
Thread.abort_on_exception = true
236237
Thread.pass
@@ -251,7 +252,7 @@ def test_basic_auth_reuses_credentials
251252
c.test_loopback_http_response << "HTTP/1.0 200 OK\nContent-Length: 2\n\nOK"
252253
c.debug_dev = str = ''
253254
c.get_content("http://localhost:#{serverport}/basic_auth/sub/dir/")
254-
assert_match /Authorization: Basic YWRtaW46YWRtaW4=/, str
255+
assert_match(/Authorization: Basic YWRtaW46YWRtaW4=/, str)
255256
end
256257

257258
def test_digest_auth
@@ -267,7 +268,7 @@ def test_digest_auth_reuses_credentials
267268
c.test_loopback_http_response << "HTTP/1.0 200 OK\nContent-Length: 2\n\nOK"
268269
c.debug_dev = str = ''
269270
c.get_content("http://localhost:#{serverport}/digest_auth/sub/dir/")
270-
assert_match /Authorization: Digest/, str
271+
assert_match(/Authorization: Digest/, str)
271272
end
272273

273274
def test_digest_auth_with_block

test/test_cookie.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -290,8 +290,8 @@ def test_keep_escaped
290290
def test_load_cookies_escaped
291291
uri = urify('http://example.org/')
292292
f = Tempfile.new('test_cookie')
293-
File.open(f.path, 'w') do |f|
294-
f.write <<EOF
293+
File.open(f.path, 'w') do |out|
294+
out.write <<EOF
295295
http://example.org/ key1 "value" 0 .example.org / 13 0
296296
http://example.org/ key2 "" 0 .example.org / 13 0
297297
http://example.org/ key3 0 .example.org / 13 0

test/test_httpclient.rb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -770,8 +770,8 @@ def test_get_with_block
770770

771771
def test_get_with_block_arity_2
772772
called = false
773-
res = @client.get(serverurl + 'servlet') { |res, str|
774-
assert_equal(200, res.status)
773+
res = @client.get(serverurl + 'servlet') { |blk_res, str|
774+
assert_equal(200, blk_res.status)
775775
assert_equal('get', str)
776776
called = true
777777
}
@@ -783,7 +783,7 @@ def test_get_with_block_arity_2
783783
def test_get_with_block_string_recycle
784784
@client.read_block_size = 2
785785
body = []
786-
res = @client.get(serverurl + 'servlet') { |str|
786+
_res = @client.get(serverurl + 'servlet') { |str|
787787
body << str
788788
}
789789
assert_equal(2, body.size)
@@ -800,7 +800,7 @@ def test_get_with_block_chunked_string_recycle
800800
url = "http://localhost:#{server.addr[1]}/"
801801
body = []
802802
begin
803-
res = @client.get(url + 'chunked') { |str|
803+
_res = @client.get(url + 'chunked') { |str|
804804
body << str
805805
}
806806
ensure
@@ -955,7 +955,7 @@ def myio.size
955955
1
956956
end
957957
@client.debug_dev = str = StringIO.new
958-
res = @client.post(serverurl + 'servlet', { :file => myio })
958+
_res = @client.post(serverurl + 'servlet', { :file => myio })
959959
assert_match(/\r\n4\r\n/, str.string, 'should send "4" not "45"')
960960
end
961961

@@ -972,7 +972,7 @@ def size
972972
end
973973
end
974974
@client.debug_dev = str = StringIO.new
975-
res = @client.post(serverurl + 'servlet', { :file1 => myio1, :file2 => myio2 })
975+
_res = @client.post(serverurl + 'servlet', { :file1 => myio1, :file2 => myio2 })
976976
assert_match(/\r\n45\r\n/, str.string)
977977
end
978978

@@ -1273,7 +1273,7 @@ def test_extra_headers
12731273

12741274
def test_http_custom_date_header
12751275
@client.debug_dev = (str = "")
1276-
res = @client.get(serverurl + 'hello', :header => {'Date' => 'foo'})
1276+
_res = @client.get(serverurl + 'hello', :header => {'Date' => 'foo'})
12771277
lines = str.split(/(?:\r?\n)+/)
12781278
assert_equal('Date: foo', lines[4])
12791279
end

test/test_webagent-cookie.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -440,8 +440,8 @@ def test_escaped
440440
def test_load_cookies_escaped
441441
uri = urify('http://example.org/')
442442
f = Tempfile.new('test_cookie')
443-
File.open(f.path, 'w') do |f|
444-
f.write <<EOF
443+
File.open(f.path, 'w') do |out|
444+
out.write <<EOF
445445
http://example.org/ key "value" 0 .example.org / 13 0
446446
http://example.org/ key "" .example.org / 13 0
447447
http://example.org/ key .example.org / 13 0

0 commit comments

Comments
 (0)