From 059c9c1cf371e049c7481c78b76e9620da52757f Mon Sep 17 00:00:00 2001 From: hsbt Date: Mon, 14 Dec 2015 08:05:35 +0000 Subject: * 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 --- lib/drb/extservm.rb | 2 +- lib/net/http.rb | 4 ++-- lib/net/http/response.rb | 2 +- lib/scanf.rb | 3 +-- lib/uri/generic.rb | 2 +- 5 files changed, 6 insertions(+), 7 deletions(-) (limited to 'lib') 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 -- cgit v1.2.3