Enable RuboCop redundancy rules - #3726
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Enables additional RuboCop redundancy cops for the Ruby codebase and applies the corresponding auto-corrections across library code, specs, integration tests, and tutorial examples to remove redundant coercions, receivers, parentheses, and escaping while preserving behavior.
Changes:
- Enable
Lint/RedundantStringCoercionand several safeStyle/Redundant*cops inlib/rb/.rubocop.yml. - Replace redundant string interpolation / explicit
.to_scalls with direct interpolation or.to_swhere appropriate. - Simplify Ruby expressions (redundant parentheses, redundant
self, redundant intermediate assignments) across Ruby transports, protocols, structs, servers, and tests.
Reviewed changes
Copilot reviewed 30 out of 30 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| tutorial/rb/RubyServer.rb | Removes redundant string interpolation by using to_s directly. |
| test/rb/integration/TestServer.rb | Removes redundant .to_s in interpolation for startup logging. |
| test/rb/core/protocol/test_json_protocol.rb | Replaces redundant "#{...}" coercions with .to_s in assertions. |
| test/rb/core/protocol/test_compact_protocol.rb | Replaces redundant "#{...}" coercions with .to_s in assertions. |
| test/rb/core/protocol/test_binary_protocol.rb | Replaces redundant "#{...}" coercions with .to_s in assertions. |
| lib/rb/spec/json_protocol_spec.rb | Removes redundant parentheses and redundant string escaping in expectations. |
| lib/rb/spec/compact_protocol_spec.rb | Removes redundant .to_s in interpolation for generated method names. |
| lib/rb/spec/base_transport_spec.rb | Removes redundant .freeze on literals under frozen_string_literal: true. |
| lib/rb/lib/thrift/union.rb | Removes redundant explicit receiver and redundant exception class in raise. |
| lib/rb/lib/thrift/transport/ssl_socket.rb | Removes redundant .to_s inside to_s interpolation. |
| lib/rb/lib/thrift/transport/ssl_server_socket.rb | Removes redundant .to_s inside to_s interpolation. |
| lib/rb/lib/thrift/transport/socket.rb | Removes redundant parentheses in conditional. |
| lib/rb/lib/thrift/transport/io_stream_transport.rb | Removes redundant .to_s calls in to_s. |
| lib/rb/lib/thrift/transport/http_client_transport.rb | Removes redundant to_s calls in interpolated error messages. |
| lib/rb/lib/thrift/transport/header_transport.rb | Removes redundant .to_s in to_s. |
| lib/rb/lib/thrift/transport/framed_transport.rb | Removes redundant .to_s in to_s. |
| lib/rb/lib/thrift/transport/buffered_transport.rb | Removes redundant .to_s in to_s. |
| lib/rb/lib/thrift/struct.rb | Removes redundant self. receiver for send/instance_variable_get. |
| lib/rb/lib/thrift/struct_union.rb | Removes redundant parentheses in a compound conditional. |
| lib/rb/lib/thrift/server/threaded_server.rb | Removes redundant .to_s in to_s. |
| lib/rb/lib/thrift/server/thread_pool_server.rb | Removes redundant .to_s in to_s. |
| lib/rb/lib/thrift/server/simple_server.rb | Removes redundant .to_s in to_s. |
| lib/rb/lib/thrift/server/base_server.rb | Removes redundant .to_s calls in nested to_s composition. |
| lib/rb/lib/thrift/protocol/json_protocol.rb | Removes redundant parentheses/escapes and simplifies control flow for redundancy cops. |
| lib/rb/lib/thrift/protocol/header_protocol.rb | Removes redundant .to_s in to_s. |
| lib/rb/lib/thrift/protocol/compact_protocol.rb | Removes redundant intermediate assignment/return and redundant .to_s in to_s. |
| lib/rb/lib/thrift/protocol/binary_protocol.rb | Removes redundant intermediate assignment/return and redundant .to_s in to_s. |
| lib/rb/lib/thrift/protocol/base_protocol.rb | Removes redundant string interpolation wrapper in to_s. |
| lib/rb/lib/thrift/bytes.rb | Removes redundant parentheses in a conditional. |
| lib/rb/.rubocop.yml | Enables redundancy-related RuboCop cops used to drive these auto-corrections. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Client: rb Co-Authored-By: OpenAI Codex (GPT-5.6) <codex@openai.com>
kpumuk
force-pushed
the
rb-rubocop-redundancy
branch
from
August 17, 2026 01:07
a76aa6e to
c169654
Compare
5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Enable
Lint/RedundantStringCoercionand the safeStyle/Redundant*cops for assignments, exceptions, freezing, interpolation, parentheses, explicitself, and string escapes.The autocorrections remove unnecessary intermediate assignments, coercions, receivers, grouping, and escaping while preserving behavior across the Ruby library, specs, integration tests, and tutorial code.
Style/RedundantBeginandStyle/RedundantReturnremain separate follow-up changes.Style/RedundantPercentQis intentionally not enabled.This follows the merged ambiguity PR #3725; its diff contains only the general redundancy layer.
[skip ci]anywhere in the commit message to free up build resources.