Enforce consistent whitespaces around blocks, equal signs, and in parameters in Ruby code
diff --git a/lib/rb/.rubocop.yml b/lib/rb/.rubocop.yml
index c7eb04f..099bf35 100644
--- a/lib/rb/.rubocop.yml
+++ b/lib/rb/.rubocop.yml
@@ -9,15 +9,33 @@
Exclude:
- "**/vendor/**/*"
-Layout/IndentationConsistency:
- Enabled: true
-
Layout/EmptyLines:
Enabled: true
+Layout/EmptyLinesAroundBlockBody:
+ Enabled: true
+
+Layout/ExtraSpacing:
+ Enabled: true
+
+Layout/IndentationConsistency:
+ Enabled: true
+
+Layout/LeadingCommentSpace:
+ Enabled: true
+
Layout/LeadingEmptyLines:
Enabled: true
+Layout/SpaceAfterComma:
+ Enabled: true
+
+Layout/SpaceAroundEqualsInParameterDefault:
+ Enabled: true
+
+Layout/SpaceInsideBlockBraces:
+ Enabled: true
+
Layout/TrailingEmptyLines:
Enabled: true
diff --git a/lib/rb/Rakefile b/lib/rb/Rakefile
index d1f0f7c..fab0f3c 100644
--- a/lib/rb/Rakefile
+++ b/lib/rb/Rakefile
@@ -135,5 +135,5 @@
CLEAN.include [
'.bundle', 'benchmark/gen-rb', 'coverage', 'ext/*.{o,bundle,so,dll}', 'ext/mkmf.log',
'ext/Makefile', 'ext/conftest.dSYM', 'ext/thrift_native.bundle.dSYM', 'mkmf.log',
- 'pkg', 'spec/gen-rb', 'test/debug_proto/gen-rb', 'thrift-*.gem'
+ 'pkg', 'spec/gen-rb', 'test/debug_proto/gen-rb', 'thrift-*.gem'
]
diff --git a/lib/rb/benchmark/benchmark.rb b/lib/rb/benchmark/benchmark.rb
index 0111ee8..c6adbc9 100644
--- a/lib/rb/benchmark/benchmark.rb
+++ b/lib/rb/benchmark/benchmark.rb
@@ -116,7 +116,7 @@
def collect_output
puts "Collecting output..."
# read from @pool until all sockets are closed
- @buffers = Hash.new { |h,k| h[k] = '' }
+ @buffers = Hash.new { |h, k| h[k] = '' }
until @pool.empty?
rd, = select(@pool)
next if rd.nil?
@@ -184,9 +184,9 @@
end
end
@report = {}
- @report[:total_calls] = call_times.inject(0.0) { |a,t| a += t }
+ @report[:total_calls] = call_times.inject(0.0) { |a, t| a += t }
@report[:avg_calls] = @report[:total_calls] / call_times.size
- @report[:total_clients] = client_times.inject(0.0) { |a,t| a += t }
+ @report[:total_clients] = client_times.inject(0.0) { |a, t| a += t }
@report[:avg_clients] = @report[:total_clients] / client_times.size
@report[:connection_failures] = connection_failures.size
@report[:connection_errors] = connection_errors.size
@@ -241,8 +241,8 @@
def tabulate(fmt, *labels_and_values)
labels = labels_and_values.map { |l| Array === l ? l.first : l }
- label_width = labels.inject(0) { |w,l| l.size > w ? l.size : w }
- labels_and_values.each do |(l,v)|
+ label_width = labels.inject(0) { |w, l| l.size > w ? l.size : w }
+ labels_and_values.each do |(l, v)|
f = fmt
l, f, c = l if Array === l
fmtstr = "%-#{label_width+1}s #{f}"
@@ -255,7 +255,7 @@
end
def resolve_const(const)
- const and const.split('::').inject(Object) { |k,c| k.const_get(c) }
+ const and const.split('::').inject(Object) { |k, c| k.const_get(c) }
end
puts "Starting server..."
diff --git a/lib/rb/benchmark/server.rb b/lib/rb/benchmark/server.rb
index 6df3fa9..45f2864 100644
--- a/lib/rb/benchmark/server.rb
+++ b/lib/rb/benchmark/server.rb
@@ -101,7 +101,7 @@
end
def resolve_const(const)
- const and const.split('::').inject(Object) { |k,c| k.const_get(c) }
+ const and const.split('::').inject(Object) { |k, c| k.const_get(c) }
end
tls = true if ARGV[0] == '-tls' and ARGV.shift
diff --git a/lib/rb/ext/extconf.rb b/lib/rb/ext/extconf.rb
index 91464cc..50ae7df 100644
--- a/lib/rb/ext/extconf.rb
+++ b/lib/rb/ext/extconf.rb
@@ -18,7 +18,7 @@
#
if defined?(RUBY_ENGINE) && RUBY_ENGINE =~ /jruby/
- File.open('Makefile', 'w'){|f| f.puts "all:\n\ninstall:\n" }
+ File.open('Makefile', 'w'){ |f| f.puts "all:\n\ninstall:\n" }
else
require 'mkmf'
diff --git a/lib/rb/lib/thrift/client.rb b/lib/rb/lib/thrift/client.rb
index 5c7cd98..27de43b 100644
--- a/lib/rb/lib/thrift/client.rb
+++ b/lib/rb/lib/thrift/client.rb
@@ -19,7 +19,7 @@
module Thrift
module Client
- def initialize(iprot, oprot=nil)
+ def initialize(iprot, oprot = nil)
@iprot = iprot
@oprot = oprot || iprot
@seqid = 0
diff --git a/lib/rb/lib/thrift/exceptions.rb b/lib/rb/lib/thrift/exceptions.rb
index 76d93ff..433ec52 100644
--- a/lib/rb/lib/thrift/exceptions.rb
+++ b/lib/rb/lib/thrift/exceptions.rb
@@ -43,7 +43,7 @@
attr_reader :type
- def initialize(type=UNKNOWN, message=nil)
+ def initialize(type = UNKNOWN, message = nil)
super(message)
@type = type
end
diff --git a/lib/rb/lib/thrift/processor.rb b/lib/rb/lib/thrift/processor.rb
index e4c827a..0e1fb9d 100644
--- a/lib/rb/lib/thrift/processor.rb
+++ b/lib/rb/lib/thrift/processor.rb
@@ -21,7 +21,7 @@
module Thrift
module Processor
- def initialize(handler, logger=nil)
+ def initialize(handler, logger = nil)
@handler = handler
if logger.nil?
@logger = Logger.new(STDERR)
@@ -32,7 +32,7 @@
end
def process(iprot, oprot)
- name, type, seqid = iprot.read_message_begin
+ name, type, seqid = iprot.read_message_begin
if respond_to?("process_#{name}")
begin
send("process_#{name}", seqid, iprot, oprot)
diff --git a/lib/rb/lib/thrift/protocol/base_protocol.rb b/lib/rb/lib/thrift/protocol/base_protocol.rb
index f2ee8dd..d69c2a5 100644
--- a/lib/rb/lib/thrift/protocol/base_protocol.rb
+++ b/lib/rb/lib/thrift/protocol/base_protocol.rb
@@ -33,7 +33,7 @@
attr_reader :type
- def initialize(type=UNKNOWN, message=nil)
+ def initialize(type = UNKNOWN, message = nil)
super(message)
@type = type
end
diff --git a/lib/rb/lib/thrift/protocol/binary_protocol.rb b/lib/rb/lib/thrift/protocol/binary_protocol.rb
index ace763c..5bb4902 100644
--- a/lib/rb/lib/thrift/protocol/binary_protocol.rb
+++ b/lib/rb/lib/thrift/protocol/binary_protocol.rb
@@ -25,7 +25,7 @@
attr_reader :strict_read, :strict_write
- def initialize(trans, strict_read=true, strict_write=true)
+ def initialize(trans, strict_read = true, strict_write = true)
super(trans)
@strict_read = strict_read
@strict_write = strict_write
diff --git a/lib/rb/lib/thrift/protocol/compact_protocol.rb b/lib/rb/lib/thrift/protocol/compact_protocol.rb
index 36b5538..56069ef 100644
--- a/lib/rb/lib/thrift/protocol/compact_protocol.rb
+++ b/lib/rb/lib/thrift/protocol/compact_protocol.rb
@@ -140,7 +140,7 @@
# 'type override' of the type header. This is used specifically in the
# boolean field case.
#
- def write_field_begin_internal(type, id, type_override=nil)
+ def write_field_begin_internal(type, id, type_override = nil)
last_id = @last_field.pop
# if there's a type override, use that.
@@ -399,7 +399,7 @@
def write_varint64(n)
while true
- if (n & EVERYTHING_ELSE_MASK) == 0 #TODO need to find a way to make this into a long...
+ if (n & EVERYTHING_ELSE_MASK) == 0 # TODO need to find a way to make this into a long...
write_byte(n)
break
else
diff --git a/lib/rb/lib/thrift/protocol/json_protocol.rb b/lib/rb/lib/thrift/protocol/json_protocol.rb
index 84f7fc8..1e47e9f 100644
--- a/lib/rb/lib/thrift/protocol/json_protocol.rb
+++ b/lib/rb/lib/thrift/protocol/json_protocol.rb
@@ -257,7 +257,7 @@
if (ch_value.kind_of? String)
ch_value = ch.bytes.first
end
- trans.write(ch_value.to_s(16).rjust(4,'0'))
+ trans.write(ch_value.to_s(16).rjust(4, '0'))
end
# Write the character ch as part of a JSON string, escaping as appropriate.
@@ -268,9 +268,9 @@
# <other> : escape using "\<other>" notation
kJSONCharTable = [
# 0 1 2 3 4 5 6 7 8 9 A B C D E F
- 0, 0, 0, 0, 0, 0, 0, 0,'b','t','n', 0,'f','r', 0, 0, # 0
+ 0, 0, 0, 0, 0, 0, 0, 0, 'b', 't', 'n', 0, 'f', 'r', 0, 0, # 0
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, # 1
- 1, 1,'"', 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, # 2
+ 1, 1, '"', 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, # 2
]
ch_value = ch[0]
diff --git a/lib/rb/lib/thrift/server/base_server.rb b/lib/rb/lib/thrift/server/base_server.rb
index 238d9d7..6e48c88 100644
--- a/lib/rb/lib/thrift/server/base_server.rb
+++ b/lib/rb/lib/thrift/server/base_server.rb
@@ -19,7 +19,7 @@
module Thrift
class BaseServer
- def initialize(processor, server_transport, transport_factory=nil, protocol_factory=nil)
+ def initialize(processor, server_transport, transport_factory = nil, protocol_factory = nil)
@processor = processor
@server_transport = server_transport
@transport_factory = transport_factory ? transport_factory : Thrift::BaseTransportFactory.new
diff --git a/lib/rb/lib/thrift/server/mongrel_http_server.rb b/lib/rb/lib/thrift/server/mongrel_http_server.rb
index 0b3832c..785b7b8 100644
--- a/lib/rb/lib/thrift/server/mongrel_http_server.rb
+++ b/lib/rb/lib/thrift/server/mongrel_http_server.rb
@@ -38,12 +38,12 @@
@processor.process protocol, protocol
end
else
- response.start(404) { }
+ response.start(404) {}
end
end
end
- def initialize(processor, opts={})
+ def initialize(processor, opts = {})
Kernel.warn "[DEPRECATION WARNING] `Thrift::MongrelHTTPServer` is deprecated. Please use `Thrift::ThinHTTPServer` instead."
port = opts[:port] || 80
ip = opts[:ip] || "0.0.0.0"
diff --git a/lib/rb/lib/thrift/server/nonblocking_server.rb b/lib/rb/lib/thrift/server/nonblocking_server.rb
index 4c2769f..f2959f2 100644
--- a/lib/rb/lib/thrift/server/nonblocking_server.rb
+++ b/lib/rb/lib/thrift/server/nonblocking_server.rb
@@ -23,7 +23,7 @@
module Thrift
# this class expects to always use a FramedTransport for reading messages
class NonblockingServer < BaseServer
- def initialize(processor, server_transport, transport_factory=nil, protocol_factory=nil, num=20, logger=nil)
+ def initialize(processor, server_transport, transport_factory = nil, protocol_factory = nil, num = 20, logger = nil)
super(processor, server_transport, transport_factory, protocol_factory)
@num_threads = num
if logger.nil?
@@ -106,7 +106,7 @@
@num_threads = num
@logger = logger
@connections = []
- @buffers = Hash.new { |h,k| h[k] = '' }
+ @buffers = Hash.new { |h, k| h[k] = '' }
@signal_queue = Queue.new
@signal_pipes = IO.pipe
@signal_pipes[1].sync = true
diff --git a/lib/rb/lib/thrift/server/thin_http_server.rb b/lib/rb/lib/thrift/server/thin_http_server.rb
index bbd1175..9cfad90 100644
--- a/lib/rb/lib/thrift/server/thin_http_server.rb
+++ b/lib/rb/lib/thrift/server/thin_http_server.rb
@@ -32,7 +32,7 @@
# * :ip
# * :path
# * :protocol_factory
- def initialize(processor, options={})
+ def initialize(processor, options = {})
port = options[:port] || 80
ip = options[:ip] || "0.0.0.0"
path = options[:path] || "/"
diff --git a/lib/rb/lib/thrift/server/thread_pool_server.rb b/lib/rb/lib/thrift/server/thread_pool_server.rb
index 97e12e1..0f9e226 100644
--- a/lib/rb/lib/thrift/server/thread_pool_server.rb
+++ b/lib/rb/lib/thrift/server/thread_pool_server.rb
@@ -21,7 +21,7 @@
module Thrift
class ThreadPoolServer < BaseServer
- def initialize(processor, server_transport, transport_factory=nil, protocol_factory=nil, num=20)
+ def initialize(processor, server_transport, transport_factory = nil, protocol_factory = nil, num = 20)
super(processor, server_transport, transport_factory, protocol_factory)
@thread_q = SizedQueue.new(num)
@exception_q = Queue.new
diff --git a/lib/rb/lib/thrift/struct.rb b/lib/rb/lib/thrift/struct.rb
index e353df4..80ba21b 100644
--- a/lib/rb/lib/thrift/struct.rb
+++ b/lib/rb/lib/thrift/struct.rb
@@ -21,7 +21,7 @@
module Thrift
module Struct
- def initialize(d={}, &block)
+ def initialize(d = {}, &block)
# get a copy of the default values to work on, removing defaults in favor of arguments
fields_with_defaults = fields_with_default_values.dup
diff --git a/lib/rb/lib/thrift/transport/base_transport.rb b/lib/rb/lib/thrift/transport/base_transport.rb
index 891b10e..5c4b0e8 100644
--- a/lib/rb/lib/thrift/transport/base_transport.rb
+++ b/lib/rb/lib/thrift/transport/base_transport.rb
@@ -28,7 +28,7 @@
attr_reader :type
- def initialize(type=UNKNOWN, message=nil)
+ def initialize(type = UNKNOWN, message = nil)
super(message)
@type = type
end
diff --git a/lib/rb/lib/thrift/transport/framed_transport.rb b/lib/rb/lib/thrift/transport/framed_transport.rb
index 74b664d..20493f6 100644
--- a/lib/rb/lib/thrift/transport/framed_transport.rb
+++ b/lib/rb/lib/thrift/transport/framed_transport.rb
@@ -20,13 +20,13 @@
module Thrift
class FramedTransport < BaseTransport
- def initialize(transport, read=true, write=true)
+ def initialize(transport, read = true, write = true)
@transport = transport
@rbuf = Bytes.empty_byte_buffer
@wbuf = Bytes.empty_byte_buffer
@read = read
@write = write
- @index = 0
+ @index = 0
end
def open?
@@ -77,7 +77,7 @@
i
end
- def write(buf, sz=nil)
+ def write(buf, sz = nil)
return @transport.write(buf) unless @write
buf = Bytes.force_binary_encoding(buf)
diff --git a/lib/rb/lib/thrift/transport/socket.rb b/lib/rb/lib/thrift/transport/socket.rb
index 05fc4c0..6587e44 100644
--- a/lib/rb/lib/thrift/transport/socket.rb
+++ b/lib/rb/lib/thrift/transport/socket.rb
@@ -22,7 +22,7 @@
module Thrift
class Socket < BaseTransport
- def initialize(host='localhost', port=9090, timeout=nil)
+ def initialize(host = 'localhost', port = 9090, timeout = nil)
@host = host
@port = port
@timeout = timeout
diff --git a/lib/rb/lib/thrift/transport/ssl_socket.rb b/lib/rb/lib/thrift/transport/ssl_socket.rb
index e71f297..11e9898 100644
--- a/lib/rb/lib/thrift/transport/ssl_socket.rb
+++ b/lib/rb/lib/thrift/transport/ssl_socket.rb
@@ -19,7 +19,7 @@
module Thrift
class SSLSocket < Socket
- def initialize(host='localhost', port=9090, timeout=nil, ssl_context=nil)
+ def initialize(host = 'localhost', port = 9090, timeout = nil, ssl_context = nil)
super(host, port, timeout)
@ssl_context = ssl_context
end
diff --git a/lib/rb/lib/thrift/transport/unix_socket.rb b/lib/rb/lib/thrift/transport/unix_socket.rb
index 76a7bad..6306f11 100644
--- a/lib/rb/lib/thrift/transport/unix_socket.rb
+++ b/lib/rb/lib/thrift/transport/unix_socket.rb
@@ -22,7 +22,7 @@
module Thrift
class UNIXSocket < Socket
- def initialize(path, timeout=nil)
+ def initialize(path, timeout = nil)
@path = path
@timeout = timeout
@desc = @path # for read()'s error
diff --git a/lib/rb/lib/thrift/types.rb b/lib/rb/lib/thrift/types.rb
index 4cec159..529c352 100644
--- a/lib/rb/lib/thrift/types.rb
+++ b/lib/rb/lib/thrift/types.rb
@@ -44,7 +44,7 @@
class TypeError < Exception
end
- def self.check_type(value, field, name, skip_nil=true)
+ def self.check_type(value, field, name, skip_nil = true)
return if value.nil? and skip_nil
klasses = case field[:type]
when Types::VOID
@@ -73,7 +73,7 @@
# check elements now
case field[:type]
when Types::MAP
- value.each_pair do |k,v|
+ value.each_pair do |k, v|
check_type(k, field[:key], "#{name}.key", false)
check_type(v, field[:value], "#{name}.value", false)
end
diff --git a/lib/rb/lib/thrift/union.rb b/lib/rb/lib/thrift/union.rb
index 82af636..471cc82 100644
--- a/lib/rb/lib/thrift/union.rb
+++ b/lib/rb/lib/thrift/union.rb
@@ -19,7 +19,7 @@
module Thrift
class Union
- def initialize(name=nil, value=nil)
+ def initialize(name = nil, value = nil)
if name
if name.is_a? Hash
if name.size > 1
diff --git a/lib/rb/script/proto_benchmark.rb b/lib/rb/script/proto_benchmark.rb
index f1c90d2..bcc5094 100644
--- a/lib/rb/script/proto_benchmark.rb
+++ b/lib/rb/script/proto_benchmark.rb
@@ -116,5 +116,4 @@
# end
# end
# f.close
-
end
diff --git a/lib/rb/spec/base_protocol_spec.rb b/lib/rb/spec/base_protocol_spec.rb
index cfa7573..b259bb0 100644
--- a/lib/rb/spec/base_protocol_spec.rb
+++ b/lib/rb/spec/base_protocol_spec.rb
@@ -20,7 +20,6 @@
require 'spec_helper'
describe 'BaseProtocol' do
-
before(:each) do
@trans = double("MockTransport")
@prot = Thrift::BaseProtocol.new(@trans)
@@ -215,7 +214,7 @@
describe Thrift::BaseProtocolFactory do
it "should raise NotImplementedError" do
# returning nil since Protocol is just an abstract class
- expect {Thrift::BaseProtocolFactory.new.get_protocol(double("MockTransport"))}.to raise_error(NotImplementedError)
+ expect { Thrift::BaseProtocolFactory.new.get_protocol(double("MockTransport")) }.to raise_error(NotImplementedError)
end
it "should provide a reasonable to_s" do
diff --git a/lib/rb/spec/base_transport_spec.rb b/lib/rb/spec/base_transport_spec.rb
index d09ba2b..9182dc1 100644
--- a/lib/rb/spec/base_transport_spec.rb
+++ b/lib/rb/spec/base_transport_spec.rb
@@ -20,7 +20,6 @@
require 'spec_helper'
describe 'BaseTransport' do
-
describe Thrift::TransportException do
it "should make type accessible" do
exc = Thrift::TransportException.new(Thrift::TransportException::ALREADY_OPEN, "msg")
@@ -341,10 +340,10 @@
it "should throw an EOFError when there isn't enough data in the buffer" do
@buffer.reset_buffer("")
- expect{@buffer.read(1)}.to raise_error(EOFError)
+ expect{ @buffer.read(1) }.to raise_error(EOFError)
@buffer.reset_buffer("1234")
- expect{@buffer.read(5)}.to raise_error(EOFError)
+ expect{ @buffer.read(5) }.to raise_error(EOFError)
end
end
diff --git a/lib/rb/spec/binary_protocol_spec.rb b/lib/rb/spec/binary_protocol_spec.rb
index 065f5ce..8607290 100644
--- a/lib/rb/spec/binary_protocol_spec.rb
+++ b/lib/rb/spec/binary_protocol_spec.rb
@@ -21,7 +21,6 @@
require File.expand_path("#{File.dirname(__FILE__)}/binary_protocol_spec_shared")
describe 'BinaryProtocol' do
-
it_should_behave_like 'a binary protocol'
def protocol_class
@@ -29,7 +28,6 @@
end
describe Thrift::BinaryProtocol do
-
before(:each) do
@trans = Thrift::MemoryBufferTransport.new
@prot = protocol_class.new(@trans)
diff --git a/lib/rb/spec/binary_protocol_spec_shared.rb b/lib/rb/spec/binary_protocol_spec_shared.rb
index 8de39ef..bd73d1f 100644
--- a/lib/rb/spec/binary_protocol_spec_shared.rb
+++ b/lib/rb/spec/binary_protocol_spec_shared.rb
@@ -185,7 +185,7 @@
it "should write a double" do
# try a random scattering of values, including min/max
- values = [Float::MIN,-1231.15325, -123123.23, -23.23515123, 0, 12351.1325, 523.23, Float::MAX]
+ values = [Float::MIN, -1231.15325, -123123.23, -23.23515123, 0, 12351.1325, 523.23, Float::MAX]
values.each do |f|
@prot.write_double(f)
expect(@trans.read(@trans.available)).to eq([f].pack("G"))
@@ -373,22 +373,22 @@
it "should perform a complete rpc with no args or return" do
srv_test(
- proc {|client| client.send_voidMethod()},
- proc {|client| expect(client.recv_voidMethod).to eq(nil)}
+ proc { |client| client.send_voidMethod() },
+ proc { |client| expect(client.recv_voidMethod).to eq(nil) }
)
end
it "should perform a complete rpc with a primitive return type" do
srv_test(
- proc {|client| client.send_primitiveMethod()},
- proc {|client| expect(client.recv_primitiveMethod).to eq(1)}
+ proc { |client| client.send_primitiveMethod() },
+ proc { |client| expect(client.recv_primitiveMethod).to eq(1) }
)
end
it "should perform a complete rpc with a struct return type" do
srv_test(
- proc {|client| client.send_structMethod()},
- proc {|client|
+ proc { |client| client.send_structMethod() },
+ proc { |client|
result = client.recv_structMethod
result.set_byte_map = nil
result.map_byte_map = nil
diff --git a/lib/rb/spec/client_spec.rb b/lib/rb/spec/client_spec.rb
index f015d66..8650350 100644
--- a/lib/rb/spec/client_spec.rb
+++ b/lib/rb/spec/client_spec.rb
@@ -20,7 +20,6 @@
require 'spec_helper'
describe 'Client' do
-
class ClientSpec
include Thrift::Client
end
diff --git a/lib/rb/spec/compact_protocol_spec.rb b/lib/rb/spec/compact_protocol_spec.rb
index e5cb111..944554f 100644
--- a/lib/rb/spec/compact_protocol_spec.rb
+++ b/lib/rb/spec/compact_protocol_spec.rb
@@ -23,9 +23,9 @@
describe Thrift::CompactProtocol do
TESTS = {
:byte => (-127..127).to_a,
- :i16 => (0..14).map {|shift| [1 << shift, -(1 << shift)]}.flatten.sort,
- :i32 => (0..30).map {|shift| [1 << shift, -(1 << shift)]}.flatten.sort,
- :i64 => (0..62).map {|shift| [1 << shift, -(1 << shift)]}.flatten.sort,
+ :i16 => (0..14).map { |shift| [1 << shift, -(1 << shift)] }.flatten.sort,
+ :i32 => (0..30).map { |shift| [1 << shift, -(1 << shift)] }.flatten.sort,
+ :i64 => (0..62).map { |shift| [1 << shift, -(1 << shift)] }.flatten.sort,
:string => ["", "1", "short", "fourteen123456", "fifteen12345678", "unicode characters: \u20AC \u20AD", "1" * 127, "1" * 3000],
:binary => ["", "\001", "\001" * 5, "\001" * 14, "\001" * 15, "\001" * 127, "\001" * 3000],
:double => [0.0, 1.0, -1.0, 1.1, -1.1, 10000000.1, 1.0/0.0, -1.0/0.0],
diff --git a/lib/rb/spec/constants_demo_spec.rb b/lib/rb/spec/constants_demo_spec.rb
index f46582d..555a460 100644
--- a/lib/rb/spec/constants_demo_spec.rb
+++ b/lib/rb/spec/constants_demo_spec.rb
@@ -73,7 +73,7 @@
it 'should have correct set constants' do
expect(ConstantsDemo::GEN_SET).to be_a(Set)
expect(ConstantsDemo::GEN_SET.size).to eq(2)
- expect(ConstantsDemo::GEN_SET.include?(235)).to be true # added twice, but this is a set
+ expect(ConstantsDemo::GEN_SET.include?(235)).to be true # added twice, but this is a set
expect(ConstantsDemo::GEN_SET.include?(53235)).to be true
expect(ConstantsDemo::GUID_SET).to be_a(Set)
diff --git a/lib/rb/spec/exception_spec.rb b/lib/rb/spec/exception_spec.rb
index 379ae69..a5f422d 100644
--- a/lib/rb/spec/exception_spec.rb
+++ b/lib/rb/spec/exception_spec.rb
@@ -20,7 +20,6 @@
require 'spec_helper'
describe 'Exception' do
-
describe Thrift::Exception do
it "should have an accessible message" do
e = Thrift::Exception.new("test message")
diff --git a/lib/rb/spec/http_client_spec.rb b/lib/rb/spec/http_client_spec.rb
index 3c02319..b6a8f4c 100644
--- a/lib/rb/spec/http_client_spec.rb
+++ b/lib/rb/spec/http_client_spec.rb
@@ -20,7 +20,6 @@
require 'spec_helper'
describe 'Thrift::HTTPClientTransport' do
-
describe Thrift::HTTPClientTransport do
before(:each) do
@client = Thrift::HTTPClientTransport.new("http://my.domain.com/path/to/service?param=value")
@@ -84,7 +83,7 @@
end
end
- @client.flush rescue
+ @client.flush rescue
expect(@client.instance_variable_get(:@outbuf)).to eq(Thrift::Bytes.empty_byte_buffer)
end
@@ -105,7 +104,6 @@
expect { @client.flush }.to raise_error(Thrift::TransportException)
end
-
end
describe 'ssl enabled' do
diff --git a/lib/rb/spec/json_protocol_spec.rb b/lib/rb/spec/json_protocol_spec.rb
index e53fd3e..8da8e0e 100644
--- a/lib/rb/spec/json_protocol_spec.rb
+++ b/lib/rb/spec/json_protocol_spec.rb
@@ -21,7 +21,6 @@
require 'spec_helper'
describe 'JsonProtocol' do
-
describe Thrift::JsonProtocol do
before(:each) do
@trans = Thrift::MemoryBufferTransport.new
@@ -251,8 +250,8 @@
end
it "should get type name for type id" do
- expect {@prot.get_type_name_for_type_id(Thrift::Types::STOP)}.to raise_error(NotImplementedError)
- expect {@prot.get_type_name_for_type_id(Thrift::Types::VOID)}.to raise_error(NotImplementedError)
+ expect { @prot.get_type_name_for_type_id(Thrift::Types::STOP) }.to raise_error(NotImplementedError)
+ expect { @prot.get_type_name_for_type_id(Thrift::Types::VOID) }.to raise_error(NotImplementedError)
expect(@prot.get_type_name_for_type_id(Thrift::Types::BOOL)).to eq("tf")
expect(@prot.get_type_name_for_type_id(Thrift::Types::BYTE)).to eq("i8")
expect(@prot.get_type_name_for_type_id(Thrift::Types::DOUBLE)).to eq("dbl")
@@ -267,7 +266,7 @@
end
it "should get type id for type name" do
- expect {@prot.get_type_id_for_type_name("pp")}.to raise_error(NotImplementedError)
+ expect { @prot.get_type_id_for_type_name("pp") }.to raise_error(NotImplementedError)
expect(@prot.get_type_id_for_type_name("tf")).to eq(Thrift::Types::BOOL)
expect(@prot.get_type_id_for_type_name("i8")).to eq(Thrift::Types::BYTE)
expect(@prot.get_type_id_for_type_name("dbl")).to eq(Thrift::Types::DOUBLE)
@@ -283,7 +282,7 @@
it "should read json syntax char" do
@trans.write('F')
- expect {@prot.read_json_syntax_char('G')}.to raise_error(Thrift::ProtocolException)
+ expect { @prot.read_json_syntax_char('G') }.to raise_error(Thrift::ProtocolException)
@trans.write('H')
@prot.read_json_syntax_char('H')
end
@@ -319,7 +318,7 @@
it "should read json string" do
@trans.write("\"\\P")
- expect {@prot.read_json_string(false)}.to raise_error(Thrift::ProtocolException)
+ expect { @prot.read_json_string(false) }.to raise_error(Thrift::ProtocolException)
@trans.write("\"this is a test string\"")
expect(@prot.read_json_string).to eq("this is a test string")
@@ -356,7 +355,7 @@
it "should read json integer" do
@trans.write("1.45\"\"")
- expect {@prot.read_json_integer}.to raise_error(Thrift::ProtocolException)
+ expect { @prot.read_json_integer }.to raise_error(Thrift::ProtocolException)
@prot.read_string
@trans.write("1453T")
@@ -365,11 +364,11 @@
it "should read json double" do
@trans.write("1.45e3e01\"\"")
- expect {@prot.read_json_double}.to raise_error(Thrift::ProtocolException)
+ expect { @prot.read_json_double }.to raise_error(Thrift::ProtocolException)
@prot.read_string
@trans.write("\"1.453e01\"")
- expect {@prot.read_json_double}.to raise_error(Thrift::ProtocolException)
+ expect { @prot.read_json_double }.to raise_error(Thrift::ProtocolException)
@trans.write("1.453e01\"\"")
expect(@prot.read_json_double).to eq(14.53)
@@ -407,7 +406,7 @@
it "should read_message_begin" do
@trans.write("[2,")
- expect {@prot.read_message_begin}.to raise_error(Thrift::ProtocolException)
+ expect { @prot.read_message_begin }.to raise_error(Thrift::ProtocolException)
@trans.write("[1,\"name\",12,32\"\"")
expect(@prot.read_message_begin).to eq(["name", 12, 32])
diff --git a/lib/rb/spec/namespaced_spec.rb b/lib/rb/spec/namespaced_spec.rb
index 4d6d369..69e4a2a 100644
--- a/lib/rb/spec/namespaced_spec.rb
+++ b/lib/rb/spec/namespaced_spec.rb
@@ -63,5 +63,4 @@
it "extended a service" do
require "extended/extended_service"
end
-
end
diff --git a/lib/rb/spec/nonblocking_server_spec.rb b/lib/rb/spec/nonblocking_server_spec.rb
index cfc60ff..572e0b5 100644
--- a/lib/rb/spec/nonblocking_server_spec.rb
+++ b/lib/rb/spec/nonblocking_server_spec.rb
@@ -21,7 +21,6 @@
require 'timeout'
describe 'NonblockingServer' do
-
class Handler
def initialize
@queue = Queue.new
@@ -77,7 +76,7 @@
@transport.read(sz)
end
- def write(buf,sz=nil)
+ def write(buf, sz = nil)
@transport.write(buf, sz)
end
@@ -167,7 +166,7 @@
break
end
end
- @clients.each { |c,t| t.close and break if c == client } #close the transport
+ @clients.each { |c, t| t.close and break if c == client } # close the transport
rescue => e
raise e unless @catch_exceptions
end
diff --git a/lib/rb/spec/processor_spec.rb b/lib/rb/spec/processor_spec.rb
index d30553f..5774df7 100644
--- a/lib/rb/spec/processor_spec.rb
+++ b/lib/rb/spec/processor_spec.rb
@@ -20,7 +20,6 @@
require 'spec_helper'
describe 'Processor' do
-
class ProcessorSpec
include Thrift::Processor
end
diff --git a/lib/rb/spec/serializer_spec.rb b/lib/rb/spec/serializer_spec.rb
index 2a7dc6d..b8afdc5 100644
--- a/lib/rb/spec/serializer_spec.rb
+++ b/lib/rb/spec/serializer_spec.rb
@@ -20,7 +20,6 @@
require 'spec_helper'
describe 'Serializer' do
-
describe Thrift::Serializer do
it "should serialize structs to binary by default" do
serializer = Thrift::Serializer.new(Thrift::BinaryProtocolAcceleratedFactory.new)
diff --git a/lib/rb/spec/server_socket_spec.rb b/lib/rb/spec/server_socket_spec.rb
index 56b3bac..4fa305d 100644
--- a/lib/rb/spec/server_socket_spec.rb
+++ b/lib/rb/spec/server_socket_spec.rb
@@ -21,7 +21,6 @@
require File.expand_path("#{File.dirname(__FILE__)}/socket_spec_shared")
describe 'Thrift::ServerSocket' do
-
describe Thrift::ServerSocket do
before(:each) do
@socket = Thrift::ServerSocket.new(1234)
diff --git a/lib/rb/spec/server_spec.rb b/lib/rb/spec/server_spec.rb
index 47204aa..c403833 100644
--- a/lib/rb/spec/server_spec.rb
+++ b/lib/rb/spec/server_spec.rb
@@ -19,7 +19,6 @@
require 'spec_helper'
describe 'Server' do
-
describe Thrift::BaseServer do
before(:each) do
@processor = double("Processor")
@@ -36,7 +35,7 @@
end
it "should not serve" do
- expect { @server.serve()}.to raise_error(NotImplementedError)
+ expect { @server.serve() }.to raise_error(NotImplementedError)
end
it "should provide a reasonable to_s" do
diff --git a/lib/rb/spec/socket_spec.rb b/lib/rb/spec/socket_spec.rb
index 202c745..b8b2045 100644
--- a/lib/rb/spec/socket_spec.rb
+++ b/lib/rb/spec/socket_spec.rb
@@ -21,7 +21,6 @@
require File.expand_path("#{File.dirname(__FILE__)}/socket_spec_shared")
describe 'Socket' do
-
describe Thrift::Socket do
before(:each) do
@socket = Thrift::Socket.new
diff --git a/lib/rb/spec/spec_helper.rb b/lib/rb/spec/spec_helper.rb
index 7c16507..24707aa 100644
--- a/lib/rb/spec/spec_helper.rb
+++ b/lib/rb/spec/spec_helper.rb
@@ -55,7 +55,7 @@
module Fixtures
COMPACT_PROTOCOL_TEST_STRUCT = Thrift::Test::COMPACT_TEST.dup
- COMPACT_PROTOCOL_TEST_STRUCT.a_binary = [0,1,2,3,4,5,6,7,8].pack('c*')
+ COMPACT_PROTOCOL_TEST_STRUCT.a_binary = [0, 1, 2, 3, 4, 5, 6, 7, 8].pack('c*')
COMPACT_PROTOCOL_TEST_STRUCT.set_byte_map = nil
COMPACT_PROTOCOL_TEST_STRUCT.map_byte_map = nil
end
diff --git a/lib/rb/spec/ssl_server_socket_spec.rb b/lib/rb/spec/ssl_server_socket_spec.rb
index 20cfdf4..c228de0 100644
--- a/lib/rb/spec/ssl_server_socket_spec.rb
+++ b/lib/rb/spec/ssl_server_socket_spec.rb
@@ -21,7 +21,6 @@
require File.expand_path("#{File.dirname(__FILE__)}/socket_spec_shared")
describe 'SSLServerSocket' do
-
describe Thrift::SSLServerSocket do
before(:each) do
@socket = Thrift::SSLServerSocket.new(1234)
diff --git a/lib/rb/spec/ssl_socket_spec.rb b/lib/rb/spec/ssl_socket_spec.rb
index eb68bcf..1bff813 100644
--- a/lib/rb/spec/ssl_socket_spec.rb
+++ b/lib/rb/spec/ssl_socket_spec.rb
@@ -21,7 +21,6 @@
require File.expand_path("#{File.dirname(__FILE__)}/socket_spec_shared")
describe 'SSLSocket' do
-
describe Thrift::SSLSocket do
before(:each) do
@context = OpenSSL::SSL::SSLContext.new
diff --git a/lib/rb/spec/struct_nested_containers_spec.rb b/lib/rb/spec/struct_nested_containers_spec.rb
index d063569..552c66a 100644
--- a/lib/rb/spec/struct_nested_containers_spec.rb
+++ b/lib/rb/spec/struct_nested_containers_spec.rb
@@ -20,7 +20,6 @@
require 'spec_helper'
describe 'StructNestedContainers' do
-
def with_type_checking
saved_type_checking, Thrift.type_checking = Thrift.type_checking, true
begin
@@ -166,7 +165,7 @@
with_type_checking do
a, b = SpecNamespace::NestedMapInMapKey.new, SpecNamespace::NestedMapInMapKey.new
[a, b].each do |thrift_struct|
- thrift_struct.value = { { 1 => 2, 3 => 4} => 1, {2 => 3, 4 => 5} => 2 }
+ thrift_struct.value = { { 1 => 2, 3 => 4} => 1, {2 => 3, 4 => 5} => 2 }
thrift_struct.validate
end
expect(a).to eq(b)
diff --git a/lib/rb/spec/struct_spec.rb b/lib/rb/spec/struct_spec.rb
index 36c738e..800b21a 100644
--- a/lib/rb/spec/struct_spec.rb
+++ b/lib/rb/spec/struct_spec.rb
@@ -20,11 +20,10 @@
require 'spec_helper'
describe 'Struct' do
-
describe Thrift::Struct do
it "should iterate over all fields properly" do
fields = {}
- SpecNamespace::Foo.new.each_field { |fid,field_info| fields[fid] = field_info }
+ SpecNamespace::Foo.new.each_field { |fid, field_info| fields[fid] = field_info }
expect(fields).to eq(SpecNamespace::Foo::FIELDS)
end
@@ -51,10 +50,10 @@
begin
struct = SpecNamespace::Foo.new
struct.ints << 17
- expect(SpecNamespace::Foo.new.ints).to eq([1,2,2,3])
+ expect(SpecNamespace::Foo.new.ints).to eq([1, 2, 2, 3])
ensure
# ensure no leakage to other tests
- SpecNamespace::Foo::FIELDS[4][:default] = [1,2,2,3]
+ SpecNamespace::Foo::FIELDS[4][:default] = [1, 2, 2, 3]
end
end
@@ -209,7 +208,7 @@
end
it "should write itself to the wire" do
- prot = Thrift::BaseProtocol.new(double("transport")) #mock("Protocol")
+ prot = Thrift::BaseProtocol.new(double("transport")) # mock("Protocol")
expect(prot).to receive(:write_struct_begin).with("SpecNamespace::Foo")
expect(prot).to receive(:write_struct_begin).with("SpecNamespace::Hello")
expect(prot).to receive(:write_struct_end).twice
@@ -287,9 +286,9 @@
prot = Thrift::BaseProtocol.new(double("trans"))
expect(prot).to receive(:write_struct_begin).with("SpecNamespace::Xception")
expect(prot).to receive(:write_struct_end)
- expect(prot).to receive(:write_field_begin).with('message', Thrift::Types::STRING, 1)#, "something happened")
+ expect(prot).to receive(:write_field_begin).with('message', Thrift::Types::STRING, 1)
expect(prot).to receive(:write_string).with("something happened")
- expect(prot).to receive(:write_field_begin).with('code', Thrift::Types::I32, 2)#, 1)
+ expect(prot).to receive(:write_field_begin).with('code', Thrift::Types::I32, 2)
expect(prot).to receive(:write_i32).with(1)
expect(prot).to receive(:write_field_stop)
expect(prot).to receive(:write_field_end).twice
diff --git a/lib/rb/spec/thin_http_server_spec.rb b/lib/rb/spec/thin_http_server_spec.rb
index 6f8f8e2..9046a00 100644
--- a/lib/rb/spec/thin_http_server_spec.rb
+++ b/lib/rb/spec/thin_http_server_spec.rb
@@ -22,13 +22,10 @@
require 'thrift/server/thin_http_server'
describe Thrift::ThinHTTPServer do
-
let(:processor) { double('processor') }
describe "#initialize" do
-
context "when using the defaults" do
-
it "binds to port 80, with host 0.0.0.0, a path of '/'" do
expect(Thin::Server).to receive(:new).with('0.0.0.0', 80, an_instance_of(Rack::Builder))
Thrift::ThinHTTPServer.new(processor)
@@ -43,11 +40,9 @@
expect(Thrift::BinaryProtocolFactory).to receive(:new)
Thrift::ThinHTTPServer.new(processor)
end
-
end
context "when using the options" do
-
it 'accepts :ip, :port, :path' do
ip = "192.168.0.1"
port = 3000
@@ -64,13 +59,10 @@
Thrift::ThinHTTPServer.new(processor,
:protocol_factory => Thrift::JsonProtocolFactory.new)
end
-
end
-
end
describe "#serve" do
-
it 'starts the Thin server' do
underlying_thin_server = double('thin server', :start => true)
allow(Thin::Server).to receive(:new).and_return(underlying_thin_server)
@@ -81,7 +73,6 @@
thin_thrift_server.serve
end
end
-
end
describe Thrift::ThinHTTPServer::RackApplication do
@@ -95,7 +86,6 @@
end
context "404 response" do
-
it 'receives a non-POST' do
header('Content-Type', "application/x-thrift")
get "/"
@@ -107,11 +97,9 @@
post "/"
expect(last_response.status).to eq 404
end
-
end
context "200 response" do
-
before do
allow(protocol_factory).to receive(:get_protocol)
allow(processor).to receive(:process)
@@ -134,7 +122,5 @@
post "/"
expect(last_response.ok?).to be true
end
-
end
-
end
diff --git a/lib/rb/spec/types_spec.rb b/lib/rb/spec/types_spec.rb
index a385367..a0ef755 100644
--- a/lib/rb/spec/types_spec.rb
+++ b/lib/rb/spec/types_spec.rb
@@ -20,7 +20,6 @@
require 'spec_helper'
describe Thrift::Types do
-
before(:each) do
Thrift.type_checking = true
end
@@ -39,33 +38,33 @@
it "should check types properly" do
# lambda { Thrift.check_type(nil, Thrift::Types::STOP) }.should raise_error(Thrift::TypeError)
- expect { Thrift.check_type(3, {:type => Thrift::Types::STOP}, :foo) }.to raise_error(Thrift::TypeError)
- expect { Thrift.check_type(nil, {:type => Thrift::Types::VOID}, :foo) }.not_to raise_error
- expect { Thrift.check_type(3, {:type => Thrift::Types::VOID}, :foo) }.to raise_error(Thrift::TypeError)
- expect { Thrift.check_type(true, {:type => Thrift::Types::BOOL}, :foo) }.not_to raise_error
- expect { Thrift.check_type(3, {:type => Thrift::Types::BOOL}, :foo) }.to raise_error(Thrift::TypeError)
- expect { Thrift.check_type(42, {:type => Thrift::Types::BYTE}, :foo) }.not_to raise_error
- expect { Thrift.check_type(42, {:type => Thrift::Types::I16}, :foo) }.not_to raise_error
- expect { Thrift.check_type(42, {:type => Thrift::Types::I32}, :foo) }.not_to raise_error
- expect { Thrift.check_type(42, {:type => Thrift::Types::I64}, :foo) }.not_to raise_error
- expect { Thrift.check_type(3.14, {:type => Thrift::Types::I32}, :foo) }.to raise_error(Thrift::TypeError)
- expect { Thrift.check_type(3.14, {:type => Thrift::Types::DOUBLE}, :foo) }.not_to raise_error
- expect { Thrift.check_type(3, {:type => Thrift::Types::DOUBLE}, :foo) }.to raise_error(Thrift::TypeError)
- expect { Thrift.check_type("3", {:type => Thrift::Types::STRING}, :foo) }.not_to raise_error
- expect { Thrift.check_type(3, {:type => Thrift::Types::STRING}, :foo) }.to raise_error(Thrift::TypeError)
+ expect { Thrift.check_type(3, {:type => Thrift::Types::STOP}, :foo) }.to raise_error(Thrift::TypeError)
+ expect { Thrift.check_type(nil, {:type => Thrift::Types::VOID}, :foo) }.not_to raise_error
+ expect { Thrift.check_type(3, {:type => Thrift::Types::VOID}, :foo) }.to raise_error(Thrift::TypeError)
+ expect { Thrift.check_type(true, {:type => Thrift::Types::BOOL}, :foo) }.not_to raise_error
+ expect { Thrift.check_type(3, {:type => Thrift::Types::BOOL}, :foo) }.to raise_error(Thrift::TypeError)
+ expect { Thrift.check_type(42, {:type => Thrift::Types::BYTE}, :foo) }.not_to raise_error
+ expect { Thrift.check_type(42, {:type => Thrift::Types::I16}, :foo) }.not_to raise_error
+ expect { Thrift.check_type(42, {:type => Thrift::Types::I32}, :foo) }.not_to raise_error
+ expect { Thrift.check_type(42, {:type => Thrift::Types::I64}, :foo) }.not_to raise_error
+ expect { Thrift.check_type(3.14, {:type => Thrift::Types::I32}, :foo) }.to raise_error(Thrift::TypeError)
+ expect { Thrift.check_type(3.14, {:type => Thrift::Types::DOUBLE}, :foo) }.not_to raise_error
+ expect { Thrift.check_type(3, {:type => Thrift::Types::DOUBLE}, :foo) }.to raise_error(Thrift::TypeError)
+ expect { Thrift.check_type("3", {:type => Thrift::Types::STRING}, :foo) }.not_to raise_error
+ expect { Thrift.check_type(3, {:type => Thrift::Types::STRING}, :foo) }.to raise_error(Thrift::TypeError)
hello = SpecNamespace::Hello.new
- expect { Thrift.check_type(hello, {:type => Thrift::Types::STRUCT, :class => SpecNamespace::Hello}, :foo) }.not_to raise_error
- expect { Thrift.check_type("foo", {:type => Thrift::Types::STRUCT}, :foo) }.to raise_error(Thrift::TypeError)
+ expect { Thrift.check_type(hello, {:type => Thrift::Types::STRUCT, :class => SpecNamespace::Hello}, :foo) }.not_to raise_error
+ expect { Thrift.check_type("foo", {:type => Thrift::Types::STRUCT}, :foo) }.to raise_error(Thrift::TypeError)
field = {:type => Thrift::Types::MAP, :key => {:type => Thrift::Types::I32}, :value => {:type => Thrift::Types::STRING}}
- expect { Thrift.check_type({1 => "one"}, field, :foo) }.not_to raise_error
- expect { Thrift.check_type([1], field, :foo) }.to raise_error(Thrift::TypeError)
+ expect { Thrift.check_type({1 => "one"}, field, :foo) }.not_to raise_error
+ expect { Thrift.check_type([1], field, :foo) }.to raise_error(Thrift::TypeError)
field = {:type => Thrift::Types::LIST, :element => {:type => Thrift::Types::I32}}
- expect { Thrift.check_type([1], field, :foo) }.not_to raise_error
- expect { Thrift.check_type({:foo => 1}, field, :foo) }.to raise_error(Thrift::TypeError)
+ expect { Thrift.check_type([1], field, :foo) }.not_to raise_error
+ expect { Thrift.check_type({:foo => 1}, field, :foo) }.to raise_error(Thrift::TypeError)
field = {:type => Thrift::Types::SET, :element => {:type => Thrift::Types::I32}}
- expect { Thrift.check_type(Set.new([1,2]), field, :foo) }.not_to raise_error
- expect { Thrift.check_type([1,2], field, :foo) }.to raise_error(Thrift::TypeError)
- expect { Thrift.check_type({:foo => true}, field, :foo) }.to raise_error(Thrift::TypeError)
+ expect { Thrift.check_type(Set.new([1, 2]), field, :foo) }.not_to raise_error
+ expect { Thrift.check_type([1, 2], field, :foo) }.to raise_error(Thrift::TypeError)
+ expect { Thrift.check_type({:foo => true}, field, :foo) }.to raise_error(Thrift::TypeError)
end
it "should error out if nil is passed and skip_types is false" do
diff --git a/lib/rb/spec/union_spec.rb b/lib/rb/spec/union_spec.rb
index f38093d..e45aa42 100644
--- a/lib/rb/spec/union_spec.rb
+++ b/lib/rb/spec/union_spec.rb
@@ -20,7 +20,6 @@
require 'spec_helper'
describe 'Union' do
-
describe Thrift::Union do
it "should return nil value in unset union" do
union = SpecNamespace::My_union.new
@@ -194,7 +193,7 @@
end
it "should not throw an error when inspected and unset" do
- expect{SpecNamespace::TestUnion.new().inspect}.not_to raise_error
+ expect{ SpecNamespace::TestUnion.new().inspect }.not_to raise_error
end
it "should print enum value name when inspected" do
diff --git a/lib/rb/spec/unix_socket_spec.rb b/lib/rb/spec/unix_socket_spec.rb
index 7f878a1..437ca83 100644
--- a/lib/rb/spec/unix_socket_spec.rb
+++ b/lib/rb/spec/unix_socket_spec.rb
@@ -21,7 +21,6 @@
require File.expand_path("#{File.dirname(__FILE__)}/socket_spec_shared")
describe 'UNIXSocket' do
-
describe Thrift::UNIXSocket do
before(:each) do
@path = '/tmp/thrift_spec_socket'
diff --git a/lib/rb/spec/uuid_validation_spec.rb b/lib/rb/spec/uuid_validation_spec.rb
index c95d408..3f46f7e 100644
--- a/lib/rb/spec/uuid_validation_spec.rb
+++ b/lib/rb/spec/uuid_validation_spec.rb
@@ -186,7 +186,7 @@
@trans = Thrift::MemoryBufferTransport.new
@prot = protocol_class.new(@trans)
- @prot.write_message_begin('testMessage', Thrift::MessageTypes::CALL, 0)
+ @prot.write_message_begin('testMessage', Thrift::MessageTypes::CALL, 0)
@prot.write_i32(42)
@prot.write_uuid('550e8400-e29b-41d4-a716-446655440000')
@prot.write_string('test')
diff --git a/lib/rb/thrift.gemspec b/lib/rb/thrift.gemspec
index d763bad..b3920d7 100644
--- a/lib/rb/thrift.gemspec
+++ b/lib/rb/thrift.gemspec
@@ -14,15 +14,15 @@
s.required_ruby_version = '>= 2.4.0'
- s.rdoc_options = %w[--line-numbers --inline-source --title Thrift --main README]
+ s.rdoc_options = %w[--line-numbers --inline-source --title Thrift --main README]
dir = File.expand_path(File.dirname(__FILE__))
s.files = Dir.glob("{lib,spec}/**/*")
s.test_files = Dir.glob("{test,spec,benchmark}/**/*")
- s.executables = Dir.glob("{bin}/**/*")
+ s.executables = Dir.glob("{bin}/**/*")
- s.extra_rdoc_files = %w[README.md] + Dir.glob("{ext,lib}/**/*.{c,h,rb}")
+ s.extra_rdoc_files = %w[README.md] + Dir.glob("{ext,lib}/**/*.{c,h,rb}")
s.require_paths = %w[lib ext]
diff --git a/test/rb/benchmarks/protocol_benchmark.rb b/test/rb/benchmarks/protocol_benchmark.rb
index 64fb4fc..897743f 100644
--- a/test/rb/benchmarks/protocol_benchmark.rb
+++ b/test/rb/benchmarks/protocol_benchmark.rb
@@ -215,5 +215,4 @@
Fixtures::Structs::OneOfEach.new.read(header_zlib_protocol)
end
end
-
end
diff --git a/test/rb/integration/TestClient.rb b/test/rb/integration/TestClient.rb
index 7a360ef..18fc5ff 100755
--- a/test/rb/integration/TestClient.rb
+++ b/test/rb/integration/TestClient.rb
@@ -219,7 +219,7 @@
def test_list
p 'test_list'
- val = [1,2,3,4,5]
+ val = [1, 2, 3, 4, 5]
assert_equal(@client.testList(val), val)
assert_kind_of(Array, @client.testList(val))
end
@@ -235,7 +235,7 @@
def test_typedef
p 'test_typedef'
- #UserId testTypedef(1: UserId thing),
+ # UserId testTypedef(1: UserId thing),
assert_equal(@client.testTypedef(309858235082523), 309858235082523)
assert_kind_of(Integer, @client.testTypedef(309858235082523))
true
@@ -243,7 +243,7 @@
def test_set
p 'test_set'
- val = Set.new([1,2,3])
+ val = Set.new([1, 2, 3])
assert_equal(@client.testSet(val), val)
assert_kind_of(Set, @client.testSet(val))
end
diff --git a/test/rb/integration/TestServer.rb b/test/rb/integration/TestServer.rb
index d0ba1fe..54f3504 100755
--- a/test/rb/integration/TestServer.rb
+++ b/test/rb/integration/TestServer.rb
@@ -32,13 +32,11 @@
[:testVoid, :testString, :testBool, :testByte, :testI32, :testI64, :testDouble, :testBinary,
:testStruct, :testMap, :testStringMap, :testSet, :testList, :testNest, :testEnum, :testTypedef,
:testEnum, :testTypedef, :testMultiException, :testUuid].each do |meth|
-
define_method(meth) do |thing|
p meth
p thing
thing
end
-
end
def testVoid()
diff --git a/test/rb/test_helper.rb b/test/rb/test_helper.rb
index c1ed779..735d899 100644
--- a/test/rb/test_helper.rb
+++ b/test/rb/test_helper.rb
@@ -27,7 +27,7 @@
module Struct
def ==(other)
return false unless other.is_a? self.class
- self.class.const_get(:FIELDS).collect {|fid, data| data[:name] }.all? do |field|
+ self.class.const_get(:FIELDS).collect { |fid, data| data[:name] }.all? do |field|
send(field) == other.send(field)
end
end
diff --git a/test/rb/test_suite.rb b/test/rb/test_suite.rb
index dac2d4a..b11b578 100644
--- a/test/rb/test_suite.rb
+++ b/test/rb/test_suite.rb
@@ -17,4 +17,4 @@
# under the License.
#
-Dir["{core,generation}/**/*.rb"].each {|f| require f }
+Dir["{core,generation}/**/*.rb"].each { |f| require f }
diff --git a/tutorial/rb/RubyClient.rb b/tutorial/rb/RubyClient.rb
index 9a5aa43..94ffdca 100755
--- a/tutorial/rb/RubyClient.rb
+++ b/tutorial/rb/RubyClient.rb
@@ -38,10 +38,10 @@
client.ping()
print "ping()\n"
- sum = client.add(1,1)
+ sum = client.add(1, 1)
print "1+1=", sum, "\n"
- sum = client.add(1,4)
+ sum = client.add(1, 4)
print "1+4=", sum, "\n"
work = Work.new()
diff --git a/tutorial/rb/RubyServer.rb b/tutorial/rb/RubyServer.rb
index 1d707d7..d42a9db 100755
--- a/tutorial/rb/RubyServer.rb
+++ b/tutorial/rb/RubyServer.rb
@@ -42,7 +42,7 @@
end
def calculate(logid, work)
- print "calculate(", logid, ", {", work.op, ",", work.num1, ",", work.num2,"})\n"
+ print "calculate(", logid, ", {", work.op, ",", work.num1, ",", work.num2, "})\n"
if work.op == Operation::ADD
val = work.num1 + work.num2
elsif work.op == Operation::SUBTRACT