PROTON-1537: [ruby] Fix all -W2 warnings in self-tests

Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/f252b2ff
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/f252b2ff
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/f252b2ff

Branch: refs/heads/go1
Commit: f252b2ff7fb17783bbdf5167d542ee722cc48bbd
Parents: 1e256cf
Author: Alan Conway <[email protected]>
Authored: Thu Dec 14 14:59:29 2017 -0500
Committer: Alan Conway <[email protected]>
Committed: Fri Dec 15 09:59:47 2017 -0500

----------------------------------------------------------------------
 proton-c/bindings/ruby/lib/codec/data.rb        |  2 +-
 proton-c/bindings/ruby/lib/core/connection.rb   |  7 +-----
 proton-c/bindings/ruby/lib/core/container.rb    |  3 +++
 proton-c/bindings/ruby/lib/core/delivery.rb     | 18 ++++++++------
 proton-c/bindings/ruby/lib/core/event.rb        | 11 ++++-----
 proton-c/bindings/ruby/lib/core/sender.rb       |  6 ++---
 proton-c/bindings/ruby/lib/core/ssl.rb          |  4 ---
 proton-c/bindings/ruby/lib/core/ssl_domain.rb   | 10 +++-----
 proton-c/bindings/ruby/lib/core/terminus.rb     |  8 +++---
 proton-c/bindings/ruby/lib/core/transfer.rb     |  1 +
 proton-c/bindings/ruby/lib/core/transport.rb    | 10 ++++----
 proton-c/bindings/ruby/lib/core/url.rb          |  1 -
 .../bindings/ruby/lib/messenger/messenger.rb    | 11 ++++-----
 proton-c/bindings/ruby/lib/util/deprecation.rb  |  2 +-
 .../bindings/ruby/lib/util/error_handler.rb     | 26 +++-----------------
 15 files changed, 45 insertions(+), 75 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/f252b2ff/proton-c/bindings/ruby/lib/codec/data.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/codec/data.rb 
b/proton-c/bindings/ruby/lib/codec/data.rb
index 1573b5c..ec74756 100644
--- a/proton-c/bindings/ruby/lib/codec/data.rb
+++ b/proton-c/bindings/ruby/lib/codec/data.rb
@@ -75,7 +75,7 @@ module Qpid::Proton
         }
       end
 
-      proton_caller :clear, :rewind, :next, :prev, :enter, :exit, :type
+      proton_caller :clear, :rewind, :next, :prev, :enter, :exit
 
       def enter_exit()
         enter

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/f252b2ff/proton-c/bindings/ruby/lib/core/connection.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/core/connection.rb 
b/proton-c/bindings/ruby/lib/core/connection.rb
index 2b97f41..b9b5746 100644
--- a/proton-c/bindings/ruby/lib/core/connection.rb
+++ b/proton-c/bindings/ruby/lib/core/connection.rb
@@ -146,11 +146,6 @@ module Qpid::Proton
       end
     end
 
-    # @private Generate a unique link name, internal use only.
-    def link_name()
-      @link_prefix + "/" +  (@link_count += 1).to_s(16)
-    end
-
     # Closes the local end of the connection. The remote end may or may not be 
closed.
     # @param error [Condition] Optional error condition to send with the close.
     def close(error=nil)
@@ -259,7 +254,7 @@ module Qpid::Proton
 
     # @private Generate a unique link name, internal use only.
     def link_name()
-      @link_prefix + "/" +  (@link_count += 1).to_s(16)
+      @link_prefix + "/" +  (@link_count += 1).to_s(32)
     end
 
     protected

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/f252b2ff/proton-c/bindings/ruby/lib/core/container.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/core/container.rb 
b/proton-c/bindings/ruby/lib/core/container.rb
index f8c8c16..242356f 100644
--- a/proton-c/bindings/ruby/lib/core/container.rb
+++ b/proton-c/bindings/ruby/lib/core/container.rb
@@ -45,9 +45,12 @@ module Qpid::Proton
 
       def initialize(io, handler, container)
         super
+        @closing = @closed = nil
         env = ENV['PN_TRACE_EVT']
         if env && ["true", "1", "yes", "on"].include?(env.downcase)
           @log_prefix = "[0x#{object_id.to_s(16)}](PN_LISTENER_"
+        else
+          @log_prefix = nil
         end
         dispatch(:on_open);
       end

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/f252b2ff/proton-c/bindings/ruby/lib/core/delivery.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/core/delivery.rb 
b/proton-c/bindings/ruby/lib/core/delivery.rb
index fd5c43a..cedce98 100644
--- a/proton-c/bindings/ruby/lib/core/delivery.rb
+++ b/proton-c/bindings/ruby/lib/core/delivery.rb
@@ -18,6 +18,8 @@
 module Qpid::Proton
   # Allow a {Receiver} to indicate the status of a received message to the 
{Sender}
   class Delivery < Transfer
+    def initialize(*args) super; @message = nil; end
+
     # @return [Receiver] The parent {Receiver} link.
     def receiver() link; end
 
@@ -80,15 +82,15 @@ module Qpid::Proton
     # @raise [UnderflowError] if the message is incomplete (check with 
{#complete?}
     # @raise [::ArgumentError] if the delivery is not the current delivery on 
a receiving link.
     def message
-      return @message if @message
-      raise AbortedError, "message aborted by sender" if aborted?
-      raise UnderflowError, "incoming message incomplete" if partial?
-      raise ArgumentError, "no incoming message" unless readable?
-      @message = Message.new
-      @message.decode(link.receive(pending))
-      link.advance
+      unless @message
+        raise AbortedError, "message aborted by sender" if aborted?
+        raise UnderflowError, "incoming message incomplete" if partial?
+        raise ArgumentError, "no incoming message" unless readable?
+        @message = Message.new
+        @message.decode(link.receive(pending))
+        link.advance
+      end
       @message
     end
-
   end
 end

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/f252b2ff/proton-c/bindings/ruby/lib/core/event.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/core/event.rb 
b/proton-c/bindings/ruby/lib/core/event.rb
index ee0fc02..d75cfff 100644
--- a/proton-c/bindings/ruby/lib/core/event.rb
+++ b/proton-c/bindings/ruby/lib/core/event.rb
@@ -125,12 +125,11 @@ module Qpid::Proton
 
     # @return [Delivery, nil] delivery for this event
     def delivery()
-      return @delivery if @delivery
-      case context
-      when Delivery then @delivery = @context
-      # deprecated: for backwards compat allow a Tracker to be treated as a 
Delivery
-      when Tracker then @delivery = Delivery.new(context.impl)
-      end
+      @delivery ||= case context
+                    when Delivery then @delivery = @context
+                      # deprecated: for backwards compat allow a Tracker to be 
treated as a Delivery
+                    when Tracker then @delivery = Delivery.new(context.impl)
+                    end
     end
 
     # @return [Tracker, nil] delivery for this event

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/f252b2ff/proton-c/bindings/ruby/lib/core/sender.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/core/sender.rb 
b/proton-c/bindings/ruby/lib/core/sender.rb
index 4c7324c..c1ba1f8 100644
--- a/proton-c/bindings/ruby/lib/core/sender.rb
+++ b/proton-c/bindings/ruby/lib/core/sender.rb
@@ -27,9 +27,6 @@ module Qpid::Proton
     # @private
     include Util::ErrorHandler
 
-    # @private
-    can_raise_error :stream, :error_class => Qpid::Proton::LinkError
-
     # Hint to the remote receiver about the number of messages available.
     # The receiver may use this to optimize credit flow, or may ignore it.
     # @param n [Integer] The number of deliveries potentially available.
@@ -71,6 +68,9 @@ module Qpid::Proton
 
     def initialize(*arg) super; @tag_count = 0; end
     def next_tag() (@tag_count += 1).to_s(32); end
+
+    # @private
+    can_raise_error :stream, :error_class => Qpid::Proton::LinkError
   end
 end
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/f252b2ff/proton-c/bindings/ruby/lib/core/ssl.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/core/ssl.rb 
b/proton-c/bindings/ruby/lib/core/ssl.rb
index ec4f14d..bc4460a 100644
--- a/proton-c/bindings/ruby/lib/core/ssl.rb
+++ b/proton-c/bindings/ruby/lib/core/ssl.rb
@@ -66,8 +66,6 @@ module Qpid::Proton
     # @private
     include Util::ErrorHandler
 
-    can_raise_error :peer_hostname=, :error_class => SSLError
-
     # Returns whether SSL is supported.
     #
     # @return [Boolean] True if SSL support is available.
@@ -155,7 +153,5 @@ module Qpid::Proton
       raise SSLError.new if error < 0
       return name
     end
-
   end
-
 end

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/f252b2ff/proton-c/bindings/ruby/lib/core/ssl_domain.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/core/ssl_domain.rb 
b/proton-c/bindings/ruby/lib/core/ssl_domain.rb
index 2a3940d..31a472f 100644
--- a/proton-c/bindings/ruby/lib/core/ssl_domain.rb
+++ b/proton-c/bindings/ruby/lib/core/ssl_domain.rb
@@ -42,11 +42,6 @@ module Qpid::Proton
     # @private
     include Util::ErrorHandler
 
-    can_raise_error :credentials, :error_class => Qpid::Proton::SSLError
-    can_raise_error :trusted_ca_db, :error_class => Qpid::Proton::SSLError
-    can_raise_error :peer_authentication, :error_class => 
Qpid::Proton::SSLError
-    can_raise_error :allow_unsecured_client, :error_class => 
Qpid::Proton::SSLError
-
     # @private
     attr_reader :impl
 
@@ -150,6 +145,9 @@ module Qpid::Proton
       Cproton.pn_ssl_domain_allow_unsecured_client(@impl);
     end
 
+    can_raise_error :credentials, :error_class => Qpid::Proton::SSLError
+    can_raise_error :trusted_ca_db, :error_class => Qpid::Proton::SSLError
+    can_raise_error :peer_authentication, :error_class => 
Qpid::Proton::SSLError
+    can_raise_error :allow_unsecured_client, :error_class => 
Qpid::Proton::SSLError
   end
-
 end

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/f252b2ff/proton-c/bindings/ruby/lib/core/terminus.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/core/terminus.rb 
b/proton-c/bindings/ruby/lib/core/terminus.rb
index 82ac9f7..d3181db 100644
--- a/proton-c/bindings/ruby/lib/core/terminus.rb
+++ b/proton-c/bindings/ruby/lib/core/terminus.rb
@@ -131,10 +131,6 @@ module Qpid::Proton
     # @private
     include Util::ErrorHandler
 
-    can_raise_error [:type=, :address=, :durability=, :expiry_policy=,
-                          :timeout=, :dynamic=, :distribution_mode=, :copy],
-                    :error_class => Qpid::Proton::LinkError
-
     # @private
     attr_reader :impl
 
@@ -211,6 +207,8 @@ module Qpid::Proton
       Cproton.pn_terminus_copy(@impl,source.impl)
     end
 
+    can_raise_error([:type=, :address=, :durability=, :expiry_policy=,
+                     :timeout=, :dynamic=, :distribution_mode=, :copy],
+                    :error_class => Qpid::Proton::LinkError)
   end
-
 end

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/f252b2ff/proton-c/bindings/ruby/lib/core/transfer.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/core/transfer.rb 
b/proton-c/bindings/ruby/lib/core/transfer.rb
index 17f3b82..4fc21a9 100644
--- a/proton-c/bindings/ruby/lib/core/transfer.rb
+++ b/proton-c/bindings/ruby/lib/core/transfer.rb
@@ -36,6 +36,7 @@ module Qpid::Proton
 
     def initialize(impl)
       @impl = impl
+      @inspect = nil
       self.class.store_instance(self, :pn_delivery_attachments)
     end
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/f252b2ff/proton-c/bindings/ruby/lib/core/transport.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/core/transport.rb 
b/proton-c/bindings/ruby/lib/core/transport.rb
index 64a8011..9b36335 100644
--- a/proton-c/bindings/ruby/lib/core/transport.rb
+++ b/proton-c/bindings/ruby/lib/core/transport.rb
@@ -201,11 +201,6 @@ module Qpid::Proton
     # @private
     include Util::ErrorHandler
 
-    can_raise_error :process, :error_class => TransportError
-    can_raise_error :close_tail, :error_class => TransportError
-    can_raise_error :pending, :error_class => TransportError, :below => 
Error::EOS
-    can_raise_error :close_head, :error_class => TransportError
-
     # @private
     def self.wrap(impl)
       return nil if impl.nil?
@@ -413,5 +408,10 @@ module Qpid::Proton
       # Direct use of the transport is deprecated.
       self.idle_timeout= (opts[:idle_timeout]*1000).round if opts.include? 
:idle_timeout
     end
+
+    can_raise_error :process, :error_class => TransportError
+    can_raise_error :close_tail, :error_class => TransportError
+    can_raise_error :pending, :error_class => TransportError, :below => 
Error::EOS
+    can_raise_error :close_head, :error_class => TransportError
   end
 end

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/f252b2ff/proton-c/bindings/ruby/lib/core/url.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/core/url.rb 
b/proton-c/bindings/ruby/lib/core/url.rb
index 1103e06..4fa59b6 100644
--- a/proton-c/bindings/ruby/lib/core/url.rb
+++ b/proton-c/bindings/ruby/lib/core/url.rb
@@ -27,7 +27,6 @@ module Qpid::Proton
     alias user username
     attr_reader :password
     attr_reader :host
-    attr_reader :port
     attr_reader :path
 
     # Parse a string, return a new URL

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/f252b2ff/proton-c/bindings/ruby/lib/messenger/messenger.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/messenger/messenger.rb 
b/proton-c/bindings/ruby/lib/messenger/messenger.rb
index 7b992e2..912d159 100644
--- a/proton-c/bindings/ruby/lib/messenger/messenger.rb
+++ b/proton-c/bindings/ruby/lib/messenger/messenger.rb
@@ -58,11 +58,6 @@ module Qpid::Proton::Messenger
     include Qpid::Proton::Util::ErrorHandler
     include Qpid::Proton::Util::Deprecation
 
-    can_raise_error [:send, :receive, :password=, :start, :stop,
-                     :perform_put, :perform_get, :interrupt,
-                     :route, :rewrite, :accept, :reject,
-                     :incoming_window=, :outgoing_window=]
-
     # Creates a new +Messenger+.
     #
     # The +name+ parameter is optional. If one is not provided then
@@ -699,6 +694,10 @@ module Qpid::Proton::Messenger
       !window.nil? && window.is_a?(Numeric)
     end
 
-  end
+    can_raise_error [:send, :receive, :password=, :start, :stop,
+                     :perform_put, :perform_get, :interrupt,
+                     :route, :rewrite, :accept, :reject,
+                     :incoming_window=, :outgoing_window=]
 
+  end
 end

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/f252b2ff/proton-c/bindings/ruby/lib/util/deprecation.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/util/deprecation.rb 
b/proton-c/bindings/ruby/lib/util/deprecation.rb
index 8e96cd6..d9d0563 100644
--- a/proton-c/bindings/ruby/lib/util/deprecation.rb
+++ b/proton-c/bindings/ruby/lib/util/deprecation.rb
@@ -39,7 +39,7 @@ module Qpid::Proton::Util
     end
 
     def self.included(other)
-      other.__send__ :extend, ClassMethods
+      other.extend ClassMethods
     end
   end
 end

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/f252b2ff/proton-c/bindings/ruby/lib/util/error_handler.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/util/error_handler.rb 
b/proton-c/bindings/ruby/lib/util/error_handler.rb
index 58545fb..9280fb0 100644
--- a/proton-c/bindings/ruby/lib/util/error_handler.rb
+++ b/proton-c/bindings/ruby/lib/util/error_handler.rb
@@ -23,35 +23,15 @@ module Qpid::Proton::Util
   # @private
   module ErrorHandler
 
-    def self.included(base)
-      base.extend(self)
-
-      unless defined? base.to_be_wrapped
-        class << base
-          @@to_be_wrapped = []
-        end
-      end
-
-      define_method :method_added do |name|
-        if (!@@to_be_wrapped.nil?) && (@@to_be_wrapped.include? name)
-          @@to_be_wrapped.delete name
-          create_exception_handler_wrapper(name)
-        end
-      end
-    end
+    def self.included(other) other.extend(self); end
 
     def can_raise_error(method_names, options = {})
       error_class = options[:error_class]
       below = options[:below] || 0
       # coerce the names to be an array
       Array(method_names).each do |method_name|
-        # if the method doesn't already exist then queue this aliasing
-        unless self.method_defined? method_name
-          @@to_be_wrapped ||= []
-          @@to_be_wrapped << method_name
-        else
-          create_exception_handler_wrapper(method_name, error_class, below)
-        end
+        raise "missing method #{method_name.inspect}" unless 
method_defined?(method_name) || private_method_defined?(method_name)
+        create_exception_handler_wrapper(method_name, error_class, below)
       end
     end
 


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to