* ext/socket/lib/socket.rb: use safe navigation operator.

[fix GH-1142] Patch by @mlarraz
* lib/drb/extservm.rb: ditto.
* lib/net/http.rb: ditto.
* lib/net/http/response.rb: ditto.
* lib/scanf.rb: ditto.
* lib/uri/generic.rb: ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53111 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
hsbt 2015-12-14 08:05:35 +00:00
parent 6cf568f4b5
commit 059c9c1cf3
7 changed files with 17 additions and 8 deletions

View File

@ -1,3 +1,13 @@
Mon Dec 14 17:04:14 2015 SHIBATA Hiroshi <hsbt@ruby-lang.org>
* ext/socket/lib/socket.rb: use safe navigation operator.
[fix GH-1142] Patch by @mlarraz
* lib/drb/extservm.rb: ditto.
* lib/net/http.rb: ditto.
* lib/net/http/response.rb: ditto.
* lib/scanf.rb: ditto.
* lib/uri/generic.rb: ditto.
Mon Dec 14 17:03:05 2015 SHIBATA Hiroshi <hsbt@ruby-lang.org> Mon Dec 14 17:03:05 2015 SHIBATA Hiroshi <hsbt@ruby-lang.org>
* bootstraptest/runner.rb: use safe navigation operator. * bootstraptest/runner.rb: use safe navigation operator.

View File

@ -1102,7 +1102,7 @@ class Socket < BasicSocket
st = File.lstat(path) st = File.lstat(path)
rescue Errno::ENOENT rescue Errno::ENOENT
end end
if st && st.socket? && st.owned? if st&.socket? && st.owned?
File.unlink path File.unlink path
end end
end end

View File

@ -37,7 +37,7 @@ module DRb
synchronize do synchronize do
while true while true
server = @servers[name] server = @servers[name]
return server if server && server.alive? return server if server&.alive?
invoke_service(name) invoke_service(name)
@cond.wait @cond.wait
end end

View File

@ -1055,7 +1055,7 @@ module Net #:nodoc:
# The address of the proxy server, if one is configured. # The address of the proxy server, if one is configured.
def proxy_address def proxy_address
if @proxy_from_env then if @proxy_from_env then
proxy_uri && proxy_uri.hostname proxy_uri&.hostname
else else
@proxy_address @proxy_address
end end
@ -1064,7 +1064,7 @@ module Net #:nodoc:
# The port of the proxy server, if one is configured. # The port of the proxy server, if one is configured.
def proxy_port def proxy_port
if @proxy_from_env then if @proxy_from_env then
proxy_uri && proxy_uri.port proxy_uri&.port
else else
@proxy_port @proxy_port
end end

View File

@ -251,7 +251,7 @@ class Net::HTTPResponse
return yield @socket if self['content-range'] return yield @socket if self['content-range']
v = self['content-encoding'] v = self['content-encoding']
case v && v.downcase case v&.downcase
when 'deflate', 'gzip', 'x-gzip' then when 'deflate', 'gzip', 'x-gzip' then
self.delete 'content-encoding' self.delete 'content-encoding'

View File

@ -471,8 +471,7 @@ module Scanf
end end
def width def width
w = @spec_string[/%\*?(\d+)/, 1] @spec_string[/%\*?(\d+)/, 1]&.to_i
w && w.to_i
end end
def mid_match? def mid_match?

View File

@ -1326,7 +1326,7 @@ module URI
# Destructive version of #normalize # Destructive version of #normalize
# #
def normalize! def normalize!
if path && path.empty? if path&.empty?
set_path('/') set_path('/')
end end
if scheme && scheme != scheme.downcase if scheme && scheme != scheme.downcase