[前][次][番号順一覧][スレッド一覧]

ruby-changes:41032

From: hsbt <ko1@a...>
Date: Mon, 14 Dec 2015 17:06:36 +0900 (JST)
Subject: [ruby-changes:41032] hsbt:r53111 (trunk): * ext/socket/lib/socket.rb: use safe navigation operator.

hsbt	2015-12-14 17:05:35 +0900 (Mon, 14 Dec 2015)

  New Revision: 53111

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=53111

  Log:
    * 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.

  Modified files:
    trunk/ChangeLog
    trunk/ext/socket/lib/socket.rb
    trunk/lib/drb/extservm.rb
    trunk/lib/net/http/response.rb
    trunk/lib/net/http.rb
    trunk/lib/scanf.rb
    trunk/lib/uri/generic.rb
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 53110)
+++ ChangeLog	(revision 53111)
@@ -1,3 +1,13 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Mon Dec 14 17:04:14 2015  SHIBATA Hiroshi  <hsbt@r...>
+
+	* 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@r...>
 
 	* bootstraptest/runner.rb: use safe navigation operator.
Index: lib/scanf.rb
===================================================================
--- lib/scanf.rb	(revision 53110)
+++ lib/scanf.rb	(revision 53111)
@@ -471,8 +471,7 @@ module Scanf https://github.com/ruby/ruby/blob/trunk/lib/scanf.rb#L471
     end
 
     def width
-      w = @spec_string[/%\*?(\d+)/, 1]
-      w && w.to_i
+      @spec_string[/%\*?(\d+)/, 1]&.to_i
     end
 
     def mid_match?
Index: lib/uri/generic.rb
===================================================================
--- lib/uri/generic.rb	(revision 53110)
+++ lib/uri/generic.rb	(revision 53111)
@@ -1326,7 +1326,7 @@ module URI https://github.com/ruby/ruby/blob/trunk/lib/uri/generic.rb#L1326
     # Destructive version of #normalize
     #
     def normalize!
-      if path && path.empty?
+      if path&.empty?
         set_path('/')
       end
       if scheme && scheme != scheme.downcase
Index: lib/net/http/response.rb
===================================================================
--- lib/net/http/response.rb	(revision 53110)
+++ lib/net/http/response.rb	(revision 53111)
@@ -251,7 +251,7 @@ class Net::HTTPResponse https://github.com/ruby/ruby/blob/trunk/lib/net/http/response.rb#L251
     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'
 
Index: lib/net/http.rb
===================================================================
--- lib/net/http.rb	(revision 53110)
+++ lib/net/http.rb	(revision 53111)
@@ -1055,7 +1055,7 @@ module Net   #:nodoc: https://github.com/ruby/ruby/blob/trunk/lib/net/http.rb#L1055
     # 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: https://github.com/ruby/ruby/blob/trunk/lib/net/http.rb#L1064
     # 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
Index: lib/drb/extservm.rb
===================================================================
--- lib/drb/extservm.rb	(revision 53110)
+++ lib/drb/extservm.rb	(revision 53111)
@@ -37,7 +37,7 @@ module DRb https://github.com/ruby/ruby/blob/trunk/lib/drb/extservm.rb#L37
       synchronize do
         while true
           server = @servers[name]
-          return server if server && server.alive?
+          return server if server&.alive?
           invoke_service(name)
           @cond.wait
         end
Index: ext/socket/lib/socket.rb
===================================================================
--- ext/socket/lib/socket.rb	(revision 53110)
+++ ext/socket/lib/socket.rb	(revision 53111)
@@ -1102,7 +1102,7 @@ class Socket < BasicSocket https://github.com/ruby/ruby/blob/trunk/ext/socket/lib/socket.rb#L1102
         st = File.lstat(path)
       rescue Errno::ENOENT
       end
-      if st && st.socket? && st.owned?
+      if st&.socket? && st.owned?
         File.unlink path
       end
     end

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]