You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avro.apache.org by "ASF GitHub Bot (JIRA)" <ji...@apache.org> on 2018/11/29 17:59:00 UTC

[jira] [Commented] (AVRO-2277) clean up Ruby warnings

    [ https://issues.apache.org/jira/browse/AVRO-2277?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16703575#comment-16703575 ] 

ASF GitHub Bot commented on AVRO-2277:
--------------------------------------

dkulp closed pull request #392: AVRO-2277: Clean up Ruby warnings
URL: https://github.com/apache/avro/pull/392
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/lang/ruby/lib/avro/io.rb b/lang/ruby/lib/avro/io.rb
index 958159c79..5961a4802 100644
--- a/lang/ruby/lib/avro/io.rb
+++ b/lang/ruby/lib/avro/io.rb
@@ -175,7 +175,6 @@ def write_int(n)
       # int and long values are written using variable-length,
       # zig-zag coding.
       def write_long(n)
-        foo = n
         n = (n << 1) ^ (n >> 63)
         while (n & ~0x7F) != 0
           @writer.write(((n & 0x7f) | 0x80).chr)
@@ -299,7 +298,7 @@ def read_array(writers_schema, readers_schema, decoder)
         while block_count != 0
           if block_count < 0
             block_count = -block_count
-            block_size = decoder.read_long
+            _block_size = decoder.read_long
           end
           block_count.times do
             read_items << read_data(writers_schema.items,
@@ -318,7 +317,7 @@ def read_map(writers_schema, readers_schema, decoder)
         while block_count != 0
           if block_count < 0
             block_count = -block_count
-            block_size = decoder.read_long
+            _block_size = decoder.read_long
           end
           block_count.times do
             key = decoder.read_string
@@ -483,7 +482,7 @@ def skip_blocks(decoder, &blk)
           if block_count < 0
             decoder.skip(decoder.read_long)
           else
-            block_count.times &blk
+            block_count.times(&blk)
           end
           block_count = decoder.read_long
         end
diff --git a/lang/ruby/lib/avro/ipc.rb b/lang/ruby/lib/avro/ipc.rb
index 03278225d..f0816e83f 100644
--- a/lang/ruby/lib/avro/ipc.rb
+++ b/lang/ruby/lib/avro/ipc.rb
@@ -5,9 +5,9 @@
 # to you under the Apache License, Version 2.0 (the
 # "License"); you may not use this file except in compliance
 # with the License.  You may obtain a copy of the License at
-# 
+#
 # http://www.apache.org/licenses/LICENSE-2.0
-# 
+#
 # Unless required by applicable law or agreed to in writing, software
 # distributed under the License is distributed on an "AS IS" BASIS,
 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -74,10 +74,10 @@ class AvroRemoteException < Avro::AvroError; end
 
   class ConnectionClosedException < Avro::AvroError; end
 
+  # Base class for the client side of a protocol interaction.
   class Requestor
-    """Base class for the client side of a protocol interaction."""
-    attr_reader :local_protocol, :transport
-    attr_accessor :remote_protocol, :remote_hash, :send_protocol
+    attr_reader :local_protocol, :transport, :remote_protocol, :remote_hash
+    attr_accessor :send_protocol
 
     def initialize(local_protocol, transport)
       @local_protocol = local_protocol
@@ -193,9 +193,9 @@ def read_call_response(message_name, decoder)
       #   * a one-byte error flag boolean, followed by either:
       #     * if the error flag is false,
       #       the message response, serialized per the message's response schema.
-      #     * if the error flag is true, 
+      #     * if the error flag is true,
       #       the error, serialized per the message's error union schema.
-      response_metadata = META_READER.read(decoder)
+      _response_metadata = META_READER.read(decoder)
 
       # remote response schema
       remote_message_schema = remote_protocol.messages[message_name]
@@ -257,7 +257,7 @@ def respond(call_request, transport=nil)
         end
 
         # read request using remote protocol
-        request_metadata = META_READER.read(buffer_decoder)
+        _request_metadata = META_READER.read(buffer_decoder)
         remote_message_name = buffer_decoder.read_string
 
         # get remote and local request schemas so we can do
diff --git a/lang/ruby/lib/avro/protocol.rb b/lang/ruby/lib/avro/protocol.rb
index 989f27021..9f509dde9 100644
--- a/lang/ruby/lib/avro/protocol.rb
+++ b/lang/ruby/lib/avro/protocol.rb
@@ -69,7 +69,6 @@ def ==(other)
 
     private
     def parse_types(types, type_names)
-      type_objects = []
       types.collect do |type|
         # FIXME adding type.name to type_names is not defined in the
         # spec. Possible bug in the python impl and the spec.
diff --git a/lang/ruby/lib/avro/schema.rb b/lang/ruby/lib/avro/schema.rb
index c1b150ead..86e5c456f 100644
--- a/lang/ruby/lib/avro/schema.rb
+++ b/lang/ruby/lib/avro/schema.rb
@@ -231,6 +231,8 @@ def initialize(name, namespace, fields, names=nil, schema_type=:record, doc=nil)
         if schema_type == :request || schema_type == 'request'
           @type_sym = schema_type.to_sym
           @namespace = namespace
+          @name = nil
+          @doc = nil
         else
           super(schema_type, name, namespace, names, doc)
         end
@@ -315,7 +317,7 @@ class EnumSchema < NamedSchema
 
       def initialize(name, space, symbols, names=nil, doc=nil)
         if symbols.uniq.length < symbols.length
-          fail_msg = 'Duplicate symbol: %s' % symbols
+          fail_msg = "Duplicate symbol: #{symbols}"
           raise Avro::SchemaParseError, fail_msg
         end
         super(:enum, name, space, names, doc)
diff --git a/lang/ruby/test/test_io.rb b/lang/ruby/test/test_io.rb
index b518708b0..350d48bc8 100644
--- a/lang/ruby/test/test_io.rb
+++ b/lang/ruby/test/test_io.rb
@@ -181,8 +181,8 @@ def test_map_with_nil
 
   def test_enum_with_duplicate
     str = '{"type": "enum", "name": "Test","symbols" : ["AA", "AA"]}'
-    assert_raises(Avro::SchemaParseError) do
-      schema = Avro::Schema.parse str
+    assert_raises(Avro::SchemaParseError.new('Duplicate symbol: ["AA", "AA"]')) do
+      Avro::Schema.parse str
     end
   end
 
@@ -289,7 +289,7 @@ def test_fixed_encoding
   end
 
   def test_skip_long
-    for value_to_skip, hex_encoding in BINARY_INT_ENCODINGS
+    for value_to_skip, _hex_encoding in BINARY_INT_ENCODINGS
       value_to_read = 6253
 
       # write some data in binary to string buffer
@@ -314,7 +314,7 @@ def test_skip_long
   end
 
   def test_skip_int
-    for value_to_skip, hex_encoding in BINARY_INT_ENCODINGS
+    for value_to_skip, _hex_encoding in BINARY_INT_ENCODINGS
       value_to_read = 6253
 
       writer = StringIO.new
@@ -364,7 +364,7 @@ def test_schema_promotion
       datum_to_write = 219
       for rs in promotable_schemas[(i + 1)..-1]
         readers_schema = Avro::Schema.parse(rs)
-        writer, enc, dw = write_datum(datum_to_write, writers_schema)
+        writer, _enc, _dw = write_datum(datum_to_write, writers_schema)
         datum_read = read_datum(writer, writers_schema, readers_schema)
         if datum_read != datum_to_write
           incorrect += 1
diff --git a/lang/ruby/test/test_logical_types.rb b/lang/ruby/test/test_logical_types.rb
index 5416e117d..529ef2970 100644
--- a/lang/ruby/test/test_logical_types.rb
+++ b/lang/ruby/test/test_logical_types.rb
@@ -34,7 +34,7 @@ def test_int_date_conversion
 
     assert_equal 5, type.encode(Date.new(1970, 1, 6))
     assert_equal 0, type.encode(Date.new(1970, 1, 1))
-    assert_equal -5, type.encode(Date.new(1969, 12, 27))
+    assert_equal(-5, type.encode(Date.new(1969, 12, 27)))
 
     assert_equal Date.new(1970, 1, 6), type.decode(5)
     assert_equal Date.new(1970, 1, 1), type.decode(0)
diff --git a/lang/ruby/test/test_schema.rb b/lang/ruby/test/test_schema.rb
index 66ea77b75..56636438d 100644
--- a/lang/ruby/test/test_schema.rb
+++ b/lang/ruby/test/test_schema.rb
@@ -274,7 +274,7 @@ def test_enum_doc_attribute
     assert_equal enum_schema_hash, enum_schema_json.to_avro
   end
 
-def test_empty_record
+  def test_empty_record
     schema = Avro::Schema.parse('{"type":"record", "name":"Empty"}')
     assert_empty(schema.fields)
   end


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


> clean up Ruby warnings
> ----------------------
>
>                 Key: AVRO-2277
>                 URL: https://issues.apache.org/jira/browse/AVRO-2277
>             Project: Apache Avro
>          Issue Type: Improvement
>          Components: ruby
>            Reporter: Tim Perkins
>            Assignee: Tim Perkins
>            Priority: Minor
>             Fix For: 1.9.0
>
>
> Running tests for the Ruby implementation generates a lot of warnings and makes it unclear that the Ruby tests are passing.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)