aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-12-14 08:05:35 +0000
committerhsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-12-14 08:05:35 +0000
commit059c9c1cf371e049c7481c78b76e9620da52757f (patch)
treeb383b59a1a2761c5fa2110fdd7712e80f02d08ea
parent6cf568f4b56dcafc5c0fe84df2c0d2491fb0c62b (diff)
downloadruby-059c9c1cf371e049c7481c78b76e9620da52757f.tar.gz
* 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
-rw-r--r--ChangeLog10
-rw-r--r--ext/socket/lib/socket.rb2
-rw-r--r--lib/drb/extservm.rb2
-rw-r--r--lib/net/http.rb4
-rw-r--r--lib/net/http/response.rb2
-rw-r--r--lib/scanf.rb3
-rw-r--r--lib/uri/generic.rb2
7 files changed, 17 insertions, 8 deletions
diff --git a/ChangeLog b/ChangeLog
index 379caca6fe..eac47333ce 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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>
* bootstraptest/runner.rb: use safe navigation operator.
diff --git a/ext/socket/lib/socket.rb b/ext/socket/lib/socket.rb
index 31dc596d3e..5c3ed400f4 100644
--- a/ext/socket/lib/socket.rb
+++ b/ext/socket/lib/socket.rb
@@ -1102,7 +1102,7 @@ class Socket < BasicSocket
st = File.lstat(path)
rescue Errno::ENOENT
end
- if st && st.socket? && st.owned?
+ if st&.socket? && st.owned?
File.unlink path
end
end
diff --git a/lib/drb/extservm.rb b/lib/drb/extservm.rb
index 8a7fc316af..7228939d58 100644
--- a/lib/drb/extservm.rb
+++ b/lib/drb/extservm.rb
@@ -37,7 +37,7 @@ module DRb
synchronize do
while true
server = @servers[name]
- return server if server && server.alive?
+ return server if server&.alive?
invoke_service(name)
@cond.wait
end
diff --git a/lib/net/http.rb b/lib/net/http.rb
index fa6185b0ba..70f5165e91 100644
--- a/lib/net/http.rb
+++ b/lib/net/http.rb
@@ -1055,7 +1055,7 @@ module Net #:nodoc:
# The address of the proxy server, if one is configured.
def proxy_address
if @proxy_from_env then
- proxy_uri && proxy_uri.hostname
+ proxy_uri&.hostname
else
@proxy_address
end
@@ -1064,7 +1064,7 @@ module Net #:nodoc:
# The port of the proxy server, if one is configured.
def proxy_port
if @proxy_from_env then
- proxy_uri && proxy_uri.port
+ proxy_uri&.port
else
@proxy_port
end
diff --git a/lib/net/http/response.rb b/lib/net/http/response.rb
index 126c22160d..f51d6b1373 100644
--- a/lib/net/http/response.rb
+++ b/lib/net/http/response.rb
@@ -251,7 +251,7 @@ class Net::HTTPResponse
return yield @socket if self['content-range']
v = self['content-encoding']
- case v && v.downcase
+ case v&.downcase
when 'deflate', 'gzip', 'x-gzip' then
self.delete 'content-encoding'
diff --git a/lib/scanf.rb b/lib/scanf.rb
index d12dc12f55..6ba6847616 100644
--- a/lib/scanf.rb
+++ b/lib/scanf.rb
@@ -471,8 +471,7 @@ module Scanf
end
def width
- w = @spec_string[/%\*?(\d+)/, 1]
- w && w.to_i
+ @spec_string[/%\*?(\d+)/, 1]&.to_i
end
def mid_match?
diff --git a/lib/uri/generic.rb b/lib/uri/generic.rb
index 1486a4cb25..224a16317b 100644
--- a/lib/uri/generic.rb
+++ b/lib/uri/generic.rb
@@ -1326,7 +1326,7 @@ module URI
# Destructive version of #normalize
#
def normalize!
- if path && path.empty?
+ if path&.empty?
set_path('/')
end
if scheme && scheme != scheme.downcase