Skip to content

Enable RuboCop Lint/UselessAssignment - #3729

Open
kpumuk wants to merge 1 commit into
apache:masterfrom
kpumuk:rb-rubocop-useless-assignment
Open

Enable RuboCop Lint/UselessAssignment#3729
kpumuk wants to merge 1 commit into
apache:masterfrom
kpumuk:rb-rubocop-useless-assignment

Conversation

@kpumuk

@kpumuk kpumuk commented Aug 17, 2026

Copy link
Copy Markdown
Member

Enable Lint/UselessAssignment and remove assignments whose values are never read across the Ruby library, benchmarks, specs, integration client, and tutorial.

The Ruby generator now binds decoded service arguments and results only when generated methods consume them. Focused functional coverage verifies zero-argument processor methods and void client receivers. The Ruby cross-test client also exercises its escape/junk string and multilingual string separately, fixing an overwritten test input exposed by the cop.

  • 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 04:50
Copilot AI lite review requested due to automatic review settings August 17, 2026 04:50
@kpumuk
kpumuk requested review from fishy and mhlakhani as code owners August 17, 2026 04:50

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 Lint/UselessAssignment for the Ruby codebase and updates Ruby sources/tests plus the Ruby code generator to avoid assigning values that are never read, while keeping behavior intact.

Changes:

  • Enabled Lint/UselessAssignment in lib/rb/.rubocop.yml and removed/adjusted unused assignments across Ruby library code, specs, benchmarks, integration tests, and tutorial code.
  • Updated the Ruby generator to only bind decoded args/results when the generated methods actually consume them (void/no-arg cases avoid unused locals).
  • Added/adjusted functional coverage for the Ruby generator and strengthened the Ruby integration string test to exercise both escaped and unicode inputs.

Reviewed changes

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

Show a summary per file
File Description
tutorial/rb/RubyClient.rb Removes an unused assignment in the divide-by-zero tutorial example.
test/rb/integration/TestClient.rb Splits string test inputs and asserts round-trips for both escaped and unicode cases.
lib/rb/thrift.gemspec Removes an unused local variable in gemspec setup.
lib/rb/spec/uuid_validation_spec.rb Avoids unused locals from read_field_begin return values in UUID specs.
lib/rb/spec/header_protocol_spec.rb Avoids unused locals from protocol read APIs in header protocol specs.
lib/rb/spec/compact_protocol_spec.rb Avoids unused locals from read_field_begin in compact protocol spec.
lib/rb/lib/thrift/union.rb Avoids unused field-name locals when reading unions.
lib/rb/lib/thrift/struct.rb Avoids unused field-name locals when reading structs.
lib/rb/lib/thrift/server/thread_pool_server.rb Removes unused rescued exception variable in worker loop.
lib/rb/lib/thrift/server/nonblocking_server.rb Removes unused rescued exception variable in accept loop.
lib/rb/lib/thrift/protocol/base_protocol.rb Avoids unused locals when skipping struct fields.
lib/rb/lib/thrift/exceptions.rb Avoids unused field-name locals when reading application exceptions.
lib/rb/benchmark/benchmark.rb Removes useless accumulator reassignment and an unused local in reporting.
lib/rb/.rubocop.yml Enables Lint/UselessAssignment to enforce unused-assignment cleanup going forward.
compiler/cpp/tests/rb/t_rb_generator_functional_tests.cc Adds functional expectations for void/no-arg Ruby service codegen behavior.
compiler/cpp/src/thrift/generate/t_rb_generator.cc Updates Ruby code generation to avoid unused args/result locals in void/no-arg scenarios.

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

@mergeable mergeable Bot added ruby Pull requests that update Ruby code compiler labels Aug 17, 2026
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