Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions compiler/cpp/src/thrift/generate/t_rb_generator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1009,9 +1009,6 @@ void t_rb_generator::generate_service_client(t_service* tservice) {

if (!(*f_iter)->is_oneway()) {
f_service_.indent();
if (!(*f_iter)->get_returntype()->is_void()) {
f_service_ << "return ";
}
f_service_ << "recv_" << funname << "()" << '\n';
}
f_service_.indent_down();
Expand Down Expand Up @@ -1075,7 +1072,7 @@ void t_rb_generator::generate_service_client(t_service* tservice) {

// Careful, only return _result if not a void function
if ((*f_iter)->get_returntype()->is_void()) {
f_service_.indent() << "return" << '\n';
f_service_.indent() << "nil" << '\n';
} else {
f_service_.indent() << "raise "
"::Thrift::ApplicationException.new(::Thrift::ApplicationException::"
Expand Down Expand Up @@ -1206,7 +1203,7 @@ void t_rb_generator::generate_process_function(t_service* tservice, t_function*

// Shortcut out here for oneway functions
if (tfunction->is_oneway()) {
f_service_.indent() << "return" << '\n';
f_service_.indent() << "nil" << '\n';
f_service_.indent_down();
f_service_.indent() << "end" << '\n';
return;
Expand Down
3 changes: 3 additions & 0 deletions compiler/cpp/tests/rb/t_rb_generator_functional_tests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ TEST_CASE("t_rb_generator formats service classes and positional arguments", "[f
"}\n"
"service PingService {\n"
" oneway void ping(1: i32 n)\n"
" i32 pong()\n"
"}\n";

{
Expand All @@ -131,6 +132,8 @@ TEST_CASE("t_rb_generator formats service classes and positional arguments", "[f
"\n"
" FIELDS";
REQUIRE(service.find("send_oneway_message(\"ping\", Ping_args, {n: n})") != string::npos);
REQUIRE(service.find("def pong()\n send_pong()\n recv_pong()\n end")
!= string::npos);
REQUIRE(service.find(expected_empty_result) != string::npos);
REQUIRE(service.find("\n\n end\n") == string::npos);

Expand Down
3 changes: 3 additions & 0 deletions lib/rb/.rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,9 @@ Style/RedundantInterpolation:
Style/RedundantParentheses:
Enabled: true

Style/RedundantReturn:
Enabled: true

Style/RedundantSelf:
Enabled: true

Expand Down
2 changes: 1 addition & 1 deletion lib/rb/lib/thrift/protocol/binary_protocol.rb
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ def write_i32_size(size)

class BinaryProtocolFactory < BaseProtocolFactory
def get_protocol(trans)
return Thrift::BinaryProtocol.new(trans)
Thrift::BinaryProtocol.new(trans)
end

def to_s
Expand Down
20 changes: 10 additions & 10 deletions lib/rb/lib/thrift/protocol/json_protocol.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@ def read
@data = @trans.read(1)
end

return @data
@data
end

def peek
if !@hasData
@data = @trans.read(1)
end
@hasData = true
return @data
@data
end
end

Expand All @@ -69,7 +69,7 @@ def read(reader)
# Default behavior is to return false.
#
def escapeNum
return false
false
end
end

Expand Down Expand Up @@ -105,7 +105,7 @@ def read(reader)

# Numbers must be turned into strings if they are the key part of a pair
def escapeNum
return @colon
@colon
end
end

Expand Down Expand Up @@ -219,9 +219,9 @@ def self.read_syntax_char(reader, ch)
def is_json_numeric(ch)
case ch
when "+", "-", ".", "0".."9", "E", "e"
return true
true
else
return false
false
end
end

Expand Down Expand Up @@ -563,7 +563,7 @@ def read_json_numeric_chars
ch = @reader.read
str << ch
end
return str
str
end

# Reads a sequence of characters and assembles them into a number,
Expand All @@ -585,7 +585,7 @@ def read_json_integer
read_json_syntax_char(@@kJSONStringDelimiter)
end

return num
num
end

# Reads a JSON number or string and interprets it as a double.
Expand Down Expand Up @@ -624,7 +624,7 @@ def read_json_double
raise ProtocolException.new(ProtocolException::INVALID_DATA, "Expected numeric value; got \"#{str}\"")
end
end
return num
num
end

def read_json_object_start
Expand Down Expand Up @@ -821,7 +821,7 @@ def invalid_unicode!(message)

class JsonProtocolFactory < BaseProtocolFactory
def get_protocol(trans)
return Thrift::JsonProtocol.new(trans)
Thrift::JsonProtocol.new(trans)
end

def to_s
Expand Down
4 changes: 2 additions & 2 deletions lib/rb/lib/thrift/transport/base_transport.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def read(sz)
# Returns an unsigned byte as a Integer in the range (0..255).
def read_byte
buf = read_all(1)
return Bytes.get_string_byte(buf, 0)
Bytes.get_string_byte(buf, 0)
end

# Reads size bytes and copies them into buffer[0..size].
Expand Down Expand Up @@ -129,7 +129,7 @@ def to_s

class BaseTransportFactory
def get_transport(trans)
return trans
trans
end

def to_s
Expand Down
6 changes: 3 additions & 3 deletions lib/rb/lib/thrift/transport/buffered_transport.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def initialize(transport)
end

def open?
return @transport.open?
@transport.open?
end

def open
Expand Down Expand Up @@ -66,7 +66,7 @@ def read_byte
# The read buffer has some data now, read a single byte. Using get_string_byte() avoids
# allocating a temp string of size 1 unnecessarily.
@index += 1
return Bytes.get_string_byte(@rbuf, @index - 1)
Bytes.get_string_byte(@rbuf, @index - 1)
end

# Reads a number of bytes from the transport into the buffer passed.
Expand Down Expand Up @@ -113,7 +113,7 @@ def to_s

class BufferedTransportFactory < BaseTransportFactory
def get_transport(transport)
return BufferedTransport.new(transport)
BufferedTransport.new(transport)
end

def to_s
Expand Down
4 changes: 2 additions & 2 deletions lib/rb/lib/thrift/transport/framed_transport.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def read_byte
# The read buffer has some data now, read a single byte. Using get_string_byte() avoids
# allocating a temp string of size 1 unnecessarily.
@index += 1
return Bytes.get_string_byte(@rbuf, @index - 1)
Bytes.get_string_byte(@rbuf, @index - 1)
end

def read_into_buffer(buffer, size)
Expand Down Expand Up @@ -116,7 +116,7 @@ def read_frame

class FramedTransportFactory < BaseTransportFactory
def get_transport(transport)
return FramedTransport.new(transport)
FramedTransport.new(transport)
end

def to_s
Expand Down
2 changes: 1 addition & 1 deletion lib/rb/lib/thrift/transport/memory_buffer_transport.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def initialize(buffer = nil)
end

def open?
return true
true
end

def open
Expand Down
8 changes: 4 additions & 4 deletions test/rb/integration/TestServer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def testVoid()
end

def testInsanity(thing)
return {
{
1 => {
2 => thing,
3 => thing,
Expand All @@ -59,7 +59,7 @@ def testInsanity(thing)
end

def testMapMap(thing)
return {
{
-4 => {
-4 => -4,
-3 => -3,
Expand All @@ -76,7 +76,7 @@ def testMapMap(thing)
end

def testMulti(arg0, arg1, arg2, arg3, arg4, arg5)
return Thrift::Test::Xtruct.new({
Thrift::Test::Xtruct.new({
"string_thing" => "Hello2",
"byte_thing" => arg0,
"i32_thing" => arg1,
Expand All @@ -100,7 +100,7 @@ def testMultiException(arg0, arg1)
elsif arg0 == "Xception"
raise Thrift::Test::Xception, {errorCode: 1001, message: "This is an Xception"}
else
return ::Thrift::Test::Xtruct.new({"string_thing" => arg1})
::Thrift::Test::Xtruct.new({"string_thing" => arg1})
end
end

Expand Down
6 changes: 3 additions & 3 deletions tutorial/rb/RubyServer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def ping()

def add(n1, n2)
print "add(", n1, ",", n2, ")\n"
return n1 + n2
n1 + n2
end

def calculate(logid, work)
Expand Down Expand Up @@ -69,12 +69,12 @@ def calculate(logid, work)
entry.value = val.to_s
@log[logid] = entry

return val
val
end

def getStruct(key)
print "getStruct(", key, ")\n"
return @log[key]
@log[key]
end

def zip()
Expand Down
Loading