Skip to content

Enable RuboCop Style/RedundantReturn - #3728

Merged
kpumuk merged 1 commit into
apache:masterfrom
kpumuk:rb-rubocop-redundant-return
Aug 17, 2026
Merged

Enable RuboCop Style/RedundantReturn#3728
kpumuk merged 1 commit into
apache:masterfrom
kpumuk:rb-rubocop-redundant-return

Conversation

@kpumuk

@kpumuk kpumuk commented Aug 17, 2026

Copy link
Copy Markdown
Member

Enable Style/RedundantReturn and remove explicit return keywords where Ruby already returns the final expression.

The Ruby generator now emits service client receive calls as final expressions. Generated void and oneway paths that previously used a bare early return emit nil instead, preserving their control flow and return value while keeping generated code compliant with the cop. Functional coverage verifies the generated non-void client method shape.

This follows the merged Style/RedundantBegin PR #3727; its diff contains only the RedundantReturn layer.

  • Did you create an Apache Jira ticket? (Request account here, not required for trivial changes)
  • If a ticket exists: Does your pull request title follow the pattern "THRIFT-NNNN: describe my issue"?
  • Did you squash your changes to a single commit? (not required, but preferred)
  • Did you do your best to avoid breaking changes? If one was needed, did you label the Jira ticket with "Breaking-Change"?
  • If your change does not involve any code, include [skip ci] anywhere in the commit message to free up build resources.

Client: rb

Co-Authored-By: OpenAI Codex (GPT-5.6) <codex@openai.com>
@kpumuk
kpumuk requested a review from Jens-G as a code owner August 17, 2026 03:42
Copilot AI lite review requested due to automatic review settings August 17, 2026 03:42
@kpumuk
kpumuk requested review from fishy and mhlakhani as code owners August 17, 2026 03:42
@mergeable mergeable Bot added ruby Pull requests that update Ruby code compiler labels Aug 17, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Enables RuboCop Style/RedundantReturn for the Ruby codebase and updates Ruby sources plus the Ruby code generator output to avoid explicit return where Ruby already returns the final expression, while keeping generated client/process control flow and return values consistent.

Changes:

  • Enable Style/RedundantReturn in lib/rb/.rubocop.yml.
  • Remove redundant trailing return statements across Ruby tutorial/test/runtime code where the final expression is sufficient.
  • Update the Ruby generator to emit recv_* calls as final expressions and adjust generated void/oneway terminal return sites to nil, with a functional test asserting the generated non-void client method shape.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated no comments.

Show a summary per file
File Description
tutorial/rb/RubyServer.rb Removes redundant returns in tutorial handler methods.
test/rb/integration/TestServer.rb Removes redundant returns in Ruby integration test handler methods.
lib/rb/lib/thrift/transport/memory_buffer_transport.rb Removes redundant return true in open?.
lib/rb/lib/thrift/transport/framed_transport.rb Removes redundant returns in read_byte and factory get_transport.
lib/rb/lib/thrift/transport/buffered_transport.rb Removes redundant returns in open?, read_byte, and factory get_transport.
lib/rb/lib/thrift/transport/base_transport.rb Removes redundant return in read_byte and factory get_transport.
lib/rb/lib/thrift/protocol/json_protocol.rb Removes redundant trailing returns (and case-branch returns) where the expression value suffices.
lib/rb/lib/thrift/protocol/binary_protocol.rb Removes redundant return in protocol factory get_protocol.
lib/rb/.rubocop.yml Enables Style/RedundantReturn.
compiler/cpp/tests/rb/t_rb_generator_functional_tests.cc Adds an assertion for generated non-void client method shape (send_* followed by recv_* as final expression).
compiler/cpp/src/thrift/generate/t_rb_generator.cc Updates Ruby generator output to avoid redundant returns and emit nil for terminal void/oneway paths.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@kpumuk
kpumuk merged commit fe5641c into apache:master Aug 17, 2026
94 of 95 checks passed
@kpumuk
kpumuk deleted the rb-rubocop-redundant-return branch August 17, 2026 04:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

compiler ruby Pull requests that update Ruby code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants