Skip to content

Enable RuboCop redundancy rules - #3726

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

Enable RuboCop redundancy rules#3726
kpumuk merged 1 commit into
apache:masterfrom
kpumuk:rb-rubocop-redundancy

Conversation

@kpumuk

@kpumuk kpumuk commented Aug 16, 2026

Copy link
Copy Markdown
Member

Enable Lint/RedundantStringCoercion and the safe Style/Redundant* cops for assignments, exceptions, freezing, interpolation, parentheses, explicit self, 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/RedundantBegin and Style/RedundantReturn remain separate follow-up changes. Style/RedundantPercentQ is intentionally not enabled.

This follows the merged ambiguity PR #3725; its diff contains only the general redundancy 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.

Copilot AI lite review requested due to automatic review settings August 16, 2026 23:51
@mergeable mergeable Bot added the ruby Pull requests that update Ruby code label Aug 16, 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 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/RedundantStringCoercion and several safe Style/Redundant* cops in lib/rb/.rubocop.yml.
  • Replace redundant string interpolation / explicit .to_s calls with direct interpolation or .to_s where 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.

Comment thread lib/rb/lib/thrift/protocol/json_protocol.rb
Client: rb

Co-Authored-By: OpenAI Codex (GPT-5.6) <codex@openai.com>
@kpumuk
kpumuk force-pushed the rb-rubocop-redundancy branch from a76aa6e to c169654 Compare August 17, 2026 01:07
Copilot AI review requested due to automatic review settings August 17, 2026 01:07

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

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

@kpumuk
kpumuk merged commit 9c0d894 into apache:master Aug 17, 2026
94 of 95 checks passed
@kpumuk
kpumuk deleted the rb-rubocop-redundancy branch August 17, 2026 01:39
@kpumuk kpumuk mentioned this pull request Aug 17, 2026
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ruby Pull requests that update Ruby code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants